initramfs: use symlink for rw root.img, instead of dm-linear

Do not add 1:1 dm-linear when root.img (/dev/xvda) is read-write. This
was to always have root device at /dev/mapper/dmroot, but unfortunately
grub can't parse it properly (fails at looking for partition number of
/dev/xvda1). There was a hack specifically for this, but it caused other
partitions on xvda unavailable.
On the other hand, symlink is enough to be able to mount always the same
device. Now, grub detect that root fs is on /dev/xvda1, which is
enough to have grub2-install working. Unfortunate effect is that it puts
root=/dev/xvda1 at kernel command line, which breaks AppVMs based on
this TemplateVM. But it's easier to fix kernel command line, than grub
device detection logic.

Fixes "initramfs: add support for root.img with partition table"

QubesOS/qubes-issues#2557
pull/14/head mm_da3f3cd4
Marek Marczykowski-Górecki 7 years ago
parent e9b8e5a4d1
commit da3f3cd426
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

@ -87,6 +87,7 @@ EOF
echo "0 `cat /sys/class/block/$ROOT_DEV/size` snapshot /dev/$ROOT_DEV /dev/xvdc2 N 16" | \
dmsetup --noudevsync create dmroot || die "Qubes: FATAL: cannot create dmroot!"
dmsetup mknodes dmroot
log_end
else
log_begin "Qubes: Doing R/W setup for TemplateVM..."
@ -99,17 +100,7 @@ EOF
fi
while ! [ -e /dev/xvdc1 ]; do sleep 0.1; done
mkswap /dev/xvdc1
if [ "$ROOT_DEV" = "xvda1" ]; then
# grub2-probe for some reason can't parse dm-linear pointing at
# partition device directly, but can when it points at it indirectly
# through base device and offset; lets make life easier for users of
# grub2-install
DM_ROOT="/dev/xvda $(cat /sys/class/block/$ROOT_DEV/start)"
else
DM_ROOT="/dev/$ROOT_DEV 0"
fi
echo "0 `cat /sys/class/block/$ROOT_DEV/size` linear $DM_ROOT" | \
dmsetup create dmroot || { echo "Qubes: FATAL: cannot create dmroot!"; exit 1; }
printf 'KERNEL=="%s", SYMLINK+="mapper/dmroot"' "$ROOT_DEV" >> \
/etc/udev/rules.d/99-root.rules
log_end
fi
dmsetup mknodes dmroot

@ -52,6 +52,7 @@ EOF
echo "0 `cat /sys/class/block/$ROOT_DEV/size` snapshot /dev/$ROOT_DEV /dev/xvdc2 N 16" | \
dmsetup create dmroot || { echo "Qubes: FATAL: cannot create dmroot!"; exit 1; }
dmsetup mknodes dmroot
echo Qubes: done.
else
echo "Qubes: Doing R/W setup for TemplateVM..."
@ -64,20 +65,9 @@ EOF
fi
while ! [ -e /dev/xvdc1 ]; do sleep 0.1; done
mkswap /dev/xvdc1
if [ "$ROOT_DEV" = "xvda1" ]; then
# grub2-probe for some reason can't parse dm-linear pointing at
# partition device directly, but can when it points at it indirectly
# through base device and offset; lets make life easier for users of
# grub2-install
DM_ROOT="/dev/xvda $(cat /sys/class/block/$ROOT_DEV/start)"
else
DM_ROOT="/dev/$ROOT_DEV 0"
fi
echo "0 `cat /sys/class/block/$ROOT_DEV/size` linear $DM_ROOT" | \
dmsetup create dmroot || { echo "Qubes: FATAL: cannot create dmroot!"; exit 1; }
ln -s ../$ROOT_DEV /dev/mapper/dmroot
echo Qubes: done.
fi
dmsetup mknodes dmroot
modprobe ext4

Loading…
Cancel
Save