MT#12537 Workaround for GRUB installations to virtio disks with lvm >=v2.02.106

Since lvm2 v2.02.106 its udev rule creates a
/dev/disk/by-id/lvm-pv-uuid-<PV_UUID> symlink for PVs:

  https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=417e52c13a8156b11c25c411d44bda8b32bf87e4

When debootstrapping Debian/wheezy to a virtio disk from a system
using lvm2 >=v2.02.106 (as present in Grml >=2014.11) this causes
the resulting GRUB installation to look like that
(`/media/ngcp-root` is the mounted logical volume with the rootfs
which also includes /boot):

| root@grml ~ # cat /media/ngcp-root/boot/grub/device.map
| (hd0)   /dev/disk/by-id/lvm-pv-uuid-RNZHr8-hLlc-nles-X9Gs-RYSp-Mqo7-uZTk6N
| (hd1)   /dev/vda

and failing to boot with:

> error: no such disk
> Entering rescue mode...
> grub rescue>

When manually removing the lvm-pv-uuid* symlink from the
Debian/jessie system before installing GRUB it works fine:

| root@grml ~ # rm /dev/disk/by-id/lvm-pv-uuid-RNZHr8-hLlc-nles-X9Gs-RYSp-Mqo7-uZTk6N
| root@grml ~ # ls /dev/disk/by-id
| ata-QEMU_DVD-ROM_QM00003@  dm-name-ngcp-swap@                                                             dm-uuid-LVM-lQhnvLyYmhESObLrZcnJs4FTZq9usVDzRex3ImRtrmqhpDH9xKBj22St82lHDADh@
| dm-name-ngcp-root@         dm-uuid-LVM-lQhnvLyYmhESObLrZcnJs4FTZq9usVDzrcMaDfk8O0RionEYRxdjnYxsY6eb0Esi@
| root@grml ~ # grml-chroot /media/ngcp-root/ grub-install --recheck /dev/vda # `grml-chroot` makes sure /proc, /sysfs and /dev are properly mounted in the chroot
| Writing /etc/debian_chroot ...
| Installation finished. No error reported.
| root@grml ~ # cat /media/ngcp-root/boot/grub/device.map
| (hd0)   /dev/vda

NOTE: This problem seems to exist only for virtio disks, when
using a disk on the SATA bus the resulting device.map of the
Debian/wheezy system looks like that and boots fine:

| root@grml ~ # cat /media/vg0-root/boot/grub/device.map
| (hd0)   /dev/disk/by-id/ata-QEMU_HARDDISK_QM00005
| (hd1)   /dev/disk/by-id/lvm-pv-uuid-lJJr4E-M96R-3eIS-b6YO-5usn-bH5o-osQV2B

As a result check for Debian wheezy (or older) and if the disk is
a virtio one (AKA /dev/vda), if so then remove the symlink of the
live system before installing Debian incl. GRUB via
grml-debootstrap.

Reported as https://bugs.debian.org/782998 in Debian's BTS.

Change-Id: I4b2cf9e39c88521ab7eac7799531508e658cc30d
(cherry picked from commit 7340bf211c)
mr3.8.2
Michael Prokop 11 years ago committed by Alexander Lutay
parent d2183da3df
commit a25fa247c6

@ -1225,7 +1225,20 @@ fi
echo "deb ${MIRROR} ${DEBIAN_RELEASE}-updates main contrib non-free" >> /etc/debootstrap/etc/apt/sources.list
# GRUB versions until Debian/wheezy generate an invalid device.map
# entry if /dev/disk/by-id/lvm-pv-uuid-* is present, resulting in
# a GRUB installation failing with "error: no such disk" during boot.
# This is only a problem if we're using a virtio disk and deploying
# from a system running lvm2 v2.02.106 or newer.
if [ "$DISK" = "vda" ] ; then
case "$DEBIAN_RELEASE" in
lenny|squeeze|wheezy)
echo "Applying /dev/disk/by-id/lvm-pv-uuid-* workaround for virtio disk and Debian release <= wheezy"
logit "Applying /dev/disk/by-id/lvm-pv-uuid-* workaround for virtio disk and Debian release <= wheezy"
rm -f /dev/disk/by-id/lvm-pv-uuid-*
;;
esac
fi
# install Debian
echo y | grml-debootstrap \

Loading…
Cancel
Save