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
This commit is contained in:
Marek Marczykowski-Górecki 2017-10-17 22:45:07 +02:00
parent e9615899ff
commit 09e6d2ac95
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 17 additions and 4 deletions

View File

@ -56,9 +56,13 @@ log_begin "Waiting for /dev/xvda* devices..."
while ! [ -e /dev/xvda ]; do sleep 0.1; done while ! [ -e /dev/xvda ]; do sleep 0.1; done
log_end log_end
# prefer first partition if exists # prefer partition if exists
if [ -b /dev/xvda1 ]; then 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 else
ROOT_DEV=xvda ROOT_DEV=xvda
fi fi

View File

@ -20,9 +20,18 @@ die() {
echo "Waiting for /dev/xvda* devices..." echo "Waiting for /dev/xvda* devices..."
while ! [ -e /dev/xvda ]; do sleep 0.1; done while ! [ -e /dev/xvda ]; do sleep 0.1; done
# prefer first partition if exists # prefer partition if exists
if [ -b /dev/xvda1 ]; then 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 else
ROOT_DEV=xvda ROOT_DEV=xvda
fi fi