URL: <https://savannah.gnu.org/bugs/?63784>
Summary: grub-mkconfig generates invalid code that passes grub-script-check when / is ZFS and there is no initrd Project: GNU GRUB Submitter: arsen Submitted: Fri 10 Feb 2023 09:33:49 PM CET Category: Configuration Severity: Major Priority: 5 - Normal Item Group: Software Error Status: None Privacy: Public Assigned to: None Originator Name: Originator Email: Open/Closed: Open Release: 2.02~rc1 Release: Discussion Lock: Any Reproducibility: Every Time Planned Release: None _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Fri 10 Feb 2023 09:33:49 PM CET By: Arsen Arsenović <arsen> 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. _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?63784> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/