From 09e6d2ac95ff958ddd870a232739561b3646d0c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 17 Oct 2017 22:45:07 +0200 Subject: [PATCH] initramfs: add support for variable partitions layout Try to find root filesystem by partition label (not filesystem label!). If that fails, default to 3rd partition according to (new) default layout. Fixes QubesOS/qubes-issues#3173 --- dracut/full-dmroot/qubes_cow_setup.sh | 8 ++++++-- dracut/simple/init.sh | 13 +++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dracut/full-dmroot/qubes_cow_setup.sh b/dracut/full-dmroot/qubes_cow_setup.sh index 7f0dcb1..59fdf91 100644 --- a/dracut/full-dmroot/qubes_cow_setup.sh +++ b/dracut/full-dmroot/qubes_cow_setup.sh @@ -56,9 +56,13 @@ log_begin "Waiting for /dev/xvda* devices..." while ! [ -e /dev/xvda ]; do sleep 0.1; done log_end -# prefer first partition if exists +# prefer partition if exists if [ -b /dev/xvda1 ]; then - ROOT_DEV=xvda1 + if [ -d /dev/disk/by-partlabel ]; then + ROOT_DEV=$(basename $(readlink "/dev/disk/by-partlabel/Root\\x20filesystem")) + else + ROOT_DEV=xvda3 + fi else ROOT_DEV=xvda fi diff --git a/dracut/simple/init.sh b/dracut/simple/init.sh index b09a5d6..6c8ae0c 100644 --- a/dracut/simple/init.sh +++ b/dracut/simple/init.sh @@ -20,9 +20,18 @@ die() { echo "Waiting for /dev/xvda* devices..." while ! [ -e /dev/xvda ]; do sleep 0.1; done -# prefer first partition if exists +# prefer partition if exists if [ -b /dev/xvda1 ]; then - ROOT_DEV=xvda1 + if [ -d /dev/disk/by-partlabel ]; then + ROOT_DEV=$(basename $(readlink "/dev/disk/by-partlabel/Root\\x20filesystem")) + else + ROOT_DEV=$(grep -l "PARTNAME=Root filesystem" /sys/block/xvda/xvda*/uevent |\ + grep -o "xvda[0-9]") + fi + if [ -z "$ROOT_DEV" ]; then + # fallback to third partition + ROOT_DEV=xvda3 + fi else ROOT_DEV=xvda fi