mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-10-20 02:42:03 +08:00
fix: empty fs_uuid on multi-device Btrfs (#440)
On a multi-device Btrfs filesystem `grub-probe --target=device /` prints
one device per line (e.g. /dev/vda3 and /dev/vdb). The whole multi-line
result was then passed to `grub-probe --device "${root_device}"
--target=fs_uuid`, which cannot handle several devices at once and
returns an empty string. The blkid fallback fails for the same reason,
so grub-btrfs aborts with "Cannot determine UUID".
Pipe the device probe through `head -n1` and keep only the first member
device. Every member of a Btrfs pool reports the same pool-wide fs UUID,
so the first device is sufficient. For single-device setups `head -n1`
is a no-op, so existing configurations are unaffected.
The same one-line-per-device behaviour applies to a /boot that lives on
a multi-device Btrfs, so the identical guard is added to boot_device.
Closes #412
Refs #425
This commit is contained in:
+5
-2
@@ -120,7 +120,10 @@ fi
|
||||
# -----------------------------------------------------------
|
||||
|
||||
# ---------- Root partition ----------
|
||||
root_device="$(${grub_probe} --target=device /)" # e.g. /dev/mapper/enc
|
||||
# head -n1: on a multi-device Btrfs, grub-probe prints one device per line.
|
||||
# Passing all of them to --device makes the fs_uuid probe return empty, so
|
||||
# keep only the first device (any member yields the pool-wide fs UUID).
|
||||
root_device="$(${grub_probe} --target=device / | head -n1)" # e.g. /dev/mapper/enc
|
||||
root_uuid="$(${grub_probe} --device "${root_device}" --target=fs_uuid 2>/dev/null)" || true
|
||||
|
||||
# Fallback when grub-probe fails (encrypted container, detached header…)
|
||||
@@ -135,7 +138,7 @@ root_uuid_subvolume="$(btrfs subvolume show / 2>/dev/null | \
|
||||
[ -z "$root_uuid_subvolume" ] && print_error "UUID of the root subvolume is not available"
|
||||
|
||||
# ---------- Boot partition ----------
|
||||
boot_device="$(${grub_probe} --target=device "${boot_directory}")" # e.g. /dev/sdb1
|
||||
boot_device="$(${grub_probe} --target=device "${boot_directory}" | head -n1)" # e.g. /dev/sdb1; head -n1: see root_device above (multi-device Btrfs)
|
||||
boot_uuid="$(${grub_probe} --device "${boot_device}" --target=fs_uuid 2>/dev/null)" || true
|
||||
|
||||
# Fallback for boot UUID
|
||||
|
||||
Reference in New Issue
Block a user