[Pkg-cryptsetup-devel] Bug#488271: cryptsetup: use a loop to wait for the root device

James Westby jw+debian at jameswestby.net
Fri Jun 27 13:31:50 UTC 2008


Package: cryptsetup
Version: 2:1.0.6-2
Severity: wishlist
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu intrepid ubuntu-patch

Hi,

In

  https://launchpad.net/bugs/164044

a user said that he was unable to boot with the root device
being a slow USB device, as the udevsettle call was only
sufficient if the kernel was currently processing an event
which would cause the device to appear. If the event is so slow
that the udevsettle call is made prior to it's arrival
the boot will fail.

The attached patch is used in Ubuntu to implement a sleeping
loop waiting for the device to appear, as is done for a
normal root device. Please consider applying the patch.

Thanks,

James

diff -pruN 2:1.0.6-2/debian/initramfs/cryptroot-script
2:1.0.6-2ubuntu7/debian/initramfs/cryptroot-script
--- 2:1.0.6-2/debian/initramfs/cryptroot-script	2008-06-20 22:19:57.000000000 +0100
+++ 2:1.0.6-2ubuntu7/debian/initramfs/cryptroot-script	2008-06-20 22:16:41.000000000 +0100
@@ -193,13 +193,49 @@ setup_mapping()
 		activate_evms $cryptsource
 	fi
 
-	udev_settle
+	# If the encrypted source device hasn't shown up yet, give it a
+	# little while to deal with removable devices
 
-	if [ ! -e $cryptsource ]; then
-		message "cryptsetup: source device $cryptsource not found"
-		return 1
+	# the following lines below have been taken from
+	# /usr/share/initramfs-tools/scripts/local, as suggested per
+	# https://launchpad.net/bugs/164044
+	if [ ! -e "$cryptsource" ] || ! /lib/udev/vol_id "$cryptsource" >/dev/null 2>&1; then
+		log_begin_msg "Waiting for encrypted source device..."
+
+		# Default delay is 180s
+		if [ -z "${ROOTDELAY}" ]; then
+			slumber=180
+		else
+			slumber=${ROOTDELAY}
+		fi
+		if [ -x /sbin/usplash_write ]; then
+			/sbin/usplash_write "TIMEOUT ${slumber}" || true
+		fi
+
+		slumber=$(( ${slumber} * 10 ))
+		while [ ! -e "$cryptsource" ] || ! /lib/udev/vol_id "$cryptsource" >/dev/null 2>&1; do
+			/bin/sleep 0.1
+			slumber=$(( ${slumber} - 1 ))
+			[ ${slumber} -gt 0 ] || break
+		done
+
+		if [ ${slumber} -gt 0 ]; then
+			log_end_msg 0
+		else
+			log_end_msg 1 || true
+		fi
+		if [ -x /sbin/usplash_write ]; then
+			/sbin/usplash_write "TIMEOUT 15" || true
+		fi
 	fi
 
+	# We've given up, but we'll let the user fix matters if they can
+	while [ ! -e "${cryptsource}" ]; do
+		echo "	Check cryptopts=source= bootarg cat /proc/cmdline"
+		echo "	or missing modules, devices: cat /proc/modules ls /dev"
+		panic -r "ALERT!  ${cryptsource} does not exist.  Dropping to a shell!"
+	done
+
 	# Prepare commands
 	if /sbin/cryptsetup isLuks $cryptsource > /dev/null 2>&1; then
 		cryptcreate="/sbin/cryptsetup -T 1 luksOpen $cryptsource $crypttarget"
@@ -275,6 +311,8 @@ setup_mapping()
 # Begin real processing
 #
 
+. ./scripts/functions
+
 # Do we have any kernel boot arguments?
 found=''
 for opt in $(cat /proc/cmdline); do



-------------- next part --------------
A non-text attachment was scrubbed...
Name: cryptsetup-wait-loop.diff
Type: text/x-patch
Size: 2113 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-cryptsetup-devel/attachments/20080627/12d86aa4/attachment.bin 


More information about the Pkg-cryptsetup-devel mailing list