]> TLD Linux GIT Repositories - packages/grub2.git/blob - grub-lvmdevice.patch
- PLD merge, mangle root device name only for LVM devices
[packages/grub2.git] / grub-lvmdevice.patch
1 --- grub-1.97.1/util/grub-mkconfig.in~  2009-11-17 17:02:16.626243372 +0200
2 +++ grub-1.97.1/util/grub-mkconfig.in   2009-11-17 17:02:08.346050859 +0200
3 @@ -120,6 +120,27 @@
4  
5  # Device containing our userland.  Typically used for root= parameter.
6  GRUB_DEVICE="`${grub_probe} --target=device /`"
7 +
8 +# Rewrite to sane LVM node (Code from PLD Linux geninitrd):
9 +# /dev/mapper/sys-rootfs -> /dev/sys/rootfs
10 +# /dev/mapper/blodnatt-blah--bleh -> /dev/blodnatt/blah-bleh
11 +# /dev/mapper/vg--meaw-root -> /dev/vg-meaw/root
12 +case "$GRUB_DEVICE" in
13 +       /dev/mapper/*-*)
14 +               DM_REAL_DEVICE="$(readlink -f "$GRUB_DEVICE")"
15 +               DM_UUID="$(cat /sys/block/${DM_REAL_DEVICE#/dev/}/dm/uuid)"
16 +               case "$DM_UUID" in
17 +                       LVM-*)
18 +                               # change "--" to / (as "/" is impossible in LV name)
19 +                               local dev=$(awk -vdev="${GRUB_DEVICE#/dev/mapper/}" 'BEGIN{gsub(/--/, "/", dev); print dev}')
20 +                               local VG=$(awk -vdev="$dev" 'BEGIN{split(dev, v, "-"); gsub("/", "-", v[1]); print v[1]}')
21 +                               local LV=$(awk -vdev="$dev" 'BEGIN{split(dev, v, "-"); gsub("/", "-", v[2]); print v[2]}')
22 +                               GRUB_DEVICE=/dev/$VG/$LV
23 +                               ;;
24 +               esac
25 +       ;;
26 +esac
27 +
28  GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
29  
30  # Device containing our /boot partition.  Usually the same as GRUB_DEVICE.