--- /mnt/hd2/usr/share/initramfs-tools/scripts/local-top/cryptroot	2007-10-11 22:39:56.000000000 +0200
+++ cryptroot	2007-11-20 12:21:25.000000000 +0100
@@ -25,6 +25,9 @@
 #
 # Helper functions
 #
+
+. /scripts/functions
+
 parse_options()
 {
 	local cryptopts
@@ -158,11 +161,45 @@
 		/sbin/udevsettle --timeout=30
 	fi
 
-	if [ ! -e $cryptsource ]; then
-		echo "cryptsetup: Source device $cryptsource not found"
-		return 1
+	# If the encrypted source device hasn't shown up yet, give it a little while
+	# to deal with removable devices
+	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 "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 luksOpen $cryptsource $crypttarget"
