diff -Nru initramfs-tools-0.85eubuntu39.2/debian/changelog initramfs-tools-0.85eubuntu39.3/debian/changelog --- initramfs-tools-0.85eubuntu39.2/debian/changelog 2008-08-04 18:20:36.000000000 +0200 +++ initramfs-tools-0.85eubuntu39.3/debian/changelog 2008-11-06 22:11:33.000000000 +0100 @@ -1,3 +1,15 @@ +initramfs-tools (0.85eubuntu39.3) hardy-proposed; urgency=low + + * Functionality backported from Intrepid to Hardy to support booting + degraded RAID, LP: #290885. + * scripts/functions: Adjust the mountroot failure hooks framework to + that used in Intrepid, renaming the function so as not to break other + callers in Hardy + * scripts/local: Add get_fstype() and root_missing() helper functions + and fix the root_missing loop + + -- Dustin Kirkland Thu, 06 Nov 2008 22:11:27 +0100 + initramfs-tools (0.85eubuntu39.2) hardy-proposed; urgency=low * Whilst looping for the root filesystem, don't just rely on the existance diff -Nru initramfs-tools-0.85eubuntu39.2/scripts/functions initramfs-tools-0.85eubuntu39.3/scripts/functions --- initramfs-tools-0.85eubuntu39.2/scripts/functions 2008-04-09 16:17:28.000000000 +0200 +++ initramfs-tools-0.85eubuntu39.3/scripts/functions 2008-11-06 18:41:44.000000000 +0100 @@ -253,3 +253,41 @@ { echo "$0" >> /tmp/mountroot-fail.hooks } + +# Add a ".d"-stype failure hook; backported from Intrepid to Hardy +add_mountroot_fail_hook_d() +{ + mkdir -p /tmp/mountroot-fail-hooks.d + ln -s "$0" /tmp/mountroot-fail-hooks.d/"$1" +} + +# Run failure hooks. +# When a failure hook exits "1", it has not done anything to correct the +# system. Exiting "0" means that something has been attempted to resolve +# the lack of a root filesystem. +# Hooks are run in lexigraphical order, and are responsible for removing +# themselves if they should not re-run in a later cycle. When one exits +# "0", the stack is stopped, so the caller can return to the main rootfs +# wait loop. +try_failure_hooks() +{ + local hook + + # Disable usplash so text from hooks can be seen + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "QUIT" + fi + chvt 1 + + if [ ! -d "/tmp/mountroot-fail-hooks.d" ]; then + return 1 + fi + + for hook in /tmp/mountroot-fail-hooks.d/*; do + if [ -x ${hook} ] && ${hook} mountfail; then + return 0 + fi + done + return 1 +} + diff -Nru initramfs-tools-0.85eubuntu39.2/scripts/local initramfs-tools-0.85eubuntu39.3/scripts/local --- initramfs-tools-0.85eubuntu39.2/scripts/local 2008-07-02 17:44:28.000000000 +0200 +++ initramfs-tools-0.85eubuntu39.3/scripts/local 2008-11-06 18:37:57.000000000 +0100 @@ -1,5 +1,40 @@ # Local filesystem mounting -*- shell-script -*- +# Parameter: device node to check +# Echos fstype to stdout +# Return value: indicates if an fs could be recognized +get_fstype () +{ + local FS FSTYPE FSSIZE RET + FS="${1}" + + # vol_id has a more complete list of file systems, + # but fstype is more robust + eval $(fstype "${FS}" 2> /dev/null) + + if [ -z "${FSTYPE}" ]; then + FSTYPE="unknown" + fi + + if [ "$FSTYPE" = "unknown" ] && [ -x /lib/udev/vol_id ]; then + FSTYPE=$(/lib/udev/vol_id -t "${FS}" 2> /dev/null) + fi + RET=$? + + if [ -z "${FSTYPE}" ]; then + FSTYPE="unknown" + fi + + echo "${FSTYPE}" + return ${RET} +} + +root_missing() +{ + ROOT="${1}" + [ ! -e "${ROOT}" ] || ! $(get_fstype "${ROOT}" >/dev/null) || ! /sbin/udevadm settle +} + # Parameter: Where to mount the filesystem mountroot () { @@ -9,7 +44,7 @@ # If the root device hasn't shown up yet, give it a little while # to deal with removable devices - if [ ! -e "${ROOT}" ] || ! /lib/udev/vol_id "${ROOT}" >/dev/null 2>&1 || ! /sbin/udevadm settle; then + while root_missing "${ROOT}"; do log_begin_msg "Waiting for root file system..." # Default delay is 180s @@ -23,7 +58,7 @@ fi slumber=$(( ${slumber} * 10 )) - while [ ! -e "${ROOT}" ] || ! /lib/udev/vol_id "${ROOT}" >/dev/null 2>&1 || ! /sbin/udevadm settle; do + while root_missing "${ROOT}"; do /bin/sleep 0.1 slumber=$(( ${slumber} - 1 )) [ ${slumber} -gt 0 ] || break @@ -37,10 +72,16 @@ if [ -x /sbin/usplash_write ]; then /sbin/usplash_write "TIMEOUT 15" || true fi - fi + # Run failure hooks, hoping one of them can fix up the system + # and we can restart the wait loop. If they all fail, abort + # and move on to the panic handler and shell. + if root_missing "${ROOT}" && ! try_failure_hooks; then + break + fi + done # We've given up, but we'll let the user fix matters if they can - while [ ! -e "${ROOT}" ] || ! /lib/udev/vol_id "${ROOT}" >/dev/null 2>&1 || ! /sbin/udevadm settle; do + while root_missing "${ROOT}"; do echo " Check root= bootarg cat /proc/cmdline" echo " or missing modules, devices: cat /proc/modules ls /dev" panic -r "ALERT! ${ROOT} does not exist. Dropping to a shell!" @@ -48,14 +89,10 @@ # Get the root filesystem type if not set if [ -z "${ROOTFSTYPE}" ]; then - eval $(fstype < ${ROOT}) + FSTYPE=$(get_fstype "${ROOT}") else FSTYPE=${ROOTFSTYPE} fi - if [ "$FSTYPE" = "unknown" ] && [ -x /lib/udev/vol_id ]; then - FSTYPE=$(/lib/udev/vol_id -t ${ROOT}) - [ -z "$FSTYPE" ] && FSTYPE="unknown" - fi [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount" run_scripts /scripts/local-premount