]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix: search for btrfs devices from actual mount poiont
authorKairui Song <kasong@redhat.com>
Thu, 22 Apr 2021 14:04:37 +0000 (22:04 +0800)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 26 Apr 2021 11:41:15 +0000 (13:41 +0200)
Currently when dracut search for btrfs device used for initramfs, it
assumes the mount points passed in with "--mount" are all mounted with
given mount path. If user want the device to be mounted to a different
location in initramfs, this will not be true.

eg. with "--mount '/dev/mapper/vol /sysroot btrfs rw,relatime,subvolid=256,subvol=/root'"
and having '/dev/mapper/vol' currently mounted on '/', will raise an
error:
    ERROR: cannot access '/sysroot': No such file or directory

So search for actual mount point of given device.

Signed-off-by: Kairui Song <kasong@redhat.com>
dracut.sh

index d72ac7fab1387d985a42721b4ee26c9f2927a3e6..1510486be56a0bc3db1baaff3eab1de47d7a4389 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1419,8 +1419,10 @@ for line in "${fstab_lines[@]}"; do
     esac
     [ -z "$dev" ] && dwarn "Bad fstab entry $*" && continue
     if [[ $3 == btrfs ]]; then
-        for i in $(btrfs_devs "$2"); do
-            push_host_devs "$i"
+        for mp in $(findmnt --source "$1" -o TARGET -n); do
+            for i in $(btrfs_devs "$mp"); do
+                push_host_devs "$i"
+            done
         done
     fi
     push_host_devs "$dev"