From f1a206963d8ab9a5433dcc163a4ce133436b9d94 Mon Sep 17 00:00:00 2001 From: Amerigo Wang Date: Thu, 21 Jul 2011 18:48:58 +0800 Subject: [PATCH] Update initramfs code. --- kdump_dracut_modules/99kdumpbase/check | 11 +- kdump_dracut_modules/99kdumpbase/install | 7 +- .../99kdumpbase/kdump_localfs.sh | 14 ++ kdump_initscripts/init | 185 ------------------ kdump_initscripts/kdumpinit.rootfs | 72 ------- kdump_sample_manifests/manifest.localrootfs | 9 - kexec-tools.spec | 5 + sources | 1 + 8 files changed, 30 insertions(+), 274 deletions(-) create mode 100755 kdump_dracut_modules/99kdumpbase/kdump_localfs.sh delete mode 100755 kdump_initscripts/init delete mode 100644 kdump_initscripts/kdumpinit.rootfs delete mode 100644 kdump_sample_manifests/manifest.localrootfs diff --git a/kdump_dracut_modules/99kdumpbase/check b/kdump_dracut_modules/99kdumpbase/check index a9de7dd..191fa75 100755 --- a/kdump_dracut_modules/99kdumpbase/check +++ b/kdump_dracut_modules/99kdumpbase/check @@ -1,10 +1,9 @@ -#!/bin/sh -if [ ! -f /etc/kdump-adv-conf/init ] +#!/bin/bash + +#kdumpctl sets this explicitly +if [ -z "$IN_KDUMP" ] then - # exit if we didn't set up an init script exit 1 fi - -#do not add this module by default -exit 1 +exit 0 diff --git a/kdump_dracut_modules/99kdumpbase/install b/kdump_dracut_modules/99kdumpbase/install index 8f38a67..bfc4761 100755 --- a/kdump_dracut_modules/99kdumpbase/install +++ b/kdump_dracut_modules/99kdumpbase/install @@ -1,5 +1,8 @@ #!/bin/bash -rm -f $initdir/init -inst "/etc/kdump-adv-conf/init" "/init" + inst "/bin/date" "/bin/date" +inst "/bin/sync" "/bin/sync" inst "/usr/bin/reboot" "/bin/reboot" +inst "/sbin/makedumpfile" "/sbin/makedumpfile" +inst_hook pre-pivot 01 "$moddir/kdump_localfs.sh" + diff --git a/kdump_dracut_modules/99kdumpbase/kdump_localfs.sh b/kdump_dracut_modules/99kdumpbase/kdump_localfs.sh new file mode 100755 index 0000000..513142b --- /dev/null +++ b/kdump_dracut_modules/99kdumpbase/kdump_localfs.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -x +# We have the root file system mounted under $NEWROOT, so copy +# the vmcore there and call it a day +# +DATEDIR=`date +%d.%m.%y-%T` +mount -o remount,rw $NEWROOT/ +mkdir -p $NEWROOT/var/crash/$DATEDIR +cp /proc/vmcore $NEWROOT/var/crash/$DATEDIR/vmcore +sync + +# Once the copy is done, just reboot the system +reboot -f diff --git a/kdump_initscripts/init b/kdump_initscripts/init deleted file mode 100755 index cb6fc6a..0000000 --- a/kdump_initscripts/init +++ /dev/null @@ -1,185 +0,0 @@ -#!/bin/sh -# -# Licensed under the GPLv2 -# -# Copyright 2008, Red Hat, Inc. -# Jeremy Katz - -emergency_shell() -{ - exec >/dev/console 2>&1 /dev/null 2>&1 -mount -t sysfs /sys /sys >/dev/null 2>&1 - -if [ ! -c /dev/ptmx ]; then - # try to mount devtmpfs - if ! mount -t devtmpfs -omode=0755 udev /dev >/dev/null 2>&1; then - # if it failed fall back to normal tmpfs - mount -t tmpfs -omode=0755 udev /dev >/dev/null 2>&1 - # Make some basic devices first, let udev handle the rest - mknod /dev/null c 1 3 - mknod /dev/ptmx c 5 2 - mknod /dev/console c 5 1 - mknod /dev/kmsg c 1 11 - fi -fi - -if getarg rdinitdebug; then - set -x -fi - -mkdir /dev/shm -mkdir /dev/pts -mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1 - -UDEVVERSION=$(udevadm --version) - -source_conf /etc/conf.d - -# run scriptlets to parse the command line -getarg 'rdbreak=cmdline' && emergency_shell "Break before cmdline" -source_all cmdline - -[ -z "$root" ] && die "No or empty root= argument" -[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'" - -# Network root scripts may need updated root= options, -# so deposit them where they can see them (udev purges the env) -{ - echo "root='$root'" - echo "rflags='$rflags'" - echo "fstype='$fstype'" - echo "netroot='$netroot'" - echo "NEWROOT='$NEWROOT'" -} > /tmp/root.info - -# pre-udev scripts run before udev starts, and are run only once. -getarg 'rdbreak=pre-udev' && emergency_shell "Break before pre-udev" -source_all pre-udev - -# start up udev and trigger cold plugs -udevd --daemon - -UDEV_LOG_PRIO_ARG=--log-priority -UDEV_QUEUE_EMPTY="udevadm settle --timeout=0" - -if [ $UDEVVERSION -lt 140 ]; then - UDEV_LOG_PRIO_ARG=--log_priority - UDEV_QUEUE_EMPTY="udevadm settle --timeout=1" -fi - -getarg rdudevinfo && udevadm control $UDEV_LOG_PRIO_ARG=info -getarg rdudevdebug && udevadm control $UDEV_LOG_PRIO_ARG=debug - -getarg 'rdbreak=pre-trigger' && emergency_shell "Break before pre-trigger" -source_all pre-trigger - -# then the rest -udevadm trigger $udevtriggeropts >/dev/null 2>&1 - -getarg 'rdbreak=initqueue' && emergency_shell "Break before initqueue" - -i=0 -while :; do - # bail out, if we have mounted the root filesystem - [ -d "$NEWROOT/proc" ] && break; - - # check if root can be mounted - [ -e /dev/root ] && break; - - if [ $UDEVVERSION -ge 143 ]; then - udevadm settle --exit-if-exists=/initqueue/work --exit-if-exists=/dev/root - else - udevadm settle --timeout=30 - fi - - # bail out, if we have mounted the root filesystem - [ -d "$NEWROOT/proc" ] && break; - # check if root can be mounted - [ -e /dev/root ] && break; - - unset queuetriggered - if [ -f /initqueue/work ]; then - rm /initqueue/work - queuetriggered="1" - fi - - for job in /initqueue/*.sh; do - [ -e "$job" ] || break - job=$job . $job - - # bail out, if we have mounted the root filesystem - [ -d "$NEWROOT/proc" ] && break; - # check if root can be mounted - [ -e /dev/root ] && break; - done - - [ -n "$queuetriggered" ] && continue - - if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then - # no more udev jobs - sleep 0.5 - i=$(($i+1)) - [ $i -gt 20 ] \ - && { flock -s 9 ; emergency_shell "No root device found"; } 9>/.console_lock - fi -done -unset job -unset queuetriggered - -# pre-mount happens before we try to mount the root filesystem, -# and happens once. -getarg 'rdbreak=pre-mount' && emergency_shell "Break pre-mount" -source_all pre-mount - - -getarg 'rdbreak=mount' && emergency_shell "Break mount" -# mount scripts actually try to mount the root filesystem, and may -# be sourced any number of times. As soon as one suceeds, no more are sourced. -i=0 -while :; do - [ -d "$NEWROOT/proc" ] && break; - for f in /mount/*.sh; do - [ -f "$f" ] && . "$f" - [ -d "$NEWROOT/proc" ] && break; - done - - i=$(($i+1)) - [ $i -gt 20 ] \ - && { flock -s 9 ; emergency_shell "Can't mount root filesystem"; } 9>/.console_lock -done - -# We have the root file system mounted under $NEWROOT, so copy -# the vmcore there and call it a day -# -DATEDIR=`date +%d.%m.%y-%T` -mkdir -p $NEWROOT/var/crash/$DATEDIR -cp /proc/vmcore /var/crash/$DATEDIR/vmcore - -# Once the copy is done, just reboot the system -reboot -f diff --git a/kdump_initscripts/kdumpinit.rootfs b/kdump_initscripts/kdumpinit.rootfs deleted file mode 100644 index ba8d90d..0000000 --- a/kdump_initscripts/kdumpinit.rootfs +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh - -################################################### -# Start by setting up the console to work as a user -# expects -################################################### -exec >/dev/console 2>&1 -export TERM=linux -export PS1='initramfs-test:\w\$ ' -stty sane - - -################################################## -# Start udev up -################################################## -start_udev - -################################################## -# Load all the modules based on -# /etc/module_load_list -################################################## -load_modules - -################################################## -# Assemble any existing lvm arrays -################################################## -assemble_lvm_array - - -################################################## -# Assemble any mdraid partitions that might exist -################################################## -#TODO - FILL ME IN - - -################################################## -# Mount the root file system -# Note that the sample manifest modified -# The /etc/fstab file to put the root file system -# under /mnt directly -################################################## -mount /mnt -if [ $? -ne 0] - echo "Failed to mount root fs for dump capture. rebooting" - reboot -f -fi - - -################################################## -# Now capture the core dump to the target fs -# Note we need to set the date here -################################################## -if [ -f /etc/clock ] -then - . /etc/clock -fi -if [ "$UTC" == "true" ] -then - TIME_FORMAT=-u -else - TIME_FORMAT=-l -fi -hwclock --hctosys $TIME_FORMAT - -DATE=`date +%Y-%m-%d-%T` - -cp /proc/vmcore /mnt/var/crash/$DATE/vmcore - -################################################## -# Reboot the system to get back to production -################################################## -reboot -f diff --git a/kdump_sample_manifests/manifest.localrootfs b/kdump_sample_manifests/manifest.localrootfs deleted file mode 100644 index 5743121..0000000 --- a/kdump_sample_manifests/manifest.localrootfs +++ /dev/null @@ -1,9 +0,0 @@ -######################################################### -# Sample manifest for default kdump configuration -# -# This manifest will build an initramfs which mounts the -# root filesystem and switchroots to it -######################################################### - - -dracutmodules="base kdumpbase crypt lvm kernel-modules rootfs-block udev-rules" diff --git a/kexec-tools.spec b/kexec-tools.spec index 270d696..91c9688 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -169,6 +169,7 @@ mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf tar -C $RPM_BUILD_ROOT/etc/kdump-adv-conf -jxvf %{SOURCE100} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/check chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/install +chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/kdump_localfs.sh #and move the custom dracut modules to the dracut directory @@ -282,6 +283,10 @@ done %changelog +* Thu Jul 21 2011 Cong Wang - 2.0.2-4 +- Update initramfs infrastructure to make it working + with dracut. + * Wed Jul 06 2011 Neil Horman - 2.0.2-3 - Removed sysv init script from package diff --git a/sources b/sources index e2ae88e..b3a1212 100644 --- a/sources +++ b/sources @@ -3,3 +3,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 +d872bdde29eb036cd59e7b71c148fca6 dracut-files.tbz2