Bug#378332: Update-initramfs: suggested patch to make scripts/local-top/lvm understand "/dev/vg/lv"
On Tue, 17 Feb 2009, Struan Bartlett wrote:
>
> The following patch is employed at our company to enable the use of
> /dev/vg/lv syntax in the root argument on the kernel command line. It
> simply adds an extra case check, for the alternative syntax. I realise
> that /dev/vg/lv is a symlink and not the 'real' root device node. But
> given the symlink is widely deployed in fstab - after all why else does
> dm-mapper create this convenient symlink? - I don't suppose it does any
> harm to make this an option on the kernel command line too.
with /dev/mapper/vg-lv syntax you know with a very good certainty
that you have a real vg in front of you.
/dev/vg/lv can be anything. the symlink only gets setup after the
/dev/mapper/vg-lv device is there. yes there were in the past quite
some lvm2 cmds that would only operate on the symlink..
> # diff -ubw initramfs-tools/scripts/local-top/lvm
> initramfs-tools.new/scripts/local-top/lvm
> --- initramfs-tools/scripts/local-top/lvm 2007-04-13
> 12:17:29.000000000 +0100
> +++ initramfs-tools.new/scripts/local-top/lvm 2009-02-17
well that legacy script is gone, but right the boot script in lvm2
is quite similar, so probably would apply there too.
> 17:23:29.000000000 +0000
> @@ -37,11 +37,9 @@
> ;;
> esac
>
> - # Make sure that we have a d-m path
> + # See if we have a /dev/mapper/vg-lv path
> vg=${vg#/dev/mapper/}
> - if [ "$vg" = "$1" ]; then
> - return 1
> - fi
> + if [ "$vg" != "$1" ]; then
no that is ugly, don't wrap a hole lot of code in an if
also you didn't add the ident then.
> # Make sure that the device includes at least one dash
> if [ "$(echo -n "$vg" | tr -d -)" = "$vg" ]; then
> @@ -54,6 +52,21 @@
> vg=$(echo ${vg} | sed -e 's#--#-#g')
>
> vgchange -ay ${vg}
> + return 0
> + fi
> +
> + # See if we have a /dev/vg/lv path
> + vg=${1#/dev/}
> + if [ "$vg" != "$1" ]; then
and how are you sure that you have an lvm2 device there!?
> +
> + # Split volume group from logical volume.
> + vg=$(echo ${vg} | sed -e 's#\(.*\)\([^/]\)/[^/].*#\1\2#')
> +
> + vgchange -ay ${vg}
beside you forget to escape the s/--/-/
> + return 0
> + fi
> +
> + return 1
> }
>
> if [ -e /scripts/local-top/lvm2 ]; then
>
>
>
>
--
maks
Reply to: