From d3444961eec5b7453026985b956c6b216d038a47 Mon Sep 17 00:00:00 2001 From: mkocustos Date: Mon, 24 Aug 2026 13:40:11 +0200 Subject: [PATCH] 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 --- 41_snapshots-btrfs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index f7d2bd6..20e7baa 100755 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -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