Fix empty fs_uuid on multi-device Btrfs#440
Open
mkocustos wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a multi-device Btrfs filesystem,
grub-probe --target=device /prints one device per line, e.g.:The whole multi-line value is then passed to
grub-probe --device "${root_device}" --target=fs_uuid, which cannot handle several devices at once and returns an empty string. Theblkidfallback fails for the same reason (it gets a multi-line device argument), so41_snapshots-btrfsaborts with:This makes grub-btrfs unusable on any multi-device Btrfs (RAID0/1/10, single-profile with added devices, etc.). The affected line was introduced in #378.
Fix
Pipe the device probe through
head -n1and 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 setupshead -n1is a no-op, so existing configurations are unaffected.The identical one-line-per-device behaviour applies to a
/bootthat lives on a multi-device Btrfs, so the same guard is added toboot_devicefor consistency.Testing
Reproduced and verified on Fedora Server 43, root on a 2-device Btrfs (
/dev/vda3+/dev/vdb),/booton a separate single-device XFS partition. Before the fixgrub-mkconfigaborted with the "Cannot determine UUID" error; after the fix the correct fs UUID is resolved andgrub-btrfs.cfgis generated as expected.bash -npasses.