OBS User unknown
2007-01-18 00:34:30 +00:00
committed by Git OBS Bridge
parent 7c048af0a7
commit 6c93df0407
5 changed files with 104 additions and 7 deletions

66
kdump
View File

@@ -27,6 +27,7 @@
. /etc/rc.status
KEXEC=/sbin/kexec
KDUMP_HELPER=/usr/sbin/kdump-helper
BOOTDIR="/boot"
@@ -184,6 +185,11 @@ load_kdump()
esac
fi
# add the dump device
if [ -n "$KDUMP_DUMPDEV" ] ; then
KDUMP_COMMANDLINE="dumpdev=$KDUMP_DUMPDEV $KDUMP_COMMANDLINE"
fi
echo 1 > /proc/sys/kernel/panic_on_oops
$KEXEC -p $kdump_kernel \
@@ -208,20 +214,70 @@ is_crash_kernel ()
return 0
}
# return success if we have a valid dump on the dump device
have_valid_dump_in_dumpdev ()
{
if [ ! -b "$KDUMP_DUMPDEV" ] ; then
return 1
fi
# return the return code from this command
$KDUMP_HELPER -c "$KDUMP_DUMPDEV" >> /dev/null
}
# invalidate the dump device so that it's not read on next boot
invalidate_dumpdev ()
{
dd if=/dev/zero of=$KDUMP_DUMPDEV bs=512 count=1
}
# copy the dump from the dumpdevice to the harddisk
copy_dump_from_dumpdev ()
{
if [ $KDUMP_KEEP_OLD_DUMPS -gt 0 ]; then
purge_old_dumps
fi
dumpsize=`$KDUMP_HELPER -l "$KDUMP_DUMPDEV" | sed -e 's/Length: //g'`
dumpsize_mb=$(($dumpsize / 1024 / 1024))
if [ $KDUMP_FREE_DISK_SIZE -gt 0 ]; then
restsize=`parse_rest_size "$KDUMP_SAVEDIR"`
needsize=`expr $dumpsize_mb + $KDUMP_FREE_DISK_SIZE`
if [ $restsize -lt $needsize ]; then
echo -n " No enough space left on dump device ($restsize MB)"
rc_status -s
rc_failed 6
return
fi
fi
coredir="${KDUMP_SAVEDIR}/`date +"%Y-%m-%d-%H:%M"`"
mkdir -p $coredir
echo -n "Saving crash dump to $coredir"
dd if=$KDUMP_DUMPDEV of=$coredir/vmcore count=$dumpsize
invalidate_dumpdev
}
case "$1" in
start)
if is_crash_kernel; then
if [ -n "$KDUMP_TRANSFER" ]; then
$KDUMP_TRANSFER
else
save_core
fi
if [ -z "$KDUMP_DUMPDEV" ] ; then
if [ -n "$KDUMP_TRANSFER" ]; then
$KDUMP_TRANSFER
else
save_core
fi
fi
if test "$KDUMP_IMMEDIATE_REBOOT" = "yes"; then
/sbin/reboot
# sleep to avoid the conflict with script "single"
sleep 600
fi
else
if have_valid_dump_in_dumpdev ; then
copy_dump_from_dumpdev
fi
load_kdump
fi
;;