path: root/sbin/dumpon
diff options
authorMark Johnston <markj@FreeBSD.org>2017-10-25 00:51:00 +0000
committerMark Johnston <markj@FreeBSD.org>2017-10-25 00:51:00 +0000
commit64a16434d8dbd5432e2f1a49007e53a449d43830 (patch)
treee9cdb0a8780646580c9a0d35fd94332c6a2443ad /sbin/dumpon
parent7b79d6d61ac82b21e2acc396a4ea66d0e92c79d9 (diff)
Add support for compressed kernel dumps.
When using a kernel built with the GZIO config option, dumpon -z can be used to configure gzip compression using the in-kernel copy of zlib. This is useful on systems with large amounts of RAM, which require a correspondingly large dump device. Recovery of compressed dumps is also faster since fewer bytes need to be copied from the dump device. Because we have no way of knowing the final size of a compressed dump until it is written, the kernel will always attempt to dump when compression is configured, regardless of the dump device size. If the dump is aborted because we run out of space, an error is reported on the console. savecore(8) is modified to handle compressed dumps and save them to vmcore.<index>.gz, as it does when given the -z option. A new rc.conf variable, dumpon_flags, is added. Its value is added to the boot-time dumpon(8) invocation that occurs when a dump device is configured in rc.conf. Reviewed by: cem (earlier version) Discussed with: def, rgrimes Relnotes: yes Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D11723
Notes: svn path=/head/; revision=324965
Diffstat (limited to 'sbin/dumpon')
2 files changed, 35 insertions, 6 deletions
diff --git a/sbin/dumpon/dumpon.8 b/sbin/dumpon/dumpon.8
index b0c8e2c12de4..572bd030aef1 100644
--- a/sbin/dumpon/dumpon.8
+++ b/sbin/dumpon/dumpon.8
@@ -28,7 +28,7 @@
.\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$
-.Dd December 10, 2016
+.Dd October 24, 2017
@@ -38,6 +38,7 @@
.Op Fl v
.Op Fl k Ar public_key_file
+.Op Fl z
.Ar special_file
.Op Fl v
@@ -114,6 +115,22 @@ This flag requires a kernel compiled with the
kernel option.
+.Fl z
+option configures the kernel to compress the dump in gzip format before writing
+it to the dump device.
+This reduces the amount of space required for the dump and accelerates
+recovery with
+.Xr savecore 8
+since less data needs to be copied from the dump device.
+When compression is enabled, the
+utility will not verify that the dump device is sufficiently large for a full
+This flag requires a kernel compiled with the
+kernel option.
.Fl l
flag causes
@@ -272,3 +289,7 @@ utility appeared in
Because the file system layer is already dead by the time a crash dump
is taken, it is not possible to send crash dumps directly to a file.
+It is currently not possible to configure both compression and encryption.
+The encrypted dump format assumes that the kernel dump size is a multiple
+of the cipher block size, which may not be true when the dump is compressed.
diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c
index e3701eace3db..8530c63b889d 100644
--- a/sbin/dumpon/dumpon.c
+++ b/sbin/dumpon/dumpon.c
@@ -71,7 +71,7 @@ static void
fprintf(stderr, "%s\n%s\n%s\n",
- "usage: dumpon [-v] [-k public_key_file] special_file",
+ "usage: dumpon [-v] [-k public_key_file] [-z] special_file",
" dumpon [-v] off",
" dumpon [-v] -l");
@@ -190,11 +190,12 @@ main(int argc, char *argv[])
int ch;
int i, fd;
int do_listdumpdev = 0;
- bool enable;
+ bool enable, gzip;
+ gzip = false;
pubkeyfile = NULL;
- while ((ch = getopt(argc, argv, "k:lv")) != -1)
+ while ((ch = getopt(argc, argv, "k:lvz")) != -1)
switch((char)ch) {
case 'k':
pubkeyfile = optarg;
@@ -205,6 +206,9 @@ main(int argc, char *argv[])
case 'v':
verbose = 1;
+ case 'z':
+ gzip = true;
+ break;
@@ -247,9 +251,11 @@ main(int argc, char *argv[])
fd = open(dumpdev, O_RDONLY);
if (fd < 0)
err(EX_OSFILE, "%s", dumpdev);
- check_size(fd, dumpdev);
- bzero(&kda, sizeof(kda));
+ if (!gzip)
+ check_size(fd, dumpdev);
+ bzero(&kda, sizeof(kda));
kda.kda_enable = 0;
i = ioctl(fd, DIOCSKERNELDUMP, &kda);
explicit_bzero(&kda, sizeof(kda));
@@ -260,6 +266,8 @@ main(int argc, char *argv[])
kda.kda_enable = 1;
+ kda.kda_compression = gzip ? KERNELDUMP_COMP_GZIP :
i = ioctl(fd, DIOCSKERNELDUMP, &kda);
explicit_bzero(kda.kda_encryptedkey, kda.kda_encryptedkeysize);