URL: <https://savannah.gnu.org/bugs/?59614>
Summary: grub-mkconfig on ZFS root result has invalid root=ZFS= value Project: GNU GRUB Submitted by: 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 Originator Email: c...@compusleuth.com Open/Closed: Open Release: Release: other Discussion Lock: Any Reproducibility: Every Time Planned Release: None _______________________________________________________ Details: 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. _______________________________________________________ File Attachments: ------------------------------------------------------- Date: Thu 03 Dec 2020 08:55:13 PM UTC Name: grub-mkconfig.log Size: 17KiB By: csleuth7 Example grub-mkconfig log <http://savannah.gnu.org/bugs/download.php?file_id=50393> _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?59614> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/