grub-mkrelpath returns invalid zfs dataset -> initramfs: mount /root fails
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
grub2 (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
If zfs is used for boot, boot will fail because of bogus information returned by
/usr/bin/
# /usr/bin/
/ROOT/linux@
This leads to a bogus /boot/grub/grub.cfg because /etc/grub.
linux /ROOT/linux@
This in turn causes that initramfs to fail on boot:
...
+ wait_for_udev
+ command -v udevadm
+ udevadm settle
+ modprobe zfs zfs_autoimport_
+ ZFS_BOOTFS=
+ echo /ROOT/linux
+ sed -e s,/.*,,
+ ZFS_RPOOL=
+ delay=0
+ [ 0 -gt 0 ]
+ unset delay
+ zpool import -N
[ 10.922149] SPL: The /etc/hostid file is not found.
[ 10.927031] SPL: using hostid 0x00000000
+ ZFS_STDERR=cannot import '': no such pool available
+ ZFS_ERROR=1
+ [ 1 -ne 0 ]
+ panic Command: zpool import -N
Message: cannot import '': no such pool available
Error: 1
Manually import the root pool at the command prompt and then exit.
Hint: Try: zpool import -f -R / -N
Wrong hint BTW, but at least a hint: "zpool import; zpool import ${poolID}|rpool" fixes it.
Anyway, when continuing after an 'exit' it fails with:
...
+ zpool status -L
+ [ n != y ]
+ log_begin_msg Setting mountpoint=/ on ZFS filesystem /ROOT/linux
+ _log_msg Begin: Setting mountpoint=/ on ZFS filesystem /ROOT/linux ...
+ [ n = y ]
+ printf Begin: Setting mountpoint=/ on ZFS filesystem /ROOT/linux ...
Begin: Setting mountpoint=/ on ZFS filesystem /ROOT/linux ... + zfs set mountpoint=/ /ROOT/linux
+ ZFS_STDERR=cannot open '/ROOT/linux': invalid dataset name
+ [ n != y ]
+ log_end_msg
+ _log_msg done.\n
+ [ n = y ]
+ printf done.\n
done.
+ [ n != y ]
+ log_begin_msg Mounting ZFS filesystem /ROOT/linux
+ _log_msg Begin: Mounting ZFS filesystem /ROOT/linux ...
+ [ n = y ]
+ printf Begin: Mounting ZFS filesystem /ROOT/linux ...
Begin: Mounting ZFS filesystem /ROOT/linux ... + mount -t zfs -o zfsutil /ROOT/linux /root
+ ZFS_STDERR=
mount: mounting /ROOT/linux on /root failed: No such file or directory
+ ZFS_ERROR=1
+ [ n != y ]
+ log_end_msg
+ _log_msg done.\n
+ [ n = y ]
+ printf done.\n
done.
+ [ 1 -ne 0 ]
+ panic Command: mount -t zfs -o zfsutil /ROOT/linux /root
Message: filesystem 'ROOT/linux' cannot be mounted, unable to open the dataset
mount: mounting /ROOT/linux on /root failed: No such file or directory
Error: 1
Manually mount the root filesystem on /root and then exit.
A 'mount -t zfs -o zfsutil rpool/ROOT/linux /root' fixis it and after an 'exit' the system finally starts.
affects: | dmidecode (Ubuntu) → grub2 (Ubuntu) |
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
Not sure, why it is made that complicated. IMHO the only thing to know is the name or ID of the pool, that contains the / dataset. Then initramfs can import it w/o any problems and related scripts incl. grub-mkconfig & friends do not need to mangle anything: Via 'zpool get -H bootfs ${pool}' or with more recent zfs-utils via 'zpool get -H -o value bootfs ${pool}' one may obtain directly the name of the dataset to mount on /root - no need to mangle anything as well.