Hi, I encountered this bug after doing a jessie install and converting
the root btrfs pool to raid post-install, similar to what Paul Dreik
described.

At first I tried the most recent patch from Marek Dopiera, however it
did not work for me since it looks like his patch relies on fstab having
device paths (e.g. /dev/mapper/sda2_crypt) and fails to detect btrfs for
fstab entries using UUID.

So I applied Jon Severinsson patch from wheezy era, works great!
Attached is his patch re-worked for 1.6.6-1.

-- 
Gerald Turner <[email protected]>        Encrypted mail preferred!
OpenPGP: 4096R / CA89 B27A 30FA 66C5 1B80  3858 EC94 2276 FDB8 716D
--- cryptsetup-1.6.6/debian/initramfs/cryptroot-hook.orig	2014-09-02 00:35:27.822073093 -0700
+++ cryptsetup-1.6.6/debian/initramfs/cryptroot-hook	2014-09-02 00:37:29.296772349 -0700
@@ -16,7 +16,7 @@
 
 . /usr/share/initramfs-tools/hook-functions
 
-get_root_device() {
+get_root_devices() {
 	local device mount type options dump pass
 
 	if [ ! -r /etc/fstab ]; then
@@ -26,8 +26,15 @@
 	grep -s '^[^#]' /etc/fstab | \
 	while read device mount type options dump pass; do
 		if [ "$mount" = "/" ]; then
-			device=$(canonical_device "$device") || return 0
-			echo "$device"
+			local devices
+			if [ "$type" = "btrfs" ] ; then
+				for dev in $(btrfs filesystem show $(canonical_device "$device" --no-simplify) 2>/dev/null | sed -r -e 's/.*devid .+ path (.+)/\1/;tx;d;:x') ; do
+					devices="$devices $(canonical_device "$dev")"
+				done
+			else
+				devices=$(canonical_device "$device") || return 0
+			fi
+			echo "$devices"
 			return
 		fi
 	done
@@ -90,7 +97,7 @@
 		if [ -n "$derived" ]; then
 			if grep -q "^$derived" /etc/crypttab; then
 				derived=$(canonical_device "/dev/mapper/$derived") || return 0
-				if [ "$derived" != "$rootdev" ]; then
+				if ! echo "$rootdevs" | grep -q -e "$derived"; then
 					devices="$devices $derived"
 				fi
 			else
@@ -308,6 +315,7 @@
 canonical_device() {
 	local dev altdev original
 	dev="$1"
+	opt="$2"
 
 	altdev="${dev#LABEL=}"
 	if [ "$altdev" != "$dev" ]; then
@@ -324,6 +332,11 @@
 		dev=$(readlink -e "$dev")
 	fi
 
+	if [ "$opt" = "--no-simplify" ]; then
+		echo "$dev"
+		return 0
+	fi
+
 	if [ "x${dev%/dev/dm-*}" = "x" ]; then
 		# try to detect corresponding symlink in /dev/mapper/
 		for dmdev in /dev/mapper/*; do
@@ -359,7 +372,7 @@
 	fi
 
 	# Flag root device
-	if [ "$nodes" = "$rootdev" ]; then
+	if echo "$rootdevs" | grep -q -e "$nodes"; then
 		if [ -z "$opts" ]; then
 			opts="rootdev"
 		else
@@ -507,7 +520,7 @@
 #
 
 setup="no"
-rootdev=""
+rootdevs=""
 resumedevs=""
 
 # Include cryptsetup modules, regardless of _this_ machine
@@ -518,15 +531,15 @@
 
 # Find the root and resume device(s)
 if [ -r /etc/crypttab ]; then
-	rootdev=$(get_root_device)
-	if [ -z "$rootdev" ]; then
+	rootdevs=$(get_root_devices)
+	if [ -z "$rootdevs" ]; then
 		echo "cryptsetup: WARNING: could not determine root device from /etc/fstab" >&2
 	fi
 	resumedevs=$(get_resume_devices)
 fi
 
 # Load the config opts and modules for each device
-for dev in $rootdev $resumedevs; do
+for dev in $rootdevs $resumedevs; do
 	if ! modules=$(add_device "$dev"); then
 		echo "cryptsetup: FAILURE: could not determine configuration for $dev" >&2
 		continue

Attachment: pgpMgD5e_UTWR.pgp
Description: PGP signature

Reply via email to