From 90970f8ae4f7b7036742fd45e3b55fbf428610f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 27 Feb 2022 04:03:44 +0100 Subject: [PATCH 1/3] dracut: set PATH to include /sbin too Don't require every command from /sbin to be called with a full path. --- dracut/simple/init.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dracut/simple/init.sh b/dracut/simple/init.sh index 1d6f6b1d..063cd4c1 100644 --- a/dracut/simple/init.sh +++ b/dracut/simple/init.sh @@ -1,6 +1,8 @@ #!/bin/sh echo "Qubes initramfs script here:" +PATH=/sbin:/bin + mkdir -p /proc /sys /dev mount -t proc proc /proc mount -t sysfs sysfs /sys From aac3112972950e24025de230238a6cfe14b6dbe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 27 Feb 2022 04:04:58 +0100 Subject: [PATCH 2/3] dracut: Mount /dev/xvdd as read-only explicitly The device is read-only, avoid confusing message about forcing mount to be read-only. --- dracut/full-modules/mount_modules.sh | 2 +- dracut/simple/init.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dracut/full-modules/mount_modules.sh b/dracut/full-modules/mount_modules.sh index afa617e7..49690b8a 100644 --- a/dracut/full-modules/mount_modules.sh +++ b/dracut/full-modules/mount_modules.sh @@ -11,7 +11,7 @@ if ! [ -d "$NEWROOT/lib/modules/$kver/kernel" ]; then # Mount only `uname -r` subdirectory, to leave the rest of /lib/modules writable mkdir -p /tmp/modules - mount -n -t ext3 /dev/xvdd /tmp/modules + mount -r -n -t ext3 /dev/xvdd /tmp/modules if ! [ -d "$NEWROOT/lib/modules/$kver" ]; then mount "$NEWROOT" -o remount,rw mkdir -p "$NEWROOT/lib/modules/$kver" diff --git a/dracut/simple/init.sh b/dracut/simple/init.sh index 063cd4c1..a200288f 100644 --- a/dracut/simple/init.sh +++ b/dracut/simple/init.sh @@ -99,7 +99,7 @@ if ! [ -d "$NEWROOT/lib/modules/$kver/kernel" ]; then while ! [ -e /dev/xvdd ]; do sleep 0.1; done mkdir -p /tmp/modules - mount -n -t ext3 /dev/xvdd /tmp/modules + mount -r -n -t ext3 /dev/xvdd /tmp/modules if /sbin/modprobe overlay; then # if overlayfs is supported, use that to provide fully writable /lib/modules if ! [ -d "$NEWROOT/lib/.modules_work" ]; then From efa8e2d1f20b5ba3e1aff7aa9270c644987d096c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 27 Feb 2022 04:14:20 +0100 Subject: [PATCH 3/3] dracut: mount 'root' subvolume if rootfs is btrfs QubesOS/qubes-issues#7310 --- dracut/simple/init.sh | 9 +++++++-- dracut/simple/module-setup.sh | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dracut/simple/init.sh b/dracut/simple/init.sh index a200288f..0e318cac 100644 --- a/dracut/simple/init.sh +++ b/dracut/simple/init.sh @@ -87,10 +87,15 @@ EOF echo Qubes: done. fi -/sbin/modprobe ext4 +rootfs_type=$(blkid --output value --match-tag TYPE /dev/mapper/dmroot) +/sbin/modprobe "$rootfs_type" mkdir -p /sysroot -mount /dev/mapper/dmroot /sysroot -o rw +if [ "$rootfs_type" = "btrfs" ]; then + mount /dev/mapper/dmroot /sysroot -o rw,subvol=root +else + mount /dev/mapper/dmroot /sysroot -o rw +fi NEWROOT=/sysroot kver="`uname -r`" diff --git a/dracut/simple/module-setup.sh b/dracut/simple/module-setup.sh index 2dd6d1f9..8f0413c7 100644 --- a/dracut/simple/module-setup.sh +++ b/dracut/simple/module-setup.sh @@ -23,6 +23,7 @@ install() { modprobe \ ln \ switch_root \ + blkid \ mount \ umount \ mkdir \