|
Harald Hoyer |
99c743 |
From 811c814677b83874fb631f6c07576765303b615a Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
99c743 |
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
|
|
Harald Hoyer |
99c743 |
<congdanhqx@gmail.com>
|
|
Harald Hoyer |
99c743 |
Date: Sat, 3 Oct 2020 14:23:26 +0700
|
|
Harald Hoyer |
99c743 |
Subject: [PATCH] rootfs-block: only write root argument for block device
|
|
Harald Hoyer |
99c743 |
MIME-Version: 1.0
|
|
Harald Hoyer |
99c743 |
Content-Type: text/plain; charset=UTF-8
|
|
Harald Hoyer |
99c743 |
Content-Transfer-Encoding: 8bit
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
Some filesystem (e.g. ZFS, and btrfs subvolumes) don't use block
|
|
Harald Hoyer |
99c743 |
devices. Should they be mounted as `/`, `find_root_block_device`
|
|
Harald Hoyer |
99c743 |
yields nothing, hence dracut will append this problematic argument
|
|
Harald Hoyer |
99c743 |
to kernel cmdline:
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
root=/dev/block
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
On a machine that employ root ZFS on LUKS, which was setup with
|
|
Harald Hoyer |
99c743 |
an OpenPGP-encrypted key file, this argument renders that machine
|
|
Harald Hoyer |
99c743 |
unbootable. Remove that `root=/dev/block` manually could boot the
|
|
Harald Hoyer |
99c743 |
machine.
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
Let check if that device is a block device before write down `root`
|
|
Harald Hoyer |
99c743 |
argument. This is consistent with the check for block device in
|
|
Harald Hoyer |
99c743 |
`find_block_device`.
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
|
|
Harald Hoyer |
99c743 |
---
|
|
Harald Hoyer |
99c743 |
modules.d/95rootfs-block/module-setup.sh | 25 +++++++++++++++----------
|
|
Harald Hoyer |
99c743 |
1 file changed, 15 insertions(+), 10 deletions(-)
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
diff --git a/modules.d/95rootfs-block/module-setup.sh b/modules.d/95rootfs-block/module-setup.sh
|
|
Harald Hoyer |
99c743 |
index 987373b4..c3982207 100755
|
|
Harald Hoyer |
99c743 |
--- a/modules.d/95rootfs-block/module-setup.sh
|
|
Harald Hoyer |
99c743 |
+++ b/modules.d/95rootfs-block/module-setup.sh
|
|
Harald Hoyer |
99c743 |
@@ -30,7 +30,8 @@ cmdline_journal() {
|
|
Harald Hoyer |
99c743 |
}
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
cmdline_rootfs() {
|
|
Harald Hoyer |
99c743 |
- local _dev=/dev/block/$(find_root_block_device)
|
|
Harald Hoyer |
99c743 |
+ local _block=$(find_root_block_device)
|
|
Harald Hoyer |
99c743 |
+ local _dev=/dev/block/$_block
|
|
Harald Hoyer |
99c743 |
local _fstype _flags _subvol
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
# "--no-hostonly-default-device" can result in empty root_devs
|
|
Harald Hoyer |
99c743 |
@@ -38,17 +39,21 @@ cmdline_rootfs() {
|
|
Harald Hoyer |
99c743 |
return
|
|
Harald Hoyer |
99c743 |
fi
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
- if [ -e $_dev ]; then
|
|
Harald Hoyer |
99c743 |
+ if [ -n "$_block" -a -b $_dev ]; then
|
|
Harald Hoyer |
99c743 |
printf " root=%s" "$(shorten_persistent_dev "$(get_persistent_dev "$_dev")")"
|
|
Harald Hoyer |
99c743 |
- _fstype="$(find_mp_fstype /)"
|
|
Harald Hoyer |
99c743 |
- _flags="$(find_mp_fsopts /)"
|
|
Harald Hoyer |
99c743 |
+ fi
|
|
Harald Hoyer |
99c743 |
+ _fstype="$(find_mp_fstype /)"
|
|
Harald Hoyer |
99c743 |
+ _flags="$(find_mp_fsopts /)"
|
|
Harald Hoyer |
99c743 |
+ if [ -n "$_fstype" ]; then
|
|
Harald Hoyer |
99c743 |
printf " rootfstype=%s" "$_fstype"
|
|
Harald Hoyer |
99c743 |
- if [[ $use_fstab != yes ]] && [[ $_fstype = btrfs ]]; then
|
|
Harald Hoyer |
99c743 |
- _subvol=$(findmnt -e -v -n -o FSROOT --target /) \
|
|
Harald Hoyer |
99c743 |
- && _subvol=${_subvol#/}
|
|
Harald Hoyer |
99c743 |
- _flags="$_flags,${_subvol:+subvol=$_subvol}"
|
|
Harald Hoyer |
99c743 |
- fi
|
|
Harald Hoyer |
99c743 |
- printf " rootflags=%s" "${_flags#,}"
|
|
Harald Hoyer |
99c743 |
+ fi
|
|
Harald Hoyer |
99c743 |
+ if [[ $use_fstab != yes ]] && [[ $_fstype = btrfs ]]; then
|
|
Harald Hoyer |
99c743 |
+ _subvol=$(findmnt -e -v -n -o FSROOT --target /) \
|
|
Harald Hoyer |
99c743 |
+ && _subvol=${_subvol#/}
|
|
Harald Hoyer |
99c743 |
+ _flags="$_flags${_subvol:+,subvol=$_subvol}"
|
|
Harald Hoyer |
99c743 |
+ fi
|
|
Harald Hoyer |
99c743 |
+ if [ -n "$_flags" ]; then
|
|
Harald Hoyer |
99c743 |
+ printf " rootflags=%s" "$_flags"
|
|
Harald Hoyer |
99c743 |
fi
|
|
Harald Hoyer |
99c743 |
}
|
|
Harald Hoyer |
99c743 |
|