Package: makedumpfile Version: 1:1.6.1-1 Severity: wishlist Tags: patch Hi,
To save storage space (especially when dumping the core to a remote host), please add support for compressing the dumpfile. The attached patch adds support for bzip2, gzip, lz4, xz and applies cleanly after the FTP support patch from bug #856957. -- Benjamin Drung System Developer Debian & Ubuntu Developer ProfitBricks GmbH Greifswalder Str. 207 D - 10405 Berlin Email: benjamin.dr...@profitbricks.com URL: http://www.profitbricks.com Sitz der Gesellschaft: Berlin. Registergericht: Amtsgericht Charlottenburg, HRB 125506B. Geschäftsführer: Andreas Gauger, Achim Weiss.
>From 1c66e03ed99a5f29b89fed5f5a323135e53fa044 Mon Sep 17 00:00:00 2001 From: Benjamin Drung <benjamin.dr...@profitbricks.com> Date: Mon, 6 Mar 2017 16:16:25 +0100 Subject: [PATCH] Support compressing the dumpfile To save storage space (especially when dumping the core to a remote host), add support for compressing the dumpfile. --- debian/kdump-config | 43 +++++++++++++++++++++++++++++++++++-------- debian/kdump-tools.default | 3 +++ 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/debian/kdump-config b/debian/kdump-config index b9a1b89..bb0cfcc 100755 --- a/debian/kdump-config +++ b/debian/kdump-config @@ -654,6 +654,33 @@ define_stampdir() } +compress() { + if [ "$KDUMP_COMPRESSION" = "bzip2" ]; then + bzip2 -c + elif [ "$KDUMP_COMPRESSION" = "gzip" ]; then + gzip -c + elif [ "$KDUMP_COMPRESSION" = "lz4" ]; then + lz4 -c + elif [ "$KDUMP_COMPRESSION" = "xz" ]; then + /usr/bin/xz -c + else + cat + fi +} + +compression_extension() { + if [ "$KDUMP_COMPRESSION" = "bzip2" ]; then + echo ".bz2" + elif [ "$KDUMP_COMPRESSION" = "gzip" ]; then + echo ".gz" + elif [ "$KDUMP_COMPRESSION" = "lz4" ]; then + echo ".lz4" + elif [ "$KDUMP_COMPRESSION" = "xz" ]; then + echo ".xz" + fi +} + + # Saving the vmcore: # Our priorities are: # 1. If the makedumpfile config link is valid, use that @@ -667,8 +694,8 @@ kdump_save_core() { KDUMP_STAMP=`date +"%Y%m%d%H%M"` KDUMP_STAMPDIR=$(define_stampdir $KDUMP_STAMP) - KDUMP_CORETEMP="$KDUMP_STAMPDIR/dump-incomplete" - KDUMP_COREFILE="$KDUMP_STAMPDIR/dump.$KDUMP_STAMP" + KDUMP_CORETEMP="$KDUMP_STAMPDIR/dump-incomplete$(compression_extension)" + KDUMP_COREFILE="$KDUMP_STAMPDIR/dump.$KDUMP_STAMP$(compression_extension)" KDUMP_DMESGFILE="$KDUMP_STAMPDIR/dmesg.$KDUMP_STAMP" # If we use NFS, verify that we can mount the FS @@ -706,7 +733,7 @@ kdump_save_core() fi log_action_msg "running makedumpfile $MAKEDUMP_ARGS $vmcore_file $KDUMP_CORETEMP" - makedumpfile $MAKEDUMP_ARGS $vmcore_file $KDUMP_CORETEMP + makedumpfile $MAKEDUMP_ARGS $vmcore_file | compress > $KDUMP_CORETEMP ERROR=$? if [ $ERROR -ne 0 ] ; then log_failure_msg "$NAME: makedumpfile failed, falling back to 'cp'" @@ -782,7 +809,7 @@ kdump_save_core_to_ftp() KDUMP_STAMP=`date +"%Y%m%d%H%M"` KDUMP_STAMPDIR=$(define_stampdir "") - KDUMP_COREFILE="${KDUMP_STAMPDIR}dump.$KDUMP_STAMP" + KDUMP_COREFILE="${KDUMP_STAMPDIR}dump.$KDUMP_STAMP$(compression_extension)" KDUMP_TMPDMESG="/tmp/dmesg.$KDUMP_STAMP" KDUMP_DMESGFILE="${KDUMP_STAMPDIR}dmesg.$KDUMP_STAMP" ERROR=0 @@ -801,7 +828,7 @@ kdump_save_core_to_ftp() # Add '-F' [flatten] to MAKEDUMP_ARGS, if not there: [ "${MAKEDUMP_ARGS#-F*}" != "${MAKEDUMP_ARGS}" ] || MAKEDUMP_ARGS="${MAKEDUMP_ARGS} -F" log_action_msg "sending makedumpfile $MAKEDUMP_ARGS $vmcore_file via FTP to $KDUMP_REMOTE_HOST:$KDUMP_COREFILE" - makedumpfile $MAKEDUMP_ARGS $vmcore_file | busybox ftpput $FTPPUT_ARGS $KDUMP_REMOTE_HOST $KDUMP_COREFILE - + makedumpfile $MAKEDUMP_ARGS $vmcore_file | compress | busybox ftpput $FTPPUT_ARGS $KDUMP_REMOTE_HOST $KDUMP_COREFILE - ERROR=$? # did we succeed? @@ -847,8 +874,8 @@ kdump_save_core_to_ssh() KDUMP_STAMP=`date +"%Y%m%d%H%M"` KDUMP_STAMPDIR=$(define_stampdir $KDUMP_STAMP) - KDUMP_CORETEMP="$KDUMP_STAMPDIR/dump-incomplete" - KDUMP_COREFILE="$KDUMP_STAMPDIR/dump.$KDUMP_STAMP" + KDUMP_CORETEMP="$KDUMP_STAMPDIR/dump-incomplete$(compression_extension)" + KDUMP_COREFILE="$KDUMP_STAMPDIR/dump.$KDUMP_STAMP$(compression_extension)" KDUMP_TMPDMESG="/tmp/dmesg.$KDUMP_STAMP" KDUMP_DMESGFILE="$KDUMP_STAMPDIR/dmesg.$KDUMP_STAMP" ERROR=0 @@ -865,7 +892,7 @@ kdump_save_core_to_ssh() # Add '-F' [flatten] to MAKEDUMP_ARGS, if not there: [ "${MAKEDUMP_ARGS#-F*}" != "${MAKEDUMP_ARGS}" ] || MAKEDUMP_ARGS="${MAKEDUMP_ARGS} -F" log_action_msg "sending makedumpfile $MAKEDUMP_ARGS $vmcore_file to $KDUMP_REMOTE_HOST : $KDUMP_CORETEMP" - makedumpfile $MAKEDUMP_ARGS $vmcore_file | ssh -i $KDUMP_SSH_KEY $KDUMP_REMOTE_HOST dd of=$KDUMP_CORETEMP + makedumpfile $MAKEDUMP_ARGS $vmcore_file | compress | ssh -i $KDUMP_SSH_KEY $KDUMP_REMOTE_HOST dd of=$KDUMP_CORETEMP ERROR=$? if [ $ERROR -ne 0 ] ; then log_failure_msg "$NAME: makedumpfile failed, falling back to 'scp'" diff --git a/debian/kdump-tools.default b/debian/kdump-tools.default index 16c0873..81378ef 100644 --- a/debian/kdump-tools.default +++ b/debian/kdump-tools.default @@ -40,10 +40,13 @@ KDUMP_INITRD=/var/lib/kdump/initrd.img # KDUMP_NUM_DUMPS - This variable controls how many dump files are kept on # the machine to prevent running out of disk space. If set to 0 or unset, # the variable is ignored and no dump files are automatically purged. +# KDUMP_COMPRESSION - Compress the dumpfile. No compression is used by default. +# Supported compressions: bzip2, gzip, lz4, xz KDUMP_COREDIR="/var/crash" #KDUMP_FAIL_CMD="reboot -f" #KDUMP_DUMP_DMESG= #KDUMP_NUM_DUMPS= +#KDUMP_COMPRESSION= # --------------------------------------------------------------------------- -- 2.9.3