mkdumprd: fix dump to local filesystem and raw dump

This commit is contained in:
Amerigo Wang 2011-08-01 20:01:31 +08:00
parent aee02035a1
commit 1048810fe0
4 changed files with 47 additions and 6 deletions

View File

@ -15,7 +15,7 @@ do_default_action()
$DEFAULT_ACTION
}
add_dump_instruction()
add_dump_code()
{
if [ -z "$DUMP_INSTRUCTION" ]
then
@ -25,6 +25,24 @@ add_dump_instruction()
fi
}
dump_localfs()
{
mount -o remount,rw $NEWROOT/ || return 1
[ -d $NEWROOT/mnt ] || mkdir -p $NEWROOT/mnt
mount -t $1 $2 $NEWROOT/mnt || return 1
mkdir -p $NEWROOT/mnt/$KDUMP_PATH/$DATEDIR
$CORE_COLLECTOR /proc/vmcore $NEWROOT/mnt/$KDUMP_PATH/$DATEDIR/vmcore || return 1
umount /mnt || return 1
return 0
}
dump_raw()
{
CORE_COLLECTOR=`echo $CORE_COLLECTOR | sed -e's/\(^makedumpfile\)\(.*$\)/\1 -F \2/'`
$CORE_COLLECTOR /proc/vmcore | dd of=$1 bs=512 || return 1
return 0
}
dump_rootfs()
{
mount -o remount,rw $NEWROOT/ || return 1
@ -36,6 +54,8 @@ dump_rootfs()
dump_nfs()
{
mount -o remount,rw $NEWROOT/ || return 1
[ -d $NEWROOT/mnt ] || mkdir -p $NEWROOT/mnt
mount -o nolock -o tcp -t nfs $1 $NEWROOT/mnt/
mkdir -p $NEWROOT/mnt/$KDUMP_PATH/$DATEDIR || return 1
$CORE_COLLECTOR /proc/vmcore $NEWROOT/mnt/$KDUMP_PATH/$DATEDIR/vmcore || return 1
@ -50,6 +70,18 @@ dump_ssh()
return 0
}
to_dev_name()
{
local _dev=$1
local _is_uuid=`echo $1 | grep UUID`
local _is_label=`echo $1 | grep LABEL`
if [ -n "$_is_uuid" -o -n "$_is_label" ]
then
_dev=`findfs $1`
fi
echo $_dev
}
read_kdump_conf()
{
local conf_file="/etc/kdump.conf"
@ -57,6 +89,12 @@ read_kdump_conf()
while read config_opt config_val;
do
case "$config_opt" in
ext[234]|xfs|btrfs|minix)
add_dump_code "dump_localfs $config_opt "$(to_dev_name $config_val)" || do_default_action"
;;
raw)
add_dump_code "dump_raw $config_val || do_default_action"
;;
path)
KDUMP_PATH="$config_val"
;;
@ -66,9 +104,9 @@ read_kdump_conf()
net)
if [ -n "$(echo $config_val | grep @)" ]
then
add_dump_instruction "dump_ssh $config_val || do_default_action"
add_dump_code "dump_ssh $config_val || do_default_action"
else
add_dump_instruction "dump_nfs $config_val || do_default_action"
add_dump_code "dump_nfs $config_val || do_default_action"
fi
;;
default)

View File

@ -69,7 +69,7 @@ depends() {
install() {
inst "/bin/date" "/bin/date"
inst "/bin/sync" "/bin/sync"
inst "/usr/bin/reboot" "/bin/reboot"
inst "/sbin/findfs" "/sbin/findfs"
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
inst "/etc/kdump.conf" "/etc/kdump.conf"
inst_hook pre-pivot 01 "$moddir/kdump.sh"

View File

@ -1,6 +1,6 @@
Name: kexec-tools
Version: 2.0.2
Release: 17%{?dist}
Release: 18%{?dist}
License: GPLv2
Group: Applications/System
Summary: The kexec/kdump userspace component.
@ -280,6 +280,9 @@ done
%changelog
* Mon Aug 1 2011 Cong Wang <xiyou.wangcong@gmail.com> - 2.0.2-18
- Fix dump to local filesystem and raw dump.
* Mon Aug 1 2011 Cong Wang <xiyou.wangcong@gmail.com> - 2.0.2-17
- Depend on dracut-network.

View File

@ -2,4 +2,4 @@ d9f2ecd3c3307905f24130a25816e6cc kexec-tools-2.0.0.tar.bz2
3e802d638dce0080b910f15908c04a24 kexec-tools-po.tar.gz
e3a813bd6d7dace903a05c1296e20d57 makedumpfile-1.3.5.tar.gz
8e359dd03731b93a2082bd37cc2a4a4c kexec-tools-2.0.2.tar.bz2
2cda75991642bd2ad58e93e89297748b dracut-files.tbz2
354f51df313598f3ee0429c3ab19242c dracut-files.tbz2