diff -Nru makedumpfile-1.6.2/debian/changelog makedumpfile-1.6.2/debian/changelog --- makedumpfile-1.6.2/debian/changelog 2017-12-13 15:39:23.000000000 +0000 +++ makedumpfile-1.6.2/debian/changelog 2018-01-12 15:47:19.000000000 +0000 @@ -1,12 +1,19 @@ -makedumpfile (1:1.6.2-1ubuntu1) bionic; urgency=medium +makedumpfile (1:1.6.2-2) unstable; urgency=medium - * KDUMP_CMDLINE_APPEND: add noirqdistrib to default command line. As it's - only used by ppc64el, it's not required to be conditionally added. - (LP: #1658733) + [ dann frazier ] + * Make the kdump kernel cmdline consistent in comments, code & docs. + * Set reasonable default cmdlines for arm64. (Closes: 883899) + * ppc64el: Remove ata_piix.prefer_ms_hyperv=0 from crashkernel cmdline + * ppc64el: add noirqdistrib to command line. (LP: #1658733) + * Add myself to Uploaders. + * Build-Depend on debhelper (>= 9.20160709) instead of dh-systemd, + which is obsolete. Thanks lintian. + + [ Thadeu Lima de Souza Cascardo ] * Set crashkernel for ppc64el to load at 128M instead of 32M. That allows larger kernels to boot. (LP: #1728115) - -- Thadeu Lima de Souza Cascardo Tue, 07 Nov 2017 12:23:33 +0000 + -- dann frazier Fri, 12 Jan 2018 08:47:19 -0700 makedumpfile (1:1.6.2-1) unstable; urgency=medium diff -Nru makedumpfile-1.6.2/debian/control makedumpfile-1.6.2/debian/control --- makedumpfile-1.6.2/debian/control 2017-11-01 13:50:26.000000000 +0000 +++ makedumpfile-1.6.2/debian/control 2018-01-12 15:47:19.000000000 +0000 @@ -2,9 +2,15 @@ Section: devel Priority: optional Maintainer: Louis Bouchard +Uploaders: dann frazier Standards-Version: 3.9.8 -Build-Depends: debhelper (>= 9), libelf-dev, libz-dev, libdw-dev (>= 0.141-2ubuntu1), - libbz2-dev, liblzo2-dev, dh-systemd (>=1.5), po-debconf +Build-Depends: debhelper (>= 9.20160709), + libelf-dev, + libz-dev, + libdw-dev (>= 0.141-2ubuntu1), + libbz2-dev, + liblzo2-dev, + po-debconf Vcs-Git: git://anonscm.debian.org/collab-maint/makedumpfile.git Vcs-Browser: https://anonscm.debian.org/gitweb/?p=collab-maint/makedumpfile.git diff -Nru makedumpfile-1.6.2/debian/kdump-config makedumpfile-1.6.2/debian/kdump-config --- makedumpfile-1.6.2/debian/kdump-config 2017-12-13 15:37:59.000000000 +0000 +++ makedumpfile-1.6.2/debian/kdump-config 1970-01-01 00:00:00.000000000 +0000 @@ -1,959 +0,0 @@ -#!/bin/bash - -# kdump-config -# Copyright (C) 2007-2009 Hewlett-Packard Development Company, L.P. -# Written by Terry Loftin -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# kdump-config -# a shell script utility to manage: -# * loading a kdump kernel -# * unloading a kdump kernel -# * saving a vmcore kdump kernel -# * determining the status of kdump -# * propagate ssh key to remote host - -PATH=/bin:/usr/bin:/sbin:/usr/sbin -NAME=${NAME:="kdump-config"} - -. /lib/lsb/init-functions -. /lib/init/vars.sh - -# Global Setup -KDUMP_DEFAULTS=/etc/default/kdump-tools -[ -r $KDUMP_DEFAULTS ] && . $KDUMP_DEFAULTS - -KEXEC=/sbin/kexec -[ -e $KEXEC ] || exit 1; - -KVER=`uname -r` -ARCH=`uname -m` - -# Set up defaults -KDUMP_SYSCTL=${KDUMP_SYSCTL:="kernel.panic_on_oops=1"} -KDUMP_COREDIR=${KDUMP_COREDIR:=/var/crash} -KDUMP_DUMP_DMESG=${KDUMP_DUMP_DMESG:=1} -KDUMP_DIR="/var/lib/kdump" -KDUMP_NUM_DUMPS=${KDUMP_NUM_DUMPS:=0} -NFS_TIMEO=${NFS_TIMEO:=600} -NFS_RETRANS=${NFS_RETRANS:=3} -MAKEDUMP_ARGS=${MAKEDUMP_ARGS:="-c -d 31"} -KDUMP_CMDLINE_APPEND=${KDUMP_CMDLINE_APPEND:="irqpoll noirqdistrib nr_cpus=1 nousb systemd.unit=kdump-tools.service ata_piix.prefer_ms_hyperv=0"} -KDUMP_KERNEL_HOOK="/etc/kernel/postinst.d/kdump-tools" -[ -d $KDUMP_COREDIR ] || mkdir -p $KDUMP_COREDIR ; - -IOMEM_ADDR=`grep -i "Crash kernel" /proc/iomem | sed "s/-..*//" | sed "s/^[ 0]*/0x/"` - -# Constants -vmcore_file=/proc/vmcore -sys_kexec_crash=/sys/kernel/kexec_crash_loaded -sys_fadump_enabled=/sys/kernel/fadump_enabled -sys_fadump_registered=/sys/kernel/fadump_registered -kexec_cmd_file=$KDUMP_COREDIR/kexec_cmd - -# DUMP_MODE = kdump/fadump -# The default dump mode is kdump. -DUMP_MODE="kdump" - -# If /sys/kernel/fadump_enabled is set to `1`, use fadump as dump mechanism -if [ -e $sys_fadump_enabled ] && [ `cat $sys_fadump_enabled` -eq 1 ]; then - DUMP_MODE="fadump" -fi - -# Utility Functions -# -function kdump_help() -{ -cat </dev/null) - sm_path=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) - - if [ -f "$sb_path" ] && [ -f "$sm_path" ]; then - sb=$(hexdump -v -e '/1 "%d\ "' $sb_path|cut -d' ' -f 5) - sm=$(hexdump -v -e '/1 "%d\ "' $sm_path|cut -d' ' -f 5) - - if [ "$sb" = "1" ] && [ "$sm" = "0" ]; then - return 0 - fi - fi - - return 1 -} - -# Find the kexec/kdump kernel and possibly a corresponding initrd. -# A kdump kernel does not need to match the `uname -r` of the booted kernel. -# -# Use the following priorites in determining the kdump kernel: -# 1. An explicit Kdump kernel in the defaults file overrides all -# 2. Use the current running kernel if it is relocatable. -# 3. Give up. Note, a kdump kernel is required. -# -# Returns: 0/1 (success/fail) -# Returns: none. prints warnings or exit -# Sets: KDUMP_KERNEL, KDUMP_INITRD -function locate_kdump_kernel() -{ - # 1: User may have specified the KDUMP_KERNEL and KDUMP_INITRD - # explicitly. Test for existance and either use it or fail. - if [ -n "$KDUMP_KERNEL" ] ; then - if [ ! -e "$KDUMP_KERNEL" ] ; then - log_failure_msg "$KDUMP_DEFAULTS: KDUMP_KERNEL does not exist: $KDUMP_KERNEL" - [ ! $DRY_RUN ] && exit 1; - elif [ -n "$KDUMP_INITRD" -a ! -e "$KDUMP_INITRD" ] ; then - log_failure_msg "$KDUMP_DEFAULTS: KDUMP_INITRD does not exist: $KDUMP_INITRD" - [ ! $DRY_RUN ] && exit 1; - fi - return 0; - fi - - # 2: The currently running kernel may be relocatable. If so, then - # use the currently running kernel as the crash kernel. - if check_relocatable /boot/config-$KVER; then - if [ -f /boot/vmlinuz-$KVER ]; then - KDUMP_KERNEL=/boot/vmlinuz-$KVER - elif [ -f /boot/vmlinux-$KVER ]; then - KDUMP_KERNEL=/boot/vmlinux-$KVER - else - KDUMP_KERNEL= - fi - if [ -f /boot/initrd.img-$KVER ]; then - KDUMP_INITRD=/boot/initrd.img-$KVER - else - KDUMP_INITRD= - fi - KDUMP_ADDR="relocatable" - return 0; - fi - - # If the kdump kernel is not relocatable, we need to make sure it was - # built to start at the crashkernel= address. IOMEM_ADDR is already - # set... - if [ -z "$KDUMP_CONFIG" ] ; then return 0 ; fi - - if check_relocatable $KDUMP_CONFIG; then - KDUMP_ADDR="relocatable" - else - KDUMP_ADDR=`grep CONFIG_PHYSICAL_START $KDUMP_CONFIG | sed "s/CONFIG_PHYSICAL_START=//"` - # compare the two - if [ "$KDUMP_ADDR" != "$IOMEM_ADDR" ] ; then - log_failure_msg "kdump kernel relocation address does not match crashkernel parameter" - [ ! $DRY_RUN ] && exit 1; - return 1; - fi - fi - - return 0; -} - -# Register firmware-assisted dump as the dump mechanism -# Returns: none. prints warnings or exit -function fadump_register() -{ - # set fadump registered sys node to `1` to register fadump - if [ "`cat $sys_fadump_registered`" -ne 1 ]; then - echo 1 > $sys_fadump_registered - fi - rc=`cat $sys_fadump_registered` - if [ $rc -ne 1 ] ; then - log_failure_msg "fadump registering failed" - logger -t $NAME "fadump registering failed" - [ ! $DRY_RUN ] && exit 1; - fi - - log_success_msg "fadump registered successfully" - logger -t $NAME "fadump registered successfully" - - # Last step: make sure panic_on_oops is enabled - PANIC_ON_OOPS=`/sbin/sysctl kernel.panic_on_oops | cut -d" " -f3` - if [ $PANIC_ON_OOPS != "1" ] ; then - sysctl -w kernel.panic_on_oops=1 >/dev/null - fi -} - -# Returns: none. prints warnings or exit -function fadump_unregister() -{ - # set fadump registered sys node to `0` to un-register fadump - if [ "`cat $sys_fadump_registered`" -ne 0 ]; then - echo 0 > $sys_fadump_registered - fi - rc=`cat $sys_fadump_registered` - if [ $rc -ne 0 ] ; then - log_failure_msg "fadump un-registering failed" - logger -t $NAME "fadump un-registering failed" - [ ! $DRY_RUN ] && exit 1; - fi - - log_success_msg "fadump un-registered successfully" - logger -t $NAME "fadump un-registered successfully" -} - -function kdump_create_symlinks() -{ -kernel_version=$1 - - if [ -e $sys_kexec_crash -a `cat $sys_kexec_crash` -eq 1 ] ; then - log_failure_msg "Cannot change symbolic links when kdump is loaded" - exit 1 - fi - - if [ -e /boot/vmlinu[xz]-${kernel_version} ];then - create_symlink vmlinuz $kernel_version - - if [ -f $KDUMP_DIR/initrd.img-${kernel_version} ]; then - create_symlink initrd.img ${kernel_version} - else - if [ -x $KDUMP_KERNEL_HOOK ];then - $KDUMP_KERNEL_HOOK $kernel_version - create_symlink initrd.img $kernel_version - else - log_failure_msg "Unable to locate kernel hook" - fi - fi - else - log_failure_msg "Invalid kernel version : $kernel_version" - fi -} -# -# Load the already determined kdump kernel and kdump initrd using kexec -# 1: A KDUMP_CMDLINE in the defaults file overrides all. -# 2: Use /proc/cmdline -# a. strip out the crashkernel= parameter. -# b. strip out the abm= parameter. -# c. append KDUMP_CMDLINE_APPEND from defaults file -# Sets: KEXEC_CMD -# Returns: none. prints warnings or exit -function kdump_load() -{ - # assemble the kexec command used to load the kdump kernel - KEXEC_CMD="$KEXEC -p" - - if check_secure_boot || check_securelevel; then - KEXEC_CMD="$KEXEC_CMD -s" - fi - - # Different kernel types allow/require different options: - # The only special case here is that x86, x86_64 elf style - # binaries require the --args-linux argument. - if [ "$ARCH" != "ia64" ] ; then - ELF_TST=`file $KDUMP_KERNEL | grep ELF` - if [ -n "$ELF_TST" ] ; then - KEXEC_CMD="$KEXEC_CMD --args-linux" - fi - fi - - # KDUMP_KEXEC_ARGS, if non-empty, comes from the defaults file. - if [ -n "$KDUMP_KEXEC_ARGS" ] ; then - KEXEC_CMD="$KEXEC_CMD $KDUMP_KEXEC_ARGS" - fi - - # Assemble the --commmand-line: - if [ -z "$KDUMP_CMDLINE" ] ; then - KDUMP_CMDLINE=`cat /proc/cmdline | \ - sed -r -e 's/(^| )crashkernel=[^ ]*//g' \ - -e 's/(^| )hugepages=[^ ]*//g' \ - -e 's/(^| )hugepagesz=[^ ]*//g' \ - -e 's/(^| )abm=[^ ]*//g' \ - -e 's/"/\\\\"/'g` - fi - KDUMP_CMDLINE="$KDUMP_CMDLINE $KDUMP_CMDLINE_APPEND" - KEXEC_CMD="$KEXEC_CMD --command-line=\"$KDUMP_CMDLINE\"" - - # Assemble the --initrd: - if [ -e "$KDUMP_INITRD" ] ; then - KEXEC_CMD="$KEXEC_CMD --initrd=$KDUMP_INITRD" - fi - - # Finally, add the kernel: - KEXEC_CMD="$KEXEC_CMD $KDUMP_KERNEL" - - if [ $DRY_RUN ] ; then return 0; fi - - eval $KEXEC_CMD - - if [ $? == 0 ]; then - log_success_msg "loaded kdump kernel" - logger -t $NAME "$KEXEC_CMD" - logger -t $NAME "loaded kdump kernel" - echo "$KEXEC_CMD" >$kexec_cmd_file - else - log_failure_msg "failed to load kdump kernel" - logger -t $NAME "failed to load kdump kernel" - [ ! $DRY_RUN ] && exit 1; - fi - - # Last step: make sure panic_on_oops is enabled - PANIC_ON_OOPS=`/sbin/sysctl kernel.panic_on_oops | cut -d" " -f3` - if [ $PANIC_ON_OOPS != "1" ] ; then - sysctl -w kernel.panic_on_oops=1 >/dev/null - fi - -} - -# Returns: none. prints warnings or exit -function kdump_unload() -{ - if check_secure_boot || check_securelevel; then - $KEXEC -s -p -u - else - $KEXEC -p -u - fi - - if [ $? == 0 ]; then - log_success_msg "unloaded kdump kernel" - logger -t $NAME "unloaded kdump kernel" - else - log_failure_msg "failed to unload kdump kernel" - logger -t $NAME "failed to unload kdump kernel" - [ ! $DRY_RUN ] && exit 1; - fi -} - -# -# Return the name of the subdirectory to store core file. -# Will add hostname/IP according to the value of -# HOSTTAG if networked dump is selected - -function define_stampdir() -{ - STAMP=$1 - HOSTTAG="${HOSTTAG:=ip}" - - if [ -z "$SSH" ] && [ -z "$NFS" ]; then - echo "$KDUMP_COREDIR/$STAMP" - elif [ "$HOSTTAG" = "hostname" ];then - echo "$KDUMP_COREDIR/$(hostname)-$STAMP" - else - # Looping to give time to network to settle - typeset -i counter=0 - while (( counter < 5));do - THIS_HOST="$(hostname -I)" - set -- $THIS_HOST - THIS_HOST=$1 - if [ -z "$THIS_HOST" ]; then - sleep 1 - ((counter+=1)) - else - break - fi - done - if [ -z "$THIS_HOST" ]; then - # Send log msg to stderr to avoid polluting - # the result of the function - log_failure_msg "Unable to get IP from network" >&2 - log_action_msg "Reverting to HOSTTAG=hostname" >&2 - THIS_HOST="$(hostname)" - fi - echo "$KDUMP_COREDIR/$THIS_HOST-$STAMP" - fi -} - - -# Saving the vmcore: -# Our priorities are: -# 1. If the makedumpfile config link is valid, use that -# 2. else if the vmlinux link is valid, use that -# 3. else fallback to using: makedumpfile -d 1 -c -# 4. else use cp -# -# Returns: 0/1 (success/fail) -# Sets: KDUMP_STAMPDIR, KDUMP_COREFILE -function 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_DMESGFILE="$KDUMP_STAMPDIR/dmesg.$KDUMP_STAMP" - - # If we use NFS, verify that we can mount the FS - # - if [ -n "$NFS" ];then - log_action_msg "Mounting NFS mountpoint $NFS ..." - mount -t nfs -o nolock -o tcp -o soft -o timeo=${NFS_TIMEO} -o retrans=${NFS_RETRANS} $NFS $KDUMP_COREDIR - ERROR=$? - if [ $ERROR -ne 0 ];then - log_failure_msg "$NAME: Unable to mount remote NFS directory $NFS. Cannot save core" - logger -t $NAME "Unable to mount remote NFS directory $NFS. Cannot save core" - return 1; - fi - - # FS is mounted, see if we can write to it - # - mkdir -p $KDUMP_STAMPDIR - ERROR=$? - - if [ $ERROR -ne 0 ];then - log_failure_msg "$NAME: Unable to write to the remote NFS directory $NFS. Cannot save core" - logger -t $NAME "Unable to write to the remote NFS directory $NFS. Cannot save core" - umount $KDUMP_COREDIR - UMNT_ERROR=$? - if [ $UMNT_ERROR -ne 0 ];then - log_failure_msg "$NAME: Unable to cleanly unmount the NFS file system" - logger -t $NAME "Unable to cleanly unmount the NFS file system" - fi - else - log_action_msg "Dumping to NFS mountpoint $NFS/$KDUMP_STAMP" - logger -t $NAME "Dumping to NFS mountpoint $NFS/$KDUMP_STAMP" - fi - else - mkdir -p $KDUMP_STAMPDIR - fi - - log_action_msg "running makedumpfile $MAKEDUMP_ARGS $vmcore_file $KDUMP_CORETEMP" - makedumpfile $MAKEDUMP_ARGS $vmcore_file $KDUMP_CORETEMP - ERROR=$? - if [ $ERROR -ne 0 ] ; then - log_failure_msg "$NAME: makedumpfile failed, falling back to 'cp'" - logger -t $NAME "makedumpfile failed, falling back to 'cp'" - KDUMP_CORETEMP="$KDUMP_STAMPDIR/vmcore-incomplete" - KDUMP_COREFILE="$KDUMP_STAMPDIR/vmcore.$KDUMP_STAMP" - cp $vmcore_file $KDUMP_CORETEMP - ERROR=$? - fi - - # did we succeed? - if [ $ERROR == 0 ]; then - mv $KDUMP_CORETEMP $KDUMP_COREFILE - log_success_msg "$NAME: saved vmcore in $KDUMP_STAMPDIR" - logger -t $NAME "saved vmcore in $KDUMP_STAMPDIR" - sync - else - log_failure_msg "$NAME: failed to save vmcore in $KDUMP_STAMPDIR" - logger -t $NAME "failed to save vmcore in $KDUMP_STAMPDIR" - fi - - # dump the dmesg buffer - if [ "$KDUMP_DUMP_DMESG" -eq 1 ] ; then - log_action_msg "running makedumpfile --dump-dmesg $vmcore_file $KDUMP_DMESGFILE" - makedumpfile --dump-dmesg $vmcore_file $KDUMP_DMESGFILE - ERROR=$? - if [ $ERROR -ne 0 ] ; then - log_failure_msg "$NAME: makedumpfile --dump-dmesg failed. dmesg content will be unavailable" - logger -t $NAME "makedumpfile --dump-dmesg failed. dmesg content will be unavailable" - fi - - # did we succeed? - if [ $ERROR == 0 ]; then - log_success_msg "$NAME: saved dmesg content in $KDUMP_STAMPDIR" - logger -t $NAME "saved dmesg content in $KDUMP_STAMPDIR" - sync - else - log_failure_msg "$NAME: failed to save dmesg content in $KDUMP_STAMPDIR" - logger -t $NAME "failed to save dmesg content in $KDUMP_STAMPDIR" - fi - fi - - # limit the number of dumps kept on the local machine - if [ -z "${NFS}" -a $ERROR == 0 -a $KDUMP_NUM_DUMPS -gt 0 ] ; then - num_dumps=$(ls -1dv $KDUMP_COREDIR/2* | wc -l) - if [ $num_dumps -gt $KDUMP_NUM_DUMPS ] ; then - purge_num=$((num_dumps - KDUMP_NUM_DUMPS)) - purge_dir=$(ls -1dv $KDUMP_COREDIR/2* | head -$purge_num | tr "\n" " ") - log_action_msg "Too many dumps, purging: $purge_dir" - logger -t $NAME "Too many dumps, purging: $purge_dir" - rm -rf $purge_dir - fi - fi - - # If we use NFS, umount the remote FS - # - if [ -n "$NFS" ];then - umount $KDUMP_COREDIR - UMNT_ERROR=$? - if [ $UMNT_ERROR -ne 0 ] ; then - log_failure_msg "$NAME: Unable to cleanly unmount the NFS file system" - logger -t $NAME "Unable to cleanly unmount the NFS file system" - fi - fi - - return $ERROR -} - -function kdump_save_core_to_ssh() -{ - KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}" - KDUMP_REMOTE_HOST="$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_TMPDMESG="/tmp/dmesg.$KDUMP_STAMP" - KDUMP_DMESGFILE="$KDUMP_STAMPDIR/dmesg.$KDUMP_STAMP" - ERROR=0 - - ssh -i $KDUMP_SSH_KEY $KDUMP_REMOTE_HOST mkdir -p $KDUMP_STAMPDIR - ERROR=$? - # If remote connections fails, no need to continue - if [ $ERROR -ne 0 ] ; then - log_failure_msg "$NAME: Unable to reach remote server $KDUMP_REMOTE_HOST. No reason to continue" - logger -t $NAME "Unable to reach remote server $KDUMP_REMOTE_HOST. No reason to continue" - return 1 - fi - - # 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 - ERROR=$? - if [ $ERROR -ne 0 ] ; then - log_failure_msg "$NAME: makedumpfile failed, falling back to 'scp'" - logger -t $NAME "makedumpfile failed, falling back to 'scp'" - KDUMP_CORETEMP="$KDUMP_STAMPDIR/vmcore-incomplete" - KDUMP_COREFILE="$KDUMP_STAMPDIR/vmcore.$KDUMP_STAMP" - scp -i $KDUMP_SSH_KEY $vmcore_file $KDUMP_REMOTE_HOST:$KDUMP_CORETEMP - if [ $? -ne 0 ];then - log_failure_msg "$NAME: makedumpfile scp failed. The vmcore file will not be available" - logger -t $NAME "makedumpfile scp failed. The vmcore file will not be available" - else - ERROR=0 - fi - else - ERROR=0 - fi - - # did we succeed? - if [ $ERROR -ne 0 ]; then - log_failure_msg "$NAME: failed to save vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" - logger -t $NAME "failed to save vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" - sync - else - ssh -i $KDUMP_SSH_KEY $KDUMP_REMOTE_HOST mv $KDUMP_CORETEMP $KDUMP_COREFILE - log_success_msg "$NAME: saved vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" - logger -t $NAME "saved vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" - fi - - # dump the dmesg buffer - if [ "$KDUMP_DUMP_DMESG" -eq 1 ] ; then - log_action_msg "running makedumpfile --dump-dmesg $vmcore_file $KDUMP_TMPDMESG" - makedumpfile --dump-dmesg $vmcore_file $KDUMP_TMPDMESG - ERROR=$? - if [ $ERROR -ne 0 ] ; then - log_failure_msg "$NAME: makedumpfile --dump-dmesg failed. dmesg content will be unavailable" - logger -t $NAME "makedumpfile --dump-dmesg failed. dmesg content will be unavailable" - else - scp -i $KDUMP_SSH_KEY $KDUMP_TMPDMESG $KDUMP_REMOTE_HOST:$KDUMP_DMESGFILE - ERROR=$? - fi - - # did we succeed? - if [ $ERROR == 0 ]; then - log_success_msg "$NAME: saved dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" - logger -t $NAME "saved dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" - return 0; - else - log_failure_msg "$NAME: failed to save dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" - logger -t $NAME "failed to save dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" - return 1; - fi - fi -} - -function kdump_propagate() -{ - KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}" - KDUMP_REMOTE_HOST="$SSH" - - # ssh key propagation is only needed - # if remote ssh dump is configured - if [ -z "$KDUMP_REMOTE_HOST" ];then - log_failure_msg "$NAME: Remote ssh dump is not configured. No reason to propagate" - logger -t $NAME "Remote ssh dump is not configured. No reason to propagate" - return 1; - fi - - # Verify if the provided key exists and create it if needed - if [ -f "$KDUMP_SSH_KEY" ];then - echo "Using existing key $KDUMP_SSH_KEY" - else - echo "Need to generate a new ssh key..." - /usr/bin/ssh-keygen -t rsa -f $KDUMP_SSH_KEY -N "" 2>&1 > /dev/null - fi - - KDUMP_SSH_USER=${KDUMP_REMOTE_HOST%@*} - KDUMP_SSH_TARGET=${KDUMP_REMOTE_HOST#*@} - - ssh-copy-id -i $KDUMP_SSH_KEY $KDUMP_SSH_USER@$KDUMP_SSH_TARGET &>/dev/null - ERROR=$? - - if [ $ERROR -ne 0 ];then - log_failure_msg "$NAME: $KDUMP_SSH_KEY failed to be sent to $KDUMP_REMOTE_HOST" - logger -t $NAME "$KDUMP_SSH_KEY failed to be sent to $KDUMP_REMOTE_HOST" - return 1; - else - logger -t $NAME "propagated ssh key $KDUMP_SSH_KEY to server $KDUMP_REMOTE_HOST" - echo "propagated ssh key $KDUMP_SSH_KEY to server $KDUMP_REMOTE_HOST" - return 0; - fi - -} - - - -case "$1" in - test) - DRY_RUN="true" - if [ "$DUMP_MODE" == "fadump" ]; then - check_fadump_support - else - check_kdump_support; - manage_symlinks; - locate_kdump_kernel; - kdump_load; - kdump_test - fi - ;; - show) - DRY_RUN="true" - if [ "$DUMP_MODE" == "fadump" ]; then - check_fadump_support; - else - check_kdump_support; - fi - kdump_show - ;; - load) - if [ "$DUMP_MODE" == "fadump" ]; then - check_fadump_support; - fadump_register - else - check_kdump_support; - manage_symlinks; - locate_kdump_kernel; - kdump_load - fi - ;; - unload) - if [ "$DUMP_MODE" == "fadump" ]; then - fadump_unregister - else - kdump_unload - fi - ;; - status) - if [ "$DUMP_MODE" == "fadump" ]; then - check_fadump_support - if [ `cat $sys_fadump_registered` -eq 1 ] ; then - echo "current state : ready to fadump"; - else - echo "current state : Not ready to fadump"; - fi - else - DRY_RUN=true - check_kdump_support; - manage_symlinks; - if [ `cat $sys_kexec_crash` -eq 1 ] ; then - echo "current state : ready to kdump"; - else - echo "current state : Not ready to kdump"; - fi - fi - exit 0; - ;; - savecore) - if ! [ -z $SSH ];then - kdump_save_core_to_ssh - else - kdump_save_core - fi - exit $? - ;; - propagate) - kdump_propagate; - ;; - symlinks) - if [ -z $2 ];then - log_failure_msg "Invalid argument : missing kernel version" - else - kdump_create_symlinks $2 - fi - ;; - help|-h*|--h*) - kdump_help - ;; - *) - echo "Usage: $0 {help|test|show|status|load|unload|savecore|propagate|symlinks kernel-version}" - exit 1 - ;; -esac - -exit 0 diff -Nru makedumpfile-1.6.2/debian/kdump-config.in makedumpfile-1.6.2/debian/kdump-config.in --- makedumpfile-1.6.2/debian/kdump-config.in 1970-01-01 00:00:00.000000000 +0000 +++ makedumpfile-1.6.2/debian/kdump-config.in 2018-01-12 15:47:19.000000000 +0000 @@ -0,0 +1,959 @@ +#!/bin/bash + +# kdump-config +# Copyright (C) 2007-2009 Hewlett-Packard Development Company, L.P. +# Written by Terry Loftin +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# kdump-config +# a shell script utility to manage: +# * loading a kdump kernel +# * unloading a kdump kernel +# * saving a vmcore kdump kernel +# * determining the status of kdump +# * propagate ssh key to remote host + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +NAME=${NAME:="kdump-config"} + +. /lib/lsb/init-functions +. /lib/init/vars.sh + +# Global Setup +KDUMP_DEFAULTS=/etc/default/kdump-tools +[ -r $KDUMP_DEFAULTS ] && . $KDUMP_DEFAULTS + +KEXEC=/sbin/kexec +[ -e $KEXEC ] || exit 1; + +KVER=`uname -r` +ARCH=`uname -m` + +# Set up defaults +KDUMP_SYSCTL=${KDUMP_SYSCTL:="kernel.panic_on_oops=1"} +KDUMP_COREDIR=${KDUMP_COREDIR:=/var/crash} +KDUMP_DUMP_DMESG=${KDUMP_DUMP_DMESG:=1} +KDUMP_DIR="/var/lib/kdump" +KDUMP_NUM_DUMPS=${KDUMP_NUM_DUMPS:=0} +NFS_TIMEO=${NFS_TIMEO:=600} +NFS_RETRANS=${NFS_RETRANS:=3} +MAKEDUMP_ARGS=${MAKEDUMP_ARGS:="-c -d 31"} +KDUMP_CMDLINE_APPEND=${KDUMP_CMDLINE_APPEND:="@KDUMP_CMDLINE_APPEND@"} +KDUMP_KERNEL_HOOK="/etc/kernel/postinst.d/kdump-tools" +[ -d $KDUMP_COREDIR ] || mkdir -p $KDUMP_COREDIR ; + +IOMEM_ADDR=`grep -i "Crash kernel" /proc/iomem | sed "s/-..*//" | sed "s/^[ 0]*/0x/"` + +# Constants +vmcore_file=/proc/vmcore +sys_kexec_crash=/sys/kernel/kexec_crash_loaded +sys_fadump_enabled=/sys/kernel/fadump_enabled +sys_fadump_registered=/sys/kernel/fadump_registered +kexec_cmd_file=$KDUMP_COREDIR/kexec_cmd + +# DUMP_MODE = kdump/fadump +# The default dump mode is kdump. +DUMP_MODE="kdump" + +# If /sys/kernel/fadump_enabled is set to `1`, use fadump as dump mechanism +if [ -e $sys_fadump_enabled ] && [ `cat $sys_fadump_enabled` -eq 1 ]; then + DUMP_MODE="fadump" +fi + +# Utility Functions +# +function kdump_help() +{ +cat </dev/null) + sm_path=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) + + if [ -f "$sb_path" ] && [ -f "$sm_path" ]; then + sb=$(hexdump -v -e '/1 "%d\ "' $sb_path|cut -d' ' -f 5) + sm=$(hexdump -v -e '/1 "%d\ "' $sm_path|cut -d' ' -f 5) + + if [ "$sb" = "1" ] && [ "$sm" = "0" ]; then + return 0 + fi + fi + + return 1 +} + +# Find the kexec/kdump kernel and possibly a corresponding initrd. +# A kdump kernel does not need to match the `uname -r` of the booted kernel. +# +# Use the following priorites in determining the kdump kernel: +# 1. An explicit Kdump kernel in the defaults file overrides all +# 2. Use the current running kernel if it is relocatable. +# 3. Give up. Note, a kdump kernel is required. +# +# Returns: 0/1 (success/fail) +# Returns: none. prints warnings or exit +# Sets: KDUMP_KERNEL, KDUMP_INITRD +function locate_kdump_kernel() +{ + # 1: User may have specified the KDUMP_KERNEL and KDUMP_INITRD + # explicitly. Test for existance and either use it or fail. + if [ -n "$KDUMP_KERNEL" ] ; then + if [ ! -e "$KDUMP_KERNEL" ] ; then + log_failure_msg "$KDUMP_DEFAULTS: KDUMP_KERNEL does not exist: $KDUMP_KERNEL" + [ ! $DRY_RUN ] && exit 1; + elif [ -n "$KDUMP_INITRD" -a ! -e "$KDUMP_INITRD" ] ; then + log_failure_msg "$KDUMP_DEFAULTS: KDUMP_INITRD does not exist: $KDUMP_INITRD" + [ ! $DRY_RUN ] && exit 1; + fi + return 0; + fi + + # 2: The currently running kernel may be relocatable. If so, then + # use the currently running kernel as the crash kernel. + if check_relocatable /boot/config-$KVER; then + if [ -f /boot/vmlinuz-$KVER ]; then + KDUMP_KERNEL=/boot/vmlinuz-$KVER + elif [ -f /boot/vmlinux-$KVER ]; then + KDUMP_KERNEL=/boot/vmlinux-$KVER + else + KDUMP_KERNEL= + fi + if [ -f /boot/initrd.img-$KVER ]; then + KDUMP_INITRD=/boot/initrd.img-$KVER + else + KDUMP_INITRD= + fi + KDUMP_ADDR="relocatable" + return 0; + fi + + # If the kdump kernel is not relocatable, we need to make sure it was + # built to start at the crashkernel= address. IOMEM_ADDR is already + # set... + if [ -z "$KDUMP_CONFIG" ] ; then return 0 ; fi + + if check_relocatable $KDUMP_CONFIG; then + KDUMP_ADDR="relocatable" + else + KDUMP_ADDR=`grep CONFIG_PHYSICAL_START $KDUMP_CONFIG | sed "s/CONFIG_PHYSICAL_START=//"` + # compare the two + if [ "$KDUMP_ADDR" != "$IOMEM_ADDR" ] ; then + log_failure_msg "kdump kernel relocation address does not match crashkernel parameter" + [ ! $DRY_RUN ] && exit 1; + return 1; + fi + fi + + return 0; +} + +# Register firmware-assisted dump as the dump mechanism +# Returns: none. prints warnings or exit +function fadump_register() +{ + # set fadump registered sys node to `1` to register fadump + if [ "`cat $sys_fadump_registered`" -ne 1 ]; then + echo 1 > $sys_fadump_registered + fi + rc=`cat $sys_fadump_registered` + if [ $rc -ne 1 ] ; then + log_failure_msg "fadump registering failed" + logger -t $NAME "fadump registering failed" + [ ! $DRY_RUN ] && exit 1; + fi + + log_success_msg "fadump registered successfully" + logger -t $NAME "fadump registered successfully" + + # Last step: make sure panic_on_oops is enabled + PANIC_ON_OOPS=`/sbin/sysctl kernel.panic_on_oops | cut -d" " -f3` + if [ $PANIC_ON_OOPS != "1" ] ; then + sysctl -w kernel.panic_on_oops=1 >/dev/null + fi +} + +# Returns: none. prints warnings or exit +function fadump_unregister() +{ + # set fadump registered sys node to `0` to un-register fadump + if [ "`cat $sys_fadump_registered`" -ne 0 ]; then + echo 0 > $sys_fadump_registered + fi + rc=`cat $sys_fadump_registered` + if [ $rc -ne 0 ] ; then + log_failure_msg "fadump un-registering failed" + logger -t $NAME "fadump un-registering failed" + [ ! $DRY_RUN ] && exit 1; + fi + + log_success_msg "fadump un-registered successfully" + logger -t $NAME "fadump un-registered successfully" +} + +function kdump_create_symlinks() +{ +kernel_version=$1 + + if [ -e $sys_kexec_crash -a `cat $sys_kexec_crash` -eq 1 ] ; then + log_failure_msg "Cannot change symbolic links when kdump is loaded" + exit 1 + fi + + if [ -e /boot/vmlinu[xz]-${kernel_version} ];then + create_symlink vmlinuz $kernel_version + + if [ -f $KDUMP_DIR/initrd.img-${kernel_version} ]; then + create_symlink initrd.img ${kernel_version} + else + if [ -x $KDUMP_KERNEL_HOOK ];then + $KDUMP_KERNEL_HOOK $kernel_version + create_symlink initrd.img $kernel_version + else + log_failure_msg "Unable to locate kernel hook" + fi + fi + else + log_failure_msg "Invalid kernel version : $kernel_version" + fi +} +# +# Load the already determined kdump kernel and kdump initrd using kexec +# 1: A KDUMP_CMDLINE in the defaults file overrides all. +# 2: Use /proc/cmdline +# a. strip out the crashkernel= parameter. +# b. strip out the abm= parameter. +# c. append KDUMP_CMDLINE_APPEND from defaults file +# Sets: KEXEC_CMD +# Returns: none. prints warnings or exit +function kdump_load() +{ + # assemble the kexec command used to load the kdump kernel + KEXEC_CMD="$KEXEC -p" + + if check_secure_boot || check_securelevel; then + KEXEC_CMD="$KEXEC_CMD -s" + fi + + # Different kernel types allow/require different options: + # The only special case here is that x86, x86_64 elf style + # binaries require the --args-linux argument. + if [ "$ARCH" != "ia64" ] ; then + ELF_TST=`file $KDUMP_KERNEL | grep ELF` + if [ -n "$ELF_TST" ] ; then + KEXEC_CMD="$KEXEC_CMD --args-linux" + fi + fi + + # KDUMP_KEXEC_ARGS, if non-empty, comes from the defaults file. + if [ -n "$KDUMP_KEXEC_ARGS" ] ; then + KEXEC_CMD="$KEXEC_CMD $KDUMP_KEXEC_ARGS" + fi + + # Assemble the --commmand-line: + if [ -z "$KDUMP_CMDLINE" ] ; then + KDUMP_CMDLINE=`cat /proc/cmdline | \ + sed -r -e 's/(^| )crashkernel=[^ ]*//g' \ + -e 's/(^| )hugepages=[^ ]*//g' \ + -e 's/(^| )hugepagesz=[^ ]*//g' \ + -e 's/(^| )abm=[^ ]*//g' \ + -e 's/"/\\\\"/'g` + fi + KDUMP_CMDLINE="$KDUMP_CMDLINE $KDUMP_CMDLINE_APPEND" + KEXEC_CMD="$KEXEC_CMD --command-line=\"$KDUMP_CMDLINE\"" + + # Assemble the --initrd: + if [ -e "$KDUMP_INITRD" ] ; then + KEXEC_CMD="$KEXEC_CMD --initrd=$KDUMP_INITRD" + fi + + # Finally, add the kernel: + KEXEC_CMD="$KEXEC_CMD $KDUMP_KERNEL" + + if [ $DRY_RUN ] ; then return 0; fi + + eval $KEXEC_CMD + + if [ $? == 0 ]; then + log_success_msg "loaded kdump kernel" + logger -t $NAME "$KEXEC_CMD" + logger -t $NAME "loaded kdump kernel" + echo "$KEXEC_CMD" >$kexec_cmd_file + else + log_failure_msg "failed to load kdump kernel" + logger -t $NAME "failed to load kdump kernel" + [ ! $DRY_RUN ] && exit 1; + fi + + # Last step: make sure panic_on_oops is enabled + PANIC_ON_OOPS=`/sbin/sysctl kernel.panic_on_oops | cut -d" " -f3` + if [ $PANIC_ON_OOPS != "1" ] ; then + sysctl -w kernel.panic_on_oops=1 >/dev/null + fi + +} + +# Returns: none. prints warnings or exit +function kdump_unload() +{ + if check_secure_boot || check_securelevel; then + $KEXEC -s -p -u + else + $KEXEC -p -u + fi + + if [ $? == 0 ]; then + log_success_msg "unloaded kdump kernel" + logger -t $NAME "unloaded kdump kernel" + else + log_failure_msg "failed to unload kdump kernel" + logger -t $NAME "failed to unload kdump kernel" + [ ! $DRY_RUN ] && exit 1; + fi +} + +# +# Return the name of the subdirectory to store core file. +# Will add hostname/IP according to the value of +# HOSTTAG if networked dump is selected + +function define_stampdir() +{ + STAMP=$1 + HOSTTAG="${HOSTTAG:=ip}" + + if [ -z "$SSH" ] && [ -z "$NFS" ]; then + echo "$KDUMP_COREDIR/$STAMP" + elif [ "$HOSTTAG" = "hostname" ];then + echo "$KDUMP_COREDIR/$(hostname)-$STAMP" + else + # Looping to give time to network to settle + typeset -i counter=0 + while (( counter < 5));do + THIS_HOST="$(hostname -I)" + set -- $THIS_HOST + THIS_HOST=$1 + if [ -z "$THIS_HOST" ]; then + sleep 1 + ((counter+=1)) + else + break + fi + done + if [ -z "$THIS_HOST" ]; then + # Send log msg to stderr to avoid polluting + # the result of the function + log_failure_msg "Unable to get IP from network" >&2 + log_action_msg "Reverting to HOSTTAG=hostname" >&2 + THIS_HOST="$(hostname)" + fi + echo "$KDUMP_COREDIR/$THIS_HOST-$STAMP" + fi +} + + +# Saving the vmcore: +# Our priorities are: +# 1. If the makedumpfile config link is valid, use that +# 2. else if the vmlinux link is valid, use that +# 3. else fallback to using: makedumpfile -d 1 -c +# 4. else use cp +# +# Returns: 0/1 (success/fail) +# Sets: KDUMP_STAMPDIR, KDUMP_COREFILE +function 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_DMESGFILE="$KDUMP_STAMPDIR/dmesg.$KDUMP_STAMP" + + # If we use NFS, verify that we can mount the FS + # + if [ -n "$NFS" ];then + log_action_msg "Mounting NFS mountpoint $NFS ..." + mount -t nfs -o nolock -o tcp -o soft -o timeo=${NFS_TIMEO} -o retrans=${NFS_RETRANS} $NFS $KDUMP_COREDIR + ERROR=$? + if [ $ERROR -ne 0 ];then + log_failure_msg "$NAME: Unable to mount remote NFS directory $NFS. Cannot save core" + logger -t $NAME "Unable to mount remote NFS directory $NFS. Cannot save core" + return 1; + fi + + # FS is mounted, see if we can write to it + # + mkdir -p $KDUMP_STAMPDIR + ERROR=$? + + if [ $ERROR -ne 0 ];then + log_failure_msg "$NAME: Unable to write to the remote NFS directory $NFS. Cannot save core" + logger -t $NAME "Unable to write to the remote NFS directory $NFS. Cannot save core" + umount $KDUMP_COREDIR + UMNT_ERROR=$? + if [ $UMNT_ERROR -ne 0 ];then + log_failure_msg "$NAME: Unable to cleanly unmount the NFS file system" + logger -t $NAME "Unable to cleanly unmount the NFS file system" + fi + else + log_action_msg "Dumping to NFS mountpoint $NFS/$KDUMP_STAMP" + logger -t $NAME "Dumping to NFS mountpoint $NFS/$KDUMP_STAMP" + fi + else + mkdir -p $KDUMP_STAMPDIR + fi + + log_action_msg "running makedumpfile $MAKEDUMP_ARGS $vmcore_file $KDUMP_CORETEMP" + makedumpfile $MAKEDUMP_ARGS $vmcore_file $KDUMP_CORETEMP + ERROR=$? + if [ $ERROR -ne 0 ] ; then + log_failure_msg "$NAME: makedumpfile failed, falling back to 'cp'" + logger -t $NAME "makedumpfile failed, falling back to 'cp'" + KDUMP_CORETEMP="$KDUMP_STAMPDIR/vmcore-incomplete" + KDUMP_COREFILE="$KDUMP_STAMPDIR/vmcore.$KDUMP_STAMP" + cp $vmcore_file $KDUMP_CORETEMP + ERROR=$? + fi + + # did we succeed? + if [ $ERROR == 0 ]; then + mv $KDUMP_CORETEMP $KDUMP_COREFILE + log_success_msg "$NAME: saved vmcore in $KDUMP_STAMPDIR" + logger -t $NAME "saved vmcore in $KDUMP_STAMPDIR" + sync + else + log_failure_msg "$NAME: failed to save vmcore in $KDUMP_STAMPDIR" + logger -t $NAME "failed to save vmcore in $KDUMP_STAMPDIR" + fi + + # dump the dmesg buffer + if [ "$KDUMP_DUMP_DMESG" -eq 1 ] ; then + log_action_msg "running makedumpfile --dump-dmesg $vmcore_file $KDUMP_DMESGFILE" + makedumpfile --dump-dmesg $vmcore_file $KDUMP_DMESGFILE + ERROR=$? + if [ $ERROR -ne 0 ] ; then + log_failure_msg "$NAME: makedumpfile --dump-dmesg failed. dmesg content will be unavailable" + logger -t $NAME "makedumpfile --dump-dmesg failed. dmesg content will be unavailable" + fi + + # did we succeed? + if [ $ERROR == 0 ]; then + log_success_msg "$NAME: saved dmesg content in $KDUMP_STAMPDIR" + logger -t $NAME "saved dmesg content in $KDUMP_STAMPDIR" + sync + else + log_failure_msg "$NAME: failed to save dmesg content in $KDUMP_STAMPDIR" + logger -t $NAME "failed to save dmesg content in $KDUMP_STAMPDIR" + fi + fi + + # limit the number of dumps kept on the local machine + if [ -z "${NFS}" -a $ERROR == 0 -a $KDUMP_NUM_DUMPS -gt 0 ] ; then + num_dumps=$(ls -1dv $KDUMP_COREDIR/2* | wc -l) + if [ $num_dumps -gt $KDUMP_NUM_DUMPS ] ; then + purge_num=$((num_dumps - KDUMP_NUM_DUMPS)) + purge_dir=$(ls -1dv $KDUMP_COREDIR/2* | head -$purge_num | tr "\n" " ") + log_action_msg "Too many dumps, purging: $purge_dir" + logger -t $NAME "Too many dumps, purging: $purge_dir" + rm -rf $purge_dir + fi + fi + + # If we use NFS, umount the remote FS + # + if [ -n "$NFS" ];then + umount $KDUMP_COREDIR + UMNT_ERROR=$? + if [ $UMNT_ERROR -ne 0 ] ; then + log_failure_msg "$NAME: Unable to cleanly unmount the NFS file system" + logger -t $NAME "Unable to cleanly unmount the NFS file system" + fi + fi + + return $ERROR +} + +function kdump_save_core_to_ssh() +{ + KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}" + KDUMP_REMOTE_HOST="$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_TMPDMESG="/tmp/dmesg.$KDUMP_STAMP" + KDUMP_DMESGFILE="$KDUMP_STAMPDIR/dmesg.$KDUMP_STAMP" + ERROR=0 + + ssh -i $KDUMP_SSH_KEY $KDUMP_REMOTE_HOST mkdir -p $KDUMP_STAMPDIR + ERROR=$? + # If remote connections fails, no need to continue + if [ $ERROR -ne 0 ] ; then + log_failure_msg "$NAME: Unable to reach remote server $KDUMP_REMOTE_HOST. No reason to continue" + logger -t $NAME "Unable to reach remote server $KDUMP_REMOTE_HOST. No reason to continue" + return 1 + fi + + # 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 + ERROR=$? + if [ $ERROR -ne 0 ] ; then + log_failure_msg "$NAME: makedumpfile failed, falling back to 'scp'" + logger -t $NAME "makedumpfile failed, falling back to 'scp'" + KDUMP_CORETEMP="$KDUMP_STAMPDIR/vmcore-incomplete" + KDUMP_COREFILE="$KDUMP_STAMPDIR/vmcore.$KDUMP_STAMP" + scp -i $KDUMP_SSH_KEY $vmcore_file $KDUMP_REMOTE_HOST:$KDUMP_CORETEMP + if [ $? -ne 0 ];then + log_failure_msg "$NAME: makedumpfile scp failed. The vmcore file will not be available" + logger -t $NAME "makedumpfile scp failed. The vmcore file will not be available" + else + ERROR=0 + fi + else + ERROR=0 + fi + + # did we succeed? + if [ $ERROR -ne 0 ]; then + log_failure_msg "$NAME: failed to save vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" + logger -t $NAME "failed to save vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" + sync + else + ssh -i $KDUMP_SSH_KEY $KDUMP_REMOTE_HOST mv $KDUMP_CORETEMP $KDUMP_COREFILE + log_success_msg "$NAME: saved vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" + logger -t $NAME "saved vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" + fi + + # dump the dmesg buffer + if [ "$KDUMP_DUMP_DMESG" -eq 1 ] ; then + log_action_msg "running makedumpfile --dump-dmesg $vmcore_file $KDUMP_TMPDMESG" + makedumpfile --dump-dmesg $vmcore_file $KDUMP_TMPDMESG + ERROR=$? + if [ $ERROR -ne 0 ] ; then + log_failure_msg "$NAME: makedumpfile --dump-dmesg failed. dmesg content will be unavailable" + logger -t $NAME "makedumpfile --dump-dmesg failed. dmesg content will be unavailable" + else + scp -i $KDUMP_SSH_KEY $KDUMP_TMPDMESG $KDUMP_REMOTE_HOST:$KDUMP_DMESGFILE + ERROR=$? + fi + + # did we succeed? + if [ $ERROR == 0 ]; then + log_success_msg "$NAME: saved dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" + logger -t $NAME "saved dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" + return 0; + else + log_failure_msg "$NAME: failed to save dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" + logger -t $NAME "failed to save dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR" + return 1; + fi + fi +} + +function kdump_propagate() +{ + KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}" + KDUMP_REMOTE_HOST="$SSH" + + # ssh key propagation is only needed + # if remote ssh dump is configured + if [ -z "$KDUMP_REMOTE_HOST" ];then + log_failure_msg "$NAME: Remote ssh dump is not configured. No reason to propagate" + logger -t $NAME "Remote ssh dump is not configured. No reason to propagate" + return 1; + fi + + # Verify if the provided key exists and create it if needed + if [ -f "$KDUMP_SSH_KEY" ];then + echo "Using existing key $KDUMP_SSH_KEY" + else + echo "Need to generate a new ssh key..." + /usr/bin/ssh-keygen -t rsa -f $KDUMP_SSH_KEY -N "" 2>&1 > /dev/null + fi + + KDUMP_SSH_USER=${KDUMP_REMOTE_HOST%@*} + KDUMP_SSH_TARGET=${KDUMP_REMOTE_HOST#*@} + + ssh-copy-id -i $KDUMP_SSH_KEY $KDUMP_SSH_USER@$KDUMP_SSH_TARGET &>/dev/null + ERROR=$? + + if [ $ERROR -ne 0 ];then + log_failure_msg "$NAME: $KDUMP_SSH_KEY failed to be sent to $KDUMP_REMOTE_HOST" + logger -t $NAME "$KDUMP_SSH_KEY failed to be sent to $KDUMP_REMOTE_HOST" + return 1; + else + logger -t $NAME "propagated ssh key $KDUMP_SSH_KEY to server $KDUMP_REMOTE_HOST" + echo "propagated ssh key $KDUMP_SSH_KEY to server $KDUMP_REMOTE_HOST" + return 0; + fi + +} + + + +case "$1" in + test) + DRY_RUN="true" + if [ "$DUMP_MODE" == "fadump" ]; then + check_fadump_support + else + check_kdump_support; + manage_symlinks; + locate_kdump_kernel; + kdump_load; + kdump_test + fi + ;; + show) + DRY_RUN="true" + if [ "$DUMP_MODE" == "fadump" ]; then + check_fadump_support; + else + check_kdump_support; + fi + kdump_show + ;; + load) + if [ "$DUMP_MODE" == "fadump" ]; then + check_fadump_support; + fadump_register + else + check_kdump_support; + manage_symlinks; + locate_kdump_kernel; + kdump_load + fi + ;; + unload) + if [ "$DUMP_MODE" == "fadump" ]; then + fadump_unregister + else + kdump_unload + fi + ;; + status) + if [ "$DUMP_MODE" == "fadump" ]; then + check_fadump_support + if [ `cat $sys_fadump_registered` -eq 1 ] ; then + echo "current state : ready to fadump"; + else + echo "current state : Not ready to fadump"; + fi + else + DRY_RUN=true + check_kdump_support; + manage_symlinks; + if [ `cat $sys_kexec_crash` -eq 1 ] ; then + echo "current state : ready to kdump"; + else + echo "current state : Not ready to kdump"; + fi + fi + exit 0; + ;; + savecore) + if ! [ -z $SSH ];then + kdump_save_core_to_ssh + else + kdump_save_core + fi + exit $? + ;; + propagate) + kdump_propagate; + ;; + symlinks) + if [ -z $2 ];then + log_failure_msg "Invalid argument : missing kernel version" + else + kdump_create_symlinks $2 + fi + ;; + help|-h*|--h*) + kdump_help + ;; + *) + echo "Usage: $0 {help|test|show|status|load|unload|savecore|propagate|symlinks kernel-version}" + exit 1 + ;; +esac + +exit 0 diff -Nru makedumpfile-1.6.2/debian/kdump-tools.5 makedumpfile-1.6.2/debian/kdump-tools.5 --- makedumpfile-1.6.2/debian/kdump-tools.5 2017-12-13 15:37:59.000000000 +0000 +++ makedumpfile-1.6.2/debian/kdump-tools.5 1970-01-01 00:00:00.000000000 +0000 @@ -1,360 +0,0 @@ -.\" -.TH "kdump-tools.conf" "5" "February 2015" "kdump-tools v1.1.4" "Linux System Administrator's Manual" -.SH NAME -kdump-tools.conf \- configuration file for the kdump-tools init script -.SH SYNOPSIS -.TP -.B /etc/default/kdump-tools -.SH DESCRIPTION -.PP -.B kdump-tools -manages the kdump feature of the Linux kernel. The -.I /etc/default/kdump-tools -file contains local configuration settings of kdump. -.PP -This file is sourced into a shell script, so it's format should be consistent -with shell scripting. -.\" -.\" # --------------------------------------------------------------------------- -.\" -.SH OPTIONS -.TP -.B USE_KDUMP -Controls whether or not -.B kdump-tools -will take any action. -If not set or 0, the -.B kdump-tools -init script will not run. -.TP -.B KDUMP_SYSCTL -Controls when a panic occurs, using the -.BR sysctl (8) -interface. Each time a kdump kernel is loaded, -.RI \*(lq "sysctl -w $KDUMP_SYSCTL" \*(rq -is also executed, thus allowing the system adiminstrator -to maintain customizable conditions for a kdump. -The contents of this variable should be the -.RI \*(lq "variable=value ..." \*(rq -portion of the -.RI \*(lq "sysctl -w" \*(rq -command. If not set, -.RI \*(lq "kernel.panic_on_oops=1" \*(rq -will be used. This feature can be disabled by setting -.br -.B KDUMP_SYSCTL=\*(lq \*(rq - -See -.BR sysctl (8) -for more info. -.\" -.\" # --------------------------------------------------------------------------- -.\" -.TP -.B KDUMP_KERNEL -A full pathname to a kdump kernel (the kernel that is kexec'd at crash time -in a reserved memory area, exposing the old kernel's memory for dumping). If -not set, -.B kdump-config -will use the boot kernel as the kdump kernel if it is relocatable; otherwise -you must set -.B KDUMP_KERNEL -in order for -.B kdump-tools -to work. -.TP -.B KDUMP_INITRD -A full pathname to the kdump initrd (if used). If -.I KDUMP_KERNEL -is set and -.I KDUMP_INITRD -is not set, a warning message will be printed, and an initrd will not be used. -.\" -.\" # --------------------------------------------------------------------------- -.\" -.TP -.B KDUMP_COREDIR -Full path to a directory where the vmcore will be saved. -Date stamped subdirectories are created each time a vmcore file is processed. -If not set, -.I /var/crash -will be used. -.TP -.B KDUMP_FAIL_CMD -This variable specifies a command to run if the vmcore save fails. -If not set, no special action is taken. -.TP -.B KDUMP_DUMP_DMESG -This variable controls if the dmesg buffer is dumped. -If not set or set to 1, the dmesg buffer is dumped. -If set to 0, the dmesg buffer is not dumped. -.TP -.B KDUMP_NUM_DUMPS -This variable specifies how many dump files should be kept on the local machine. -If not set or set to 0, no special action is taken. If set to >1 and there are -too many dump files on the machine, older dumps are removed. The cleanup action -is only taken after a successful dump. This variable is ignored if remote dumping -is enabled. -.\" -.\" -.\" -.\" -.TP -.B MAKEDUMP_ARGS -Extra arguments passed to -.BR makedumpfile (8). -If not set, -.RI \*(lq "-c -d 31" \*(rq -will be used. This tells makedumpfile to use compression, -and reduce the corefile to in-use kernel pages only. See -.BR makedumpfile (8) -for details. -.\" -.\" # --------------------------------------------------------------------------- -.\" -.TP -.B KDUMP_KEXEC_ARGS -Additional arguments to the kexec command used to load the kdump kernel. -.TP -.B KDUMP_CMDLINE -Normally, the current kernel commandline is obtained from -.IR /proc/cmdline . -Set this variable to override -.IR /proc/cmdline . -.TP -.B KDUMP_CMDLINE_APPEND -Additional arguments to append to the command line for the kdump kernel. -If not set, -.RI \*(lq "irqpoll noirqdistrib nr_cpus=1 nousb" \*(rq -will be used. -.TP -.B SSH -username and hostname of the remote server that will receive the dump -and dmesg files. -.I username@hostname -format must be used. -.TP -.B SSH_KEY -Full path of the ssh private key to be used to login to the remote server. -Use -.RI \*(lq "kdump-config propagate" \*(rq -to send the public key to the remote server. -If not set, the default -.I /root/.ssh/kdump_id_rsa -will be used -.TP -.B HOSTTAG -Select if hostname of IP address will be used as a prefix to the -timestamped directory when sending files to the remote server. -If not set, -.RI \*(lq "ip" \*(rq -will be used. -.TP -.B NFS -Hostname and mount point of the NFS server configured to receive the crash dump. -The syntax must be HOSTNAME:MOUNTPOINT (e.g. -.I remote:/var/crash -) -.\" -.\" # --------------------------------------------------------------------------- -.\" -.SH USAGE -.PP -.B kdump-tools -is as automated as can be at this point but there are some -prerequisites to using it. Additionally, some manual configuration -is still required. -.PP -By default, kernel dumps are stored locally on the system. -.B kdump-tools -can be configured to store the kernel dumps on a remote server accessible -through the network. -.SS Manual Configuration -.IP 1. -.B USE_KDUMP -is set to 0 by default. To enable -.BR kdump-tools , -edit the -.I /etc/default/kdump-tools -configuration file and set -.BR USE_KDUMP=1 . -.\" -.\" -.IP 2. -.B Kernel Command line parameters -\- the kernel must be booted with a -.IR crashkernel = -command line parameter. Some example crashkernel parameters: -.nf - ia64: \fIcrashkernel=384M\fR - x86: \fIcrashkernel=128M\fR - x86_64: \fIcrashkernel=256M\fR -.fi - -Some users may also want to add -.I nmi_watchdog=1 -on certain systems. The nmi watchdog will cause the kernel to panic -(and kdump) if a system hang is detected. - -The kernel command line parameter is generally set in one of these files: -.IR /etc/default/grub , -.IR /boot/grub/menu.lst , -.IR /etc/elilo.conf , -or -.IR /etc/lilo.conf . -If the command line parameter is changed, a reboot is required in -order for it to take effect. -.\" -.\" -.IP 3. -.B Architectural considerations -.RS -.IP A) -.B -x86 && PAE && memory > 4 Gigabytes -\- use -.I -KDUMP_KEXEC_ARGS="--elf64-core-headers" -.IP B) -.B -x86 and x86_64 -\- Some systems can take advantage of the nmi watchdog. Add -.I -nmi_watchdog=1 -to the boot commandline to turn on the watchdog. -The nmi interrupt will call panic if activated. -.IP C) -.B -ia64 -\- Some systems may need -.IR KDUMP_KEXEC_ARGS="--noio" . -Use this if the system hangs after a panic, but before the kdump kernel -begins to boot. -.RE -.\" -.\" -.SS Networked kernel dump Configuration -.IP 1. -Either use -.B SSH -or -.B NFS -to choose which protocol to use to remotely access the target server. -.IP 2 -For -.B SSH -.I username@hostname -needs to be provided along with an appropriate -.B SSH_KEY -definition or use -.RI \*(lq "kdump-config propagate" \*(rq -to propagate a new default ssh key. -.PP -.IP 3 -For -.B NFS -the remote server name must be provided along with the directory where -files are to be copied. -.SS Prerequisites -.IP 1. -.B Boot Kernel Configuration -\- The boot kernel must be configured with -.IR CONFIG_KEXEC=y -and, if it is also to be used as the kdump kernel, -.IR CONFIG_CRASHDUMP=y . - -For ia64, only makedumpfile level 1 will work if the -memory model selected is -.IR CONFIG_DISCONTIG . -.IR CONFIG_SPARSEMEM -is recommended instead. -.\" -.\" -.IP 2. -.B Kdump Kernel Configuration -\- The kdump kernel must be relocated or relocatable. ia64 is relocatable by -default, but x86, x86_64, and powerpc must be built with -.IR CONFIG_RELOCATABLE=y . -Other architectures may require a predermined start location via -.IR CONFIG_PHYSICAL_START . -If the boot kernel is relocatable, -.B kdump-tools -will automatically use that kernel. -Otherwise, a relocatable or relocated kernel will need to be provided. -The kdump kernel can be specified in the -.I /etc/default/kdump-tools -file. -Set the -.B KDUMP_KERNEL -variable and if necessary the -.B KDUMP_INITRD -variable to point to the provided kernel and its initrd. - -The kdump kernel must be configured with: -.B CONFIG_CRASH_DUMP=y -.\" -.\" # --------------------------------------------------------------------------- -.\" -.SH EXAMPLES -.PP -Also panic and kdump on oom: -.RS -KDUMP_SYSCTL="kernel.panic_on_oops=1 vm.panic_on_oom=1" -.RE -.PP -Use this option on x86 systems with PAE and more than 4 gig of memory: -.RS -KDUMP_KEXEC_ARGS="--elf64-core-headers" -.RE -.PP -This option starts a shell if -.B kdump-tools -cannot save the vmcore file: -.RS -KDUMP_FAIL_CMD="/bin/bash; reboot -f" -.RE -.\" -.\" # --------------------------------------------------------------------------- -.\" -.SH FILES -.TP 25 -.I /etc/init.d/kdump-tools -an init script to automatically load a kdump kernel, or save a vmcore and reboot. -.TP 25 -.I /etc/default/kdump-tools -the -.B kdump-tools -configuration file -.TP 25 -.I /var/crash/kernel_link -a link to the current debug kernel -.TP 25 -.I /var/crash/kexec_cmd -the last kexec_cmd executed by -.B kdump-config -.\" -.\" # --------------------------------------------------------------------------- -.\" -.SH DIAGNOSTICS -.PP -See -.BR kdump-config (8) -for explanations of various error messages. -.\" -.\" # --------------------------------------------------------------------------- -.\" -.SH SEE ALSO -.PP -.I /usr/share/doc/kdump-tools/README -.br -.I /usr/share/doc/kdump-tools/README.Debian -.br -.BR kdump-config (8), -.BR kexec (8), -.BR sysctl (8), -.BR makedumpfile (8), -.BR crash (8), -.BR gdb (1), -.SH AUTHOR -.PP -Terry Loftin diff -Nru makedumpfile-1.6.2/debian/kdump-tools.5.in makedumpfile-1.6.2/debian/kdump-tools.5.in --- makedumpfile-1.6.2/debian/kdump-tools.5.in 1970-01-01 00:00:00.000000000 +0000 +++ makedumpfile-1.6.2/debian/kdump-tools.5.in 2018-01-12 15:47:19.000000000 +0000 @@ -0,0 +1,360 @@ +.\" +.TH "kdump-tools.conf" "5" "February 2015" "kdump-tools v1.1.4" "Linux System Administrator's Manual" +.SH NAME +kdump-tools.conf \- configuration file for the kdump-tools init script +.SH SYNOPSIS +.TP +.B /etc/default/kdump-tools +.SH DESCRIPTION +.PP +.B kdump-tools +manages the kdump feature of the Linux kernel. The +.I /etc/default/kdump-tools +file contains local configuration settings of kdump. +.PP +This file is sourced into a shell script, so it's format should be consistent +with shell scripting. +.\" +.\" # --------------------------------------------------------------------------- +.\" +.SH OPTIONS +.TP +.B USE_KDUMP +Controls whether or not +.B kdump-tools +will take any action. +If not set or 0, the +.B kdump-tools +init script will not run. +.TP +.B KDUMP_SYSCTL +Controls when a panic occurs, using the +.BR sysctl (8) +interface. Each time a kdump kernel is loaded, +.RI \*(lq "sysctl -w $KDUMP_SYSCTL" \*(rq +is also executed, thus allowing the system adiminstrator +to maintain customizable conditions for a kdump. +The contents of this variable should be the +.RI \*(lq "variable=value ..." \*(rq +portion of the +.RI \*(lq "sysctl -w" \*(rq +command. If not set, +.RI \*(lq "kernel.panic_on_oops=1" \*(rq +will be used. This feature can be disabled by setting +.br +.B KDUMP_SYSCTL=\*(lq \*(rq + +See +.BR sysctl (8) +for more info. +.\" +.\" # --------------------------------------------------------------------------- +.\" +.TP +.B KDUMP_KERNEL +A full pathname to a kdump kernel (the kernel that is kexec'd at crash time +in a reserved memory area, exposing the old kernel's memory for dumping). If +not set, +.B kdump-config +will use the boot kernel as the kdump kernel if it is relocatable; otherwise +you must set +.B KDUMP_KERNEL +in order for +.B kdump-tools +to work. +.TP +.B KDUMP_INITRD +A full pathname to the kdump initrd (if used). If +.I KDUMP_KERNEL +is set and +.I KDUMP_INITRD +is not set, a warning message will be printed, and an initrd will not be used. +.\" +.\" # --------------------------------------------------------------------------- +.\" +.TP +.B KDUMP_COREDIR +Full path to a directory where the vmcore will be saved. +Date stamped subdirectories are created each time a vmcore file is processed. +If not set, +.I /var/crash +will be used. +.TP +.B KDUMP_FAIL_CMD +This variable specifies a command to run if the vmcore save fails. +If not set, no special action is taken. +.TP +.B KDUMP_DUMP_DMESG +This variable controls if the dmesg buffer is dumped. +If not set or set to 1, the dmesg buffer is dumped. +If set to 0, the dmesg buffer is not dumped. +.TP +.B KDUMP_NUM_DUMPS +This variable specifies how many dump files should be kept on the local machine. +If not set or set to 0, no special action is taken. If set to >1 and there are +too many dump files on the machine, older dumps are removed. The cleanup action +is only taken after a successful dump. This variable is ignored if remote dumping +is enabled. +.\" +.\" +.\" +.\" +.TP +.B MAKEDUMP_ARGS +Extra arguments passed to +.BR makedumpfile (8). +If not set, +.RI \*(lq "-c -d 31" \*(rq +will be used. This tells makedumpfile to use compression, +and reduce the corefile to in-use kernel pages only. See +.BR makedumpfile (8) +for details. +.\" +.\" # --------------------------------------------------------------------------- +.\" +.TP +.B KDUMP_KEXEC_ARGS +Additional arguments to the kexec command used to load the kdump kernel. +.TP +.B KDUMP_CMDLINE +Normally, the current kernel commandline is obtained from +.IR /proc/cmdline . +Set this variable to override +.IR /proc/cmdline . +.TP +.B KDUMP_CMDLINE_APPEND +Additional arguments to append to the command line for the kdump kernel. +If not set, +.RI \*(lq "@KDUMP_CMDLINE_APPEND@" \*(rq +will be used. +.TP +.B SSH +username and hostname of the remote server that will receive the dump +and dmesg files. +.I username@hostname +format must be used. +.TP +.B SSH_KEY +Full path of the ssh private key to be used to login to the remote server. +Use +.RI \*(lq "kdump-config propagate" \*(rq +to send the public key to the remote server. +If not set, the default +.I /root/.ssh/kdump_id_rsa +will be used +.TP +.B HOSTTAG +Select if hostname of IP address will be used as a prefix to the +timestamped directory when sending files to the remote server. +If not set, +.RI \*(lq "ip" \*(rq +will be used. +.TP +.B NFS +Hostname and mount point of the NFS server configured to receive the crash dump. +The syntax must be HOSTNAME:MOUNTPOINT (e.g. +.I remote:/var/crash +) +.\" +.\" # --------------------------------------------------------------------------- +.\" +.SH USAGE +.PP +.B kdump-tools +is as automated as can be at this point but there are some +prerequisites to using it. Additionally, some manual configuration +is still required. +.PP +By default, kernel dumps are stored locally on the system. +.B kdump-tools +can be configured to store the kernel dumps on a remote server accessible +through the network. +.SS Manual Configuration +.IP 1. +.B USE_KDUMP +is set to 0 by default. To enable +.BR kdump-tools , +edit the +.I /etc/default/kdump-tools +configuration file and set +.BR USE_KDUMP=1 . +.\" +.\" +.IP 2. +.B Kernel Command line parameters +\- the kernel must be booted with a +.IR crashkernel = +command line parameter. Some example crashkernel parameters: +.nf + ia64: \fIcrashkernel=384M\fR + x86: \fIcrashkernel=128M\fR + x86_64: \fIcrashkernel=256M\fR +.fi + +Some users may also want to add +.I nmi_watchdog=1 +on certain systems. The nmi watchdog will cause the kernel to panic +(and kdump) if a system hang is detected. + +The kernel command line parameter is generally set in one of these files: +.IR /etc/default/grub , +.IR /boot/grub/menu.lst , +.IR /etc/elilo.conf , +or +.IR /etc/lilo.conf . +If the command line parameter is changed, a reboot is required in +order for it to take effect. +.\" +.\" +.IP 3. +.B Architectural considerations +.RS +.IP A) +.B +x86 && PAE && memory > 4 Gigabytes +\- use +.I +KDUMP_KEXEC_ARGS="--elf64-core-headers" +.IP B) +.B +x86 and x86_64 +\- Some systems can take advantage of the nmi watchdog. Add +.I +nmi_watchdog=1 +to the boot commandline to turn on the watchdog. +The nmi interrupt will call panic if activated. +.IP C) +.B +ia64 +\- Some systems may need +.IR KDUMP_KEXEC_ARGS="--noio" . +Use this if the system hangs after a panic, but before the kdump kernel +begins to boot. +.RE +.\" +.\" +.SS Networked kernel dump Configuration +.IP 1. +Either use +.B SSH +or +.B NFS +to choose which protocol to use to remotely access the target server. +.IP 2 +For +.B SSH +.I username@hostname +needs to be provided along with an appropriate +.B SSH_KEY +definition or use +.RI \*(lq "kdump-config propagate" \*(rq +to propagate a new default ssh key. +.PP +.IP 3 +For +.B NFS +the remote server name must be provided along with the directory where +files are to be copied. +.SS Prerequisites +.IP 1. +.B Boot Kernel Configuration +\- The boot kernel must be configured with +.IR CONFIG_KEXEC=y +and, if it is also to be used as the kdump kernel, +.IR CONFIG_CRASHDUMP=y . + +For ia64, only makedumpfile level 1 will work if the +memory model selected is +.IR CONFIG_DISCONTIG . +.IR CONFIG_SPARSEMEM +is recommended instead. +.\" +.\" +.IP 2. +.B Kdump Kernel Configuration +\- The kdump kernel must be relocated or relocatable. ia64 is relocatable by +default, but x86, x86_64, and powerpc must be built with +.IR CONFIG_RELOCATABLE=y . +Other architectures may require a predermined start location via +.IR CONFIG_PHYSICAL_START . +If the boot kernel is relocatable, +.B kdump-tools +will automatically use that kernel. +Otherwise, a relocatable or relocated kernel will need to be provided. +The kdump kernel can be specified in the +.I /etc/default/kdump-tools +file. +Set the +.B KDUMP_KERNEL +variable and if necessary the +.B KDUMP_INITRD +variable to point to the provided kernel and its initrd. + +The kdump kernel must be configured with: +.B CONFIG_CRASH_DUMP=y +.\" +.\" # --------------------------------------------------------------------------- +.\" +.SH EXAMPLES +.PP +Also panic and kdump on oom: +.RS +KDUMP_SYSCTL="kernel.panic_on_oops=1 vm.panic_on_oom=1" +.RE +.PP +Use this option on x86 systems with PAE and more than 4 gig of memory: +.RS +KDUMP_KEXEC_ARGS="--elf64-core-headers" +.RE +.PP +This option starts a shell if +.B kdump-tools +cannot save the vmcore file: +.RS +KDUMP_FAIL_CMD="/bin/bash; reboot -f" +.RE +.\" +.\" # --------------------------------------------------------------------------- +.\" +.SH FILES +.TP 25 +.I /etc/init.d/kdump-tools +an init script to automatically load a kdump kernel, or save a vmcore and reboot. +.TP 25 +.I /etc/default/kdump-tools +the +.B kdump-tools +configuration file +.TP 25 +.I /var/crash/kernel_link +a link to the current debug kernel +.TP 25 +.I /var/crash/kexec_cmd +the last kexec_cmd executed by +.B kdump-config +.\" +.\" # --------------------------------------------------------------------------- +.\" +.SH DIAGNOSTICS +.PP +See +.BR kdump-config (8) +for explanations of various error messages. +.\" +.\" # --------------------------------------------------------------------------- +.\" +.SH SEE ALSO +.PP +.I /usr/share/doc/kdump-tools/README +.br +.I /usr/share/doc/kdump-tools/README.Debian +.br +.BR kdump-config (8), +.BR kexec (8), +.BR sysctl (8), +.BR makedumpfile (8), +.BR crash (8), +.BR gdb (1), +.SH AUTHOR +.PP +Terry Loftin diff -Nru makedumpfile-1.6.2/debian/kdump-tools.conf makedumpfile-1.6.2/debian/kdump-tools.conf --- makedumpfile-1.6.2/debian/kdump-tools.conf 2017-12-13 15:37:59.000000000 +0000 +++ makedumpfile-1.6.2/debian/kdump-tools.conf 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -# kdump-tools configuration -# --------------------------------------------------------------------------- -# USE_KDUMP - controls kdump will be configured -# 0 - kdump kernel will not be loaded -# 1 - kdump kernel will be loaded and kdump is configured -# KDUMP_SYSCTL - controls when a panic occurs, using the sysctl -# interface. The contents of this variable should be the -# "variable=value ..." portion of the 'sysctl -w ' command. -# If not set, the default value "kernel.panic_on_oops=1" will -# be used. Disable this feature by setting KDUMP_SYSCTL=" " -# Example - also panic on oom: -# KDUMP_SYSCTL="kernel.panic_on_oops=1 vm.panic_on_oom=1" -# -USE_KDUMP=1 -#KDUMP_SYSCTL="kernel.panic_on_oops=1" - - -# --------------------------------------------------------------------------- -# Kdump Kernel: -# KDUMP_KERNEL - A full pathname to a kdump kernel. -# KDUMP_INITRD - A full pathname to the kdump initrd (if used). -# If these are not set, kdump-config will try to use the current kernel -# and initrd if it is relocatable. Otherwise, you will need to specify -# these manually. -KDUMP_KERNEL=/var/lib/kdump/vmlinuz -KDUMP_INITRD=/var/lib/kdump/initrd.img - - -# --------------------------------------------------------------------------- -# vmcore Handling: -# KDUMP_COREDIR - local path to save the vmcore to. -# KDUMP_FAIL_CMD - This variable can be used to cause a reboot or -# start a shell if saving the vmcore fails. If not set, "reboot -f" -# is the default. -# Example - start a shell if the vmcore copy fails: -# KDUMP_FAIL_CMD="echo 'makedumpfile FAILED.'; /bin/bash; reboot -f" -# KDUMP_DUMP_DMESG - This variable controls if the dmesg buffer is dumped. -# If unset or set to 1, the dmesg buffer is dumped. If set to 0, the dmesg -# buffer is not dumped. -KDUMP_COREDIR="/var/crash" -#KDUMP_FAIL_CMD="reboot -f" -#KDUMP_DUMP_DMESG= -# 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_COREDIR="/var/crash" -#KDUMP_FAIL_CMD="reboot -f" -#KDUMP_DUMP_DMESG= -#KDUMP_NUM_DUMPS= - - -# --------------------------------------------------------------------------- -# Makedumpfile options: -# MAKEDUMP_ARGS - extra arguments passed to makedumpfile (8). The default, -# if unset, is to pass '-c -d 31' telling makedumpfile to use compression -# and reduce the corefile to in-use kernel pages only. -#MAKEDUMP_ARGS="-c -d 31" - - -# --------------------------------------------------------------------------- -# Kexec/Kdump args -# KDUMP_KEXEC_ARGS - Additional arguments to the kexec command used to load -# the kdump kernel -# Example - Use this option on x86 systems with PAE and more than -# 4 gig of memory: -# KDUMP_KEXEC_ARGS="--elf64-core-headers" -# KDUMP_CMDLINE - The default is to use the contents of /proc/cmdline. -# Set this variable to override /proc/cmdline. -# KDUMP_CMDLINE_APPEND - Additional arguments to append to the command line -# for the kdump kernel. If unset, it defaults to -# "irqpoll noirqdistrib nr_cpus=1 nousb systemd.unit=kdump-tools.service ata_piix.prefer_ms_hyperv=0" -#KDUMP_KEXEC_ARGS="" -#KDUMP_CMDLINE="" -#KDUMP_CMDLINE_APPEND="irqpoll noirqdistrib nr_cpus=1 nousb systemd.unit=kdump-tools.service ata_piix.prefer_ms_hyperv=0" - -# --------------------------------------------------------------------------- -# Architecture specific Overrides: - -# --------------------------------------------------------------------------- -# Remote dump facilities: -# SSH - username and hostname of the remote server that will receive the dump -# and dmesg files. -# SSH_KEY - Full path of the ssh private key to be used to login to the remote -# server. use kdump-config propagate to send the public key to the -# remote server -# HOSTTAG - Select if hostname of IP address will be used as a prefix to the -# timestamped directory when sending files to the remote server. -# 'ip' is the default. -# NFS - Hostname and mount point of the NFS server configured to receive -# the crash dump. The syntax must be {HOSTNAME}:{MOUNTPOINT} -# (e.g. remote:/var/crash) -# NFS_TIMEO - Timeout before NFS retries a request. See man nfs(5) for details. -# NFS_RETRANS - Number of times NFS client retries a request. See man nfs(5) for details. -# SSH="" -# -# SSH_KEY="" -# -# HOSTTAG="hostname|[ip]" -# -# NFS="" -# -# NFS_TIMEO="600" -# -# NFS_RETRANS="3" diff -Nru makedumpfile-1.6.2/debian/kdump-tools.conf.in makedumpfile-1.6.2/debian/kdump-tools.conf.in --- makedumpfile-1.6.2/debian/kdump-tools.conf.in 1970-01-01 00:00:00.000000000 +0000 +++ makedumpfile-1.6.2/debian/kdump-tools.conf.in 2018-01-12 15:47:19.000000000 +0000 @@ -0,0 +1,104 @@ +# kdump-tools configuration +# --------------------------------------------------------------------------- +# USE_KDUMP - controls kdump will be configured +# 0 - kdump kernel will not be loaded +# 1 - kdump kernel will be loaded and kdump is configured +# KDUMP_SYSCTL - controls when a panic occurs, using the sysctl +# interface. The contents of this variable should be the +# "variable=value ..." portion of the 'sysctl -w ' command. +# If not set, the default value "kernel.panic_on_oops=1" will +# be used. Disable this feature by setting KDUMP_SYSCTL=" " +# Example - also panic on oom: +# KDUMP_SYSCTL="kernel.panic_on_oops=1 vm.panic_on_oom=1" +# +USE_KDUMP=1 +#KDUMP_SYSCTL="kernel.panic_on_oops=1" + + +# --------------------------------------------------------------------------- +# Kdump Kernel: +# KDUMP_KERNEL - A full pathname to a kdump kernel. +# KDUMP_INITRD - A full pathname to the kdump initrd (if used). +# If these are not set, kdump-config will try to use the current kernel +# and initrd if it is relocatable. Otherwise, you will need to specify +# these manually. +KDUMP_KERNEL=/var/lib/kdump/vmlinuz +KDUMP_INITRD=/var/lib/kdump/initrd.img + + +# --------------------------------------------------------------------------- +# vmcore Handling: +# KDUMP_COREDIR - local path to save the vmcore to. +# KDUMP_FAIL_CMD - This variable can be used to cause a reboot or +# start a shell if saving the vmcore fails. If not set, "reboot -f" +# is the default. +# Example - start a shell if the vmcore copy fails: +# KDUMP_FAIL_CMD="echo 'makedumpfile FAILED.'; /bin/bash; reboot -f" +# KDUMP_DUMP_DMESG - This variable controls if the dmesg buffer is dumped. +# If unset or set to 1, the dmesg buffer is dumped. If set to 0, the dmesg +# buffer is not dumped. +KDUMP_COREDIR="/var/crash" +#KDUMP_FAIL_CMD="reboot -f" +#KDUMP_DUMP_DMESG= +# 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_COREDIR="/var/crash" +#KDUMP_FAIL_CMD="reboot -f" +#KDUMP_DUMP_DMESG= +#KDUMP_NUM_DUMPS= + + +# --------------------------------------------------------------------------- +# Makedumpfile options: +# MAKEDUMP_ARGS - extra arguments passed to makedumpfile (8). The default, +# if unset, is to pass '-c -d 31' telling makedumpfile to use compression +# and reduce the corefile to in-use kernel pages only. +#MAKEDUMP_ARGS="-c -d 31" + + +# --------------------------------------------------------------------------- +# Kexec/Kdump args +# KDUMP_KEXEC_ARGS - Additional arguments to the kexec command used to load +# the kdump kernel +# Example - Use this option on x86 systems with PAE and more than +# 4 gig of memory: +# KDUMP_KEXEC_ARGS="--elf64-core-headers" +# KDUMP_CMDLINE - The default is to use the contents of /proc/cmdline. +# Set this variable to override /proc/cmdline. +# KDUMP_CMDLINE_APPEND - Additional arguments to append to the command line +# for the kdump kernel. If unset, it defaults to +# "@KDUMP_CMDLINE_APPEND@" +#KDUMP_KEXEC_ARGS="" +#KDUMP_CMDLINE="" +#KDUMP_CMDLINE_APPEND="@KDUMP_CMDLINE_APPEND@" + +# --------------------------------------------------------------------------- +# Architecture specific Overrides: + +# --------------------------------------------------------------------------- +# Remote dump facilities: +# SSH - username and hostname of the remote server that will receive the dump +# and dmesg files. +# SSH_KEY - Full path of the ssh private key to be used to login to the remote +# server. use kdump-config propagate to send the public key to the +# remote server +# HOSTTAG - Select if hostname of IP address will be used as a prefix to the +# timestamped directory when sending files to the remote server. +# 'ip' is the default. +# NFS - Hostname and mount point of the NFS server configured to receive +# the crash dump. The syntax must be {HOSTNAME}:{MOUNTPOINT} +# (e.g. remote:/var/crash) +# NFS_TIMEO - Timeout before NFS retries a request. See man nfs(5) for details. +# NFS_RETRANS - Number of times NFS client retries a request. See man nfs(5) for details. +# SSH="" +# +# SSH_KEY="" +# +# HOSTTAG="hostname|[ip]" +# +# NFS="" +# +# NFS_TIMEO="600" +# +# NFS_RETRANS="3" diff -Nru makedumpfile-1.6.2/debian/kdump-tools.grub.arm64 makedumpfile-1.6.2/debian/kdump-tools.grub.arm64 --- makedumpfile-1.6.2/debian/kdump-tools.grub.arm64 1970-01-01 00:00:00.000000000 +0000 +++ makedumpfile-1.6.2/debian/kdump-tools.grub.arm64 2018-01-12 15:47:19.000000000 +0000 @@ -0,0 +1 @@ +GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT crashkernel=2G-4G:320M,4G-32G:512M,32G-64G:1024M,64G-128G:2048M,128G-:4096M" diff -Nru makedumpfile-1.6.2/debian/rules makedumpfile-1.6.2/debian/rules --- makedumpfile-1.6.2/debian/rules 2017-11-01 13:50:26.000000000 +0000 +++ makedumpfile-1.6.2/debian/rules 2018-01-12 15:47:19.000000000 +0000 @@ -7,6 +7,15 @@ SUBSTVARS = -Vdist:Depends="kexec-tools" endif +KDUMP_CMDLINE_APPEND = nr_cpus=1 systemd.unit=kdump-tools.service +ifeq ($(DEB_HOST_ARCH),arm64) + # pass +else ifeq ($(DEB_HOST_ARCH),ppc64el) + KDUMP_CMDLINE_APPEND += irqpoll noirqdistrib nousb +else + KDUMP_CMDLINE_APPEND += irqpoll nousb ata_piix.prefer_ms_hyperv=0 +endif + %: dh $@ --with=systemd @@ -16,7 +25,15 @@ override_dh_auto_build: dh_auto_build -- LINKTYPE=dynamic USELZO=on -override_dh_install: +kdump_cmdline_insert = sed "s/@KDUMP_CMDLINE_APPEND@/$(KDUMP_CMDLINE_APPEND)/" < $< > $@ +debian/kdump-config: debian/kdump-config.in + $(kdump_cmdline_insert) +debian/kdump-tools.conf: debian/kdump-tools.conf.in + $(kdump_cmdline_insert) +debian/kdump-tools.5: debian/kdump-tools.5.in + $(kdump_cmdline_insert) + +override_dh_install: debian/kdump-config debian/kdump-tools.conf debian/kdump-tools.5 dh_install install -D -m 755 debian/kernel-postinst-generate-initrd debian/kdump-tools/etc/kernel/postinst.d/kdump-tools install -D -m 755 debian/kernel-postrm-delete-initrd debian/kdump-tools/etc/kernel/postrm.d/kdump-tools @@ -37,4 +54,5 @@ override_dh_auto_clean: rm -f debian/kdump-tools.maintscript + rm -f debian/kdump-config debian/kdump-tools.conf debian/kdump-tools.5 dh_auto_clean