From: Đoàn Trần Công Danh Date: Sat, 3 Oct 2020 07:23:26 +0000 (+0700) Subject: rootfs-block: only write root argument for block device X-Git-Tag: 051~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=811c814677b83874fb631f6c07576765303b615a;p=thirdparty%2Fdracut.git rootfs-block: only write root argument for block device Some filesystem (e.g. ZFS, and btrfs subvolumes) don't use block devices. Should they be mounted as `/`, `find_root_block_device` yields nothing, hence dracut will append this problematic argument to kernel cmdline: root=/dev/block On a machine that employ root ZFS on LUKS, which was setup with an OpenPGP-encrypted key file, this argument renders that machine unbootable. Remove that `root=/dev/block` manually could boot the machine. Let check if that device is a block device before write down `root` argument. This is consistent with the check for block device in `find_block_device`. Signed-off-by: Đoàn Trần Công Danh --- diff --git a/modules.d/95rootfs-block/module-setup.sh b/modules.d/95rootfs-block/module-setup.sh index 987373b4f..c3982207d 100755 --- a/modules.d/95rootfs-block/module-setup.sh +++ b/modules.d/95rootfs-block/module-setup.sh @@ -30,7 +30,8 @@ cmdline_journal() { } cmdline_rootfs() { - local _dev=/dev/block/$(find_root_block_device) + local _block=$(find_root_block_device) + local _dev=/dev/block/$_block local _fstype _flags _subvol # "--no-hostonly-default-device" can result in empty root_devs @@ -38,17 +39,21 @@ cmdline_rootfs() { return fi - if [ -e $_dev ]; then + if [ -n "$_block" -a -b $_dev ]; then printf " root=%s" "$(shorten_persistent_dev "$(get_persistent_dev "$_dev")")" - _fstype="$(find_mp_fstype /)" - _flags="$(find_mp_fsopts /)" + fi + _fstype="$(find_mp_fstype /)" + _flags="$(find_mp_fsopts /)" + if [ -n "$_fstype" ]; then printf " rootfstype=%s" "$_fstype" - if [[ $use_fstab != yes ]] && [[ $_fstype = btrfs ]]; then - _subvol=$(findmnt -e -v -n -o FSROOT --target /) \ - && _subvol=${_subvol#/} - _flags="$_flags,${_subvol:+subvol=$_subvol}" - fi - printf " rootflags=%s" "${_flags#,}" + fi + if [[ $use_fstab != yes ]] && [[ $_fstype = btrfs ]]; then + _subvol=$(findmnt -e -v -n -o FSROOT --target /) \ + && _subvol=${_subvol#/} + _flags="$_flags${_subvol:+,subvol=$_subvol}" + fi + if [ -n "$_flags" ]; then + printf " rootflags=%s" "$_flags" fi }