Hey Christoph, On 04/11/2010 Christoph Anton Mitterer wrote: > I haven't fully looked at this so perhaps it's unrelated,... > > But one main problem I see here (that may be related), is that lvm's > init-scripts are simply wrong, and abusing some things. > I've already told Bastian this and there are even several bugs open. > > The problem is that lvm's init script simply doesn't to an lvchange -ay > but try to detect the LV holding root. > And it does this in a wrong way by using the root= kernel param (which > is the final device, containing the root-fs) > > Most lvm/dm-crypt realted I've seen were simply solvable by letting the > lvm initscript just do an lvchange -ay (thereby making all LVs > available) and then using dmcrypt/cryptsetup as normal.
while this bug is not related to init scripts at all, your suggestions makes a lot of sense to me. after all, i don't see a reason to detect the volume group with complicated dmsetup, sed and lvdisplay invokations instead of just activating all volume groups globally in the initramfs. attached patch removes any vg-guessing magic from the initramfs cryptroot script, just invoking 'lvm vgchange -ay' instead. thanks for the comment, Christoph! greetings, jonas
--- /usr/share/initramfs-tools/scripts/local-top/cryptroot.orig
+++ /usr/share/initramfs-tools/scripts/local-top/cryptroot
@@ -141,46 +141,31 @@
activate_vg()
{
- local vg
- vg="${1#/dev/mapper/}"
-
# Sanity checks
if [ ! -x /sbin/lvm ]; then
message "cryptsetup: lvm is not available"
return 1
- elif [ "$vg" = "$1" ]; then
- message "cryptsetup: lvm device name ($vg) does not begin with /dev/mapper/"
- return 1
fi
- # Make sure that the device contains at least one dash
- if [ "${vg%%-*}" = "$vg" ]; then
- message "cryptsetup: lvm device name ($vg) does not contain a dash"
+ # Detect available volume groups
+ vgs=$(lvm vgs --noheadings -o vg_name | sed -e "s/^[ \t]*\(.*\)[ \t]*$/\1/g")
+ if [ -z "$vgs" ]; then
+ message "cryptsetup: no lvm volume groups found"
return 1
fi
- # Split volume group from logical volume.
- vg=$(echo ${vg} | sed -e 's#\(.*\)\([^-]\)-[^-].*#\1\2#')
-
- # Reduce padded --'s to -'s
- vg=$(echo ${vg} | sed -e 's#--#-#g')
-
- lvm vgchange -ay ${vg}
+ lvm vgchange -ay
return $?
}
activate_evms()
{
local dev module
- dev="${1#/dev/evms/}"
# Sanity checks
if [ ! -x /sbin/evms_activate ]; then
message "cryptsetup: evms_activate is not available"
return 1
- elif [ "$dev" = "$1" ]; then
- message "cryptsetup: evms device name ($vg) does not begin with /dev/evms/"
- return 1
fi
# Load modules used by evms
@@ -219,8 +204,8 @@
# Make sure the cryptsource device is available
if [ ! -e $cryptsource ]; then
- activate_vg $cryptsource
- activate_evms $cryptsource
+ activate_vg
+ activate_evms
fi
# If the encrypted source device hasn't shown up yet, give it a
@@ -320,7 +305,7 @@
if [ -z "$cryptlvm" ]; then
message "cryptsetup: lvm fs found but no lvm configured"
return 1
- elif ! activate_vg "/dev/mapper/$cryptlvm"; then
+ elif ! activate_vg; then
# disable error message, LP: #151532
#message "cryptsetup: failed to setup lvm device"
return 1
signature.asc
Description: Digital signature

