bugGNU GRUB - Bugs: bug #48228, grub-mkconfig assumes grub-probe...


You are not allowed to post comments on this tracker with your current authentication level.

bug #48228: grub-mkconfig assumes grub-probe will only produce 1 line of output, breaks with mirrored zfs volumes

Submitted by:  Will Rouesnel <wrouesnel>
Submitted on:  Tue 14 Jun 2016 11:49:58 PM UTC  
Category:  Booting Severity:  Major
Priority:  6 Item Group:  Software Error
Status:  None Privacy:  Public
Assigned to:  None Originator Name:  Will Rouesnel
Open/Closed:  Open Release: 
Release:  2.02~beta1 Reproducibility:  Every Time
Planned Release:  2.02

( Jump to the original submission)

Thu 31 May 2018 05:10:13 PM UTC, comment #7: 

This is an issue for btrfs volumes with multiple devices aswell.

# grub-probe --target=device /

will give two lines of output:

which causes grub-mkconfig to output a linebreak in the kernel cmdline aswell.
In case of btrfs, it's sufficient to trim the $GRUB_DEVICE after the first blank, don't know about zfs though.

Latest git (cda0a857dd7a27cd5d621747464bfe71e8727fff) does not fix this issue.

(file #44263)

Marcel Sackermann <m0gg>
Wed 26 Oct 2016 07:04:59 PM UTC, comment #6: 

i cannot right now as I'm not using that configuration any longer.

the information i provided should be ample to conclude that this is a bug.

spongman <spongman>
Wed 26 Oct 2016 04:38:48 PM UTC, comment #5: 

Please provide debug information I asked for.

Andrei Borzenkov <arvidjaar>
Project Member
Wed 26 Oct 2016 03:32:03 AM UTC, comment #4: 

I'm seeing the same issue - the grub-mkconfig is written entirely with the assumption that only one device is returned from grub-probe. which is not true in the case of multi-device zfs pools.

for example, for me 'grub-probe --target=device /' returns:

which completely breaks grub-mkconfig.

the 'head -n1' hack doesn't work for me, since this is a raidz pool which requires at least 4 out of the 5 devices to be passed to the 'grub-probe --target=fs' call in 10_linux in order for it to be able to discover the fs type.

IMO, grub-mkconfig needs to be rewritten in order to handle multiple-device roots. i'd recommend replacing all calls to 'grub-probe --device <device>' to 'grub-probe <path>'. obviously that's a rather large change that'll break a whole bunch of existing scripts.

Either that, or grub-mkconfig needs to detect the multiple device case and throw a not-supported error.

spongman <spongman>
Wed 29 Jun 2016 06:03:22 PM UTC, comment #3: 

Did you test upstream GIT? If root is zfs, we should get


so I do not see how you end up with ${GRUB_DEVICE}. Please add "set -x" at the top of /etc/grub.d/10_linux and attach trace output.

Andrei Borzenkov <arvidjaar>
Project Member
Wed 29 Jun 2016 04:53:29 PM UTC, comment #2: 

I've attached grub.cfg from a system with the following setup:

  pool: ssdpool
 state: ONLINE
status: The pool is formatted using a legacy on-disk format.  The pool can
still be used, but some features are unavailable.
action: Upgrade the pool using 'zpool upgrade'.  Once this is done, the
pool will no longer be accessible on software that does not support
feature flags.
  scan: scrub repaired 0 in 0h5m with 0 errors on Sat May 21 00:18:37 2016

NAME                                                     STATE     READ WRITE CKSUM
ssdpool                                                  ONLINE       0     0     0
  mirror-0                                               ONLINE       0     0     0
    ata-Samsung_SSD_850_EVO_250GB_S21MNXAG814168J-part1  ONLINE       0     0     0
    ata-Samsung_SSD_850_EVO_250GB_S21MNXAG814170W-part1  ONLINE       0     0     0

Both disks are root devices. I can boot from them successfully with the previously attached patches with update-grub.

The problem is all my linux stanzas end up looking like this:

echo 'Loading Linux 4.6.0-040600-generic ...'
linux /ROOT/mint-13@/boot/vmlinuz-4.6.0-040600-generic root=/dev/sdk1
/dev/sdj1 ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /ROOT/mint-13@/boot/initrd.img-4.6.0-040600-generic

The split newline in the root= is because grub-probe can and does output multiple lines. I've also had the same problem with cryptomount stanzas (and the same solution applies). In both cases, this is broken - this config will not boot through grub unless I edit the lines out.

(file #37624)

Will Rouesnel <wrouesnel>
Wed 15 Jun 2016 03:22:35 AM UTC, comment #1: 

Your patch is wrong - we need to know all devices to build full list of drivers. You do not say what exactly is broken in your case. One problem with multi-device filesystem was fixed in 2.02~beta3; please test with current GIT. If it does not work, attach bad grub.cfg.

Andrei Borzenkov <arvidjaar>
Project Member
Tue 14 Jun 2016 11:49:58 PM UTC, original submission:  

Using 2.02~beta2-36ubuntu3 and a ZFS root setup with mirrored, encrypted drives, I've had multiple problems with the grub-mkconfig script and libraries assuming that the output from grub-probe will only ever be a single line.

This leads to malformed set root= entries which break booting, malformed cryptomount entries etc.

The ideal solution would be to support generating something like the windows bootloader with "plex 2" when using a mirrored boot configuration in case one drive fails. As it stands for a workaround I've simply added `| sort | head -n1` pipes to the grub-probe commands to generate reproducible and correct output.

Will Rouesnel <wrouesnel>


Attached Files
file #44263:  mkconfig-out added by m0gg (71KiB - application/octet-stream - grub-mkconfig output with set -x)
file #37624:  grub.cfg added by wrouesnel (9KiB - application/octet-stream - grub.cfg showing the problem)
file #37478:  mkconfig.patch added by wrouesnel (2KiB - text/x-patch - Example patches for consistent behavior, probably not the right long-term solution.)
file #37479:  grub-mkconfig.patch added by wrouesnel (1KiB - text/x-patch - Example patches for consistent behavior, probably not the right long-term solution.)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by m0gg (Updated the item)
  • -email is unavailable- added by spongman (Posted a comment)
  • -email is unavailable- added by phcoder (Updated the item)
  • -email is unavailable- added by arvidjaar (Posted a comment)
  • -email is unavailable- added by wrouesnel (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-05-31 m0gg Attached File- => Added mkconfig-out, #44263
    2016-10-11 phcoder Priority5 - Normal => 6
        Planned ReleaseNone => 2.02
    2016-06-29 wrouesnel Attached File- => Added grub.cfg, #37624
    2016-06-14 wrouesnel Attached File- => Added mkconfig.patch, #37478
        Attached File- => Added grub-mkconfig.patch, #37479

    Back to the top

    Powered by Savane 3.6