bugGNU GRUB - Bugs: bug #59614, grub-mkconfig on ZFS root result...

 
 

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

bug #59614: grub-mkconfig on ZFS root result has invalid root=ZFS= value

Submitted by:  Todd Markley <csleuth7>
Submitted on:  Thu 03 Dec 2020 08:55:13 PM UTC  
 
Category:  Configuration Severity:  Major
Priority:  5 - Normal Item Group:  Software Error
Status:  None Privacy:  Public
Assigned to:  None Originator Name:  Todd
Open/Closed:  Open Release: 
Release:  other Reproducibility:  Every Time
Planned Release:  None

Tue 12 Jan 2021 07:54:02 AM UTC, comment #5: 

I didn't notice the proposed fix. I checked that it works for me. Works even for the pool backed by multiple physical devices.

Ivan Volosyuk <ivanrt>
Tue 12 Jan 2021 07:43:29 AM UTC, comment #4: 

I hit the same issue after migrating to ZFS 2.0.0

In my debugging I noticed that "grub-probe --device ${GRUB_DEVICE} --target=fs_label" reports "unknown filesystem".

$ debug=all grub-probe -v /
....
grub-core/osdep/hostdisk.c:396: reusing open device `/dev/sdb4'
grub-core/fs/zfs/zfs.c:2110: zap: name = org.illumos:lz4_compress, value = 1, cd = 0
grub-core/fs/zfs/zfs.c:2110: zap: name = com.joyent:multi_vdev_crash_dump, value = 0, cd = 0
grub-core/fs/zfs/zfs.c:2110: zap: name = com.delphix:hole_birth, value = 1, cd = 0
grub-core/fs/zfs/zfs.c:2110: zap: name = com.delphix:extensible_dataset, value = 45, cd = 0
grub-core/fs/zfs/zfs.c:2110: zap: name = com.delphix:embedded_data, value = 1, cd = 0
grub-core/fs/zfs/zfs.c:2110: zap: name = org.open-zfs:large_blocks, value = 1c, cd = 0
grub-core/fs/zfs/zfs.c:2110: zap: name = org.zfsonlinux:large_dnode, value = 22, cd = 0
grub-core/kern/disk.c:295: Closing `hostdisk//dev/sdb'.
grub-core/kern/fs.c:78: zfs detection failed.
...

The failure happens at grub-core/fs/zfs/zfs.c:
  grub_error (GRUB_ERR_BAD_FS, "Unsupported features in pool");

Looks like my root pool contains zfs features unsupported by grub. Strictly speaking, this is irrelevant for grub as my /boot is on a separate fat32 partition for efi64 boot method. There is no need to perform full compatibility checks just to output fs_label and construct root=ZFS=rpool/ROOT kernel argument.

I would say for /boot 'bpool' strict checks are need to be able to load kernel at boot time, but for / 'rpool' which is only used by the loaded kernel the compatibility checks can be omitted.

Ivan Volosyuk <ivanrt>
Fri 18 Dec 2020 02:33:45 AM UTC, comment #3: 

I submitted https://lists.gnu.org/archive/html/grub-devel/2020-12/msg00239.html to the mailing list which should fix your issue as well.

Doug Goldstein <cardoe>
Wed 16 Dec 2020 05:03:45 AM UTC, comment #2: 

Looking at other items in the tracker I believe this is the same issue as bug #58555.

Doug Goldstein <cardoe>
Wed 16 Dec 2020 05:00:25 AM UTC, comment #1: 

I believe the issue is with grub-probe not supporting the filesystem features that Ubuntu is using. You can see it mentioned in the OpenZFS Ubuntu 20.04 Guide under Step 2 Item 7.

I think there should be a cleaner approach that always uses zfs instead of grub-probe for best compatibility. Just like 10_linux_zfs does.

Doug Goldstein <cardoe>
Thu 03 Dec 2020 08:55:13 PM UTC, original submission:  

This problem was identified using Ubuntu 20.04.1 and selecting the ZFS root option during installation. The grub version is 2.04-1ubuntu26.7

Installation will boot, but after any install or upgrade that requires touching the grub configuration the resulting grub.cfg has an invalid root=ZFS=/ROOT/ubuntu_xxxxxx value which is missing the zpool name, the correct value should look like this:
root=ZFS=rpool/ROOT/ubuntu_xxxxxx

The root cause seems to be in these two files:
/etc/grub.d/10_linux           (line 137)
/etc/grub.d/20_linux_xen       (line 88)

Which contain a line that sets the value of ${rpool} like this:

rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`

This is setting ${rpool} to NULL since the grub-probe fails:
root@stream:/etc/grub.d# /usr/sbin/grub-probe --device /dev/nvme0n1p4 --target=fs_label
/usr/sbin/grub-probe: error: unknown filesystem.

Since this rpool= line should only be run when the root filesystem is ZFS, I would expect this will always fail on every system with a ZFS root.

This is my hack test fix, (applied to both files):

------------------------------
        rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
        if [ "${rpool}" = "" ]; then
           rpool=`/usr/sbin/zfs list | awk '{if( $5 == "/" ) { print $1; }}' | sed "s:/.*::" | head -1`
        fi
        bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
        LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"

------------------------------

This test resolved the problem and worked on my three test systems:
Ubuntu 20.04 ZFS root
Ubuntu 20.04 ZFS root with Xen installed
Ubuntu 20.04 xfs root

Although this worked, I expect a better fix would just change the rpool=`` line with a command that works. My example fix assumed Ubuntu 20.04 was installed with ZFS, and I did not consider any other configurations. I don't expect details about my hardware would affect this issue, but two used ASRock+AMD and the 3rd was an old Lenovo laptop.

Todd Markley <csleuth7>

 

Attached Files
file #50395:  grub2.patch added by csleuth7 (1KiB - text/x-patch - cd /etc/grub.d; sudo patch < /tmp/grub2.patch)
file #50393:  grub-mkconfig.log added by csleuth7 (17KiB - text/x-log - Example grub-mkconfig log)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ivanrt (Posted a comment)
  • -email is unavailable- added by cardoe (Posted a comment)
  • -email is unavailable- added by oxygen_cat
  • -email is unavailable- added by csleuth7 (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-12-09 oxygen_cat Carbon-Copy- => Added oxygen_cat
    2020-12-09 oxygen_cat Carbon-CopyRemoved -email is unavailable- => -
    2020-12-09 oxygen_cat Carbon-Copy- => Added oxygen-cat@protonmail.com
    2020-12-03 csleuth7 Attached File- => Added grub2.patch, #50395
    2020-12-03 csleuth7 Attached File- => Added grub-mkconfig.log, #50393

    Back to the top


    Powered by Savane 3.6