[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#468115: Support for mount failure hooks.



Package: initramfs-tools
Severity: wishlist
Version: 0.91e
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch hardy ubuntu

Attached is a patch to allow scripts in either local-top or init-premount to register hook to perform specific actions in the event the root device cannot be found. A good use for this is when an attemt is made to find the device that contains an LVM volume. If the root device cannot be found, lvm can then be queried to present the user with information about what may be wrong with their volumes. This patch applies against git head. This is part of the Ubuntu specification for better initramfs reliability, found at the following URL: https://wiki.ubuntu.com/HardyInitramfsErrorHandling
diff -urN initramfs-tools/scripts/local initramfs-tools.new/scripts/local
--- initramfs-tools/scripts/local	2008-02-26 10:36:10.443676705 +1100
+++ initramfs-tools.new/scripts/local	2008-02-26 11:31:15.247676705 +1100
@@ -87,7 +87,7 @@
 		esac
 		echo "ALERT!  ${ROOT} does not exist.  Dropping to a shell!"
 		echo "	Check your root= boot argument (cat /proc/cmdline)"
-		panic "	Check for missing modules (cat /proc/modules), or device files (ls /dev)"
+		panic -r "	Check for missing modules (cat /proc/modules), or device files (ls /dev)"
 	done
 
 	# Get the root filesystem type if not set
diff -urN initramfs-tools/scripts/functions initramfs-tools.new/scripts/functions
--- initramfs-tools/scripts/functions	2008-02-26 10:36:10.407676705 +1100
+++ initramfs-tools.new/scripts/functions	2008-02-26 12:13:39.183676705 +1100
@@ -64,6 +64,19 @@
 		sleep ${panic}
 		reboot
 	fi
+
+	# Call mountroot failure hooks if requested.
+	if [ "${1}" = "-r" ]; then
+		shift 1
+
+		if [ -r "/tmp/mountroot-fail.hooks" ]; then
+			mountroot_fail_hooks=$(cat /tmp/mountroot-fail.hooks)
+			for mr_fh in "${mountroot_fail_hooks}"; do
+				${mr_fh} mountfail
+			done
+		fi
+	fi
+
 	modprobe i8042
 	modprobe atkbd
 	echo $@
@@ -308,3 +321,8 @@
 	# source relevant ipconfig output
 	. /tmp/net-${DEVICE}.conf
 }
+
+add_mountroot_fail_hook()
+{
+	echo "$0" >> /tmp/mountroot-fail.hooks
+}
--- 0.85e/initramfs-tools.8	2006-12-14 23:41:16.000000000 +0000
+++ 0.85eubuntu25/initramfs-tools.8	2008-02-12 03:31:09.000000000 +0000
@@ -303,6 +316,20 @@ user to investigate the situation.
 .PP
 .B Example:
 panic "Frobnication failed"
+.fi
+.RE
+.RE
+
+.TP
+\fB \fI
+add_mountroot_fail_hook
+Registers the script as able to provide possible further information, in the
+event that the root device cannot be found. See the example script in the
+initramfs-tools examples directory for more information.
+.RS
+.PP
+.B Example:
+add_mountroot_fail_hook
 .RE
 
 .SS Subdirectories
--- 0.85e/docs/example_script	2006-07-16 20:47:13.000000000 +0100
+++ 0.85eubuntu25/docs/example_script	2008-02-12 03:24:34.000000000 +0000
@@ -60,10 +60,23 @@ prereqs)
 	prereqs
 	exit 0
 	;;
+mountfail) # Called if the script has previously registered a mountroot
+           # failure.
+	# Check status, and display any relevant information about the
+	# failure if there is a problem, then exit with a status of 1.
+	;;
 esac
 
 # Do the work here.
 
+# If this script is to be placed in either init-premount, or local-top,
+# register a mountroot failure hook, so that further information can be given
+# to the user, in the event that the root device cannot be found.
+
+. /scripts/functions
+
+add_mountroot_fail_hook
+
 echo "Got here!"
 
 # Handle an error:

Attachment: signature.asc
Description: Digital signature


Reply to: