bugGNU GRUB - Bugs: bug #63784, grub-mkconfig generates invalid...

 
 

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

bug #63784: grub-mkconfig generates invalid code that passes grub-script-check when / is ZFS and there is no initrd

Submitter:  Arsen Arsenović <arsen>
Submitted:  Fri 10 Feb 2023 08:33:49 PM UTC
   
 
Category:  Configuration Severity:  Major
Priority:  5 - Normal Item Group:  Software Error
Status:  None Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Open Release:  2.02~rc1
Release:  Reproducibility:  Every Time
Planned Release:  None

Fri 10 Feb 2023 08:33:49 PM UTC, original submission:  

Note: I'm actually on 2.06.  This release isn't listed on the submit page, though.

If / is ZFS and there's no initrd, a rather peculiar sequences of failures happens.
Let's suppose the following:


~$ GRUB_DEVICE="`grub-probe --target device /`"
~$ echo "$GRUB_DEVICE"  # Note the newline.  This becomes problematic later.
/dev/nvme0n1p1
/dev/sda1
~$ grub-probe --device $GRUB_DEVICE --target=fs
grub-probe: warning: disk does not exist, so falling back to partition device /dev/nvme0n1p1.
grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1.
grub-probe: warning: disk does not exist, so falling back to partition device /dev/nvme0n1p1.
grub-probe: warning: disk does not exist, so falling back to partition device /dev/nvme0n1p1.
grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1.
grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1.
grub-probe: error: disk `hostdisk//dev/nvme0n1p1' not found.
~ 1 $ # The above results in a GRUB_FS=unknown, replaced by zfs.


Later, in 10_linux, the following block replaces the root device with "$GRUB_DEVICE" from above:


  if test -z "${initramfs}" && test -z "${initrd_real}" ; then
    # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs.  Since there's
    # no initrd or builtin initramfs, it can't work here.
    if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
        || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then

        linux_root_device_thisversion=${GRUB_DEVICE}
    else
        linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID}
    fi
  fi


This results in the following menuentry:


        menuentry 'Gentoo GNU/Linux, with Linux 6.1.8-gentoo-dist' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.1.8-gentoo-dist-advanced-/dev/nvme0n1p1_/dev/sda1' {
                load_video
                set gfxpayload=keep
                insmod gzio
                insmod part_gpt
                insmod ext2
                set root='hd1,gpt2'
                if [ x$feature_platform_search_hint = xy ]; then
                 search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2  2b360390-ecee-4481-8e15-5d440e562863
                else
                 search --no-floppy --fs-uuid --set=root 2b360390-ecee-4481-8e15-5d440e562863
                fi
                echo        'Loading Linux 6.1.8-gentoo-dist ...'
                linux        /vmlinuz-6.1.8-gentoo-dist root=/dev/nvme0n1p1
        /dev/sda1 ro console=tty12 splash quiet
        }


In general, 10_linux (and presumably others) seem unprepared for odd GRUB_DEVICE values.

I'm unsure what a correct, or even decent, fix here is.. perhaps failing when GRUB_DEVICE is determined to be more than one device?  While that is, of course, an error while running mkconfig, it's presumably better to an unbootable system.
In that case, the user could specify their root device manually, maybe?

Thanks in advance, have a lovely day.

Arsen Arsenović <arsen>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by arsen (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-269c.
    Corresponding source code