how do I boot freebsd root on zfs from linux's grub

Hi,

This is a crossover question because it involves the grub boot loader from Linux and FreeBSD's kernel. I have successfully booted into FreeBSD from grub, but the process produces an environment that is not 100% consistent (upgrading using freebsd-update(8) has an issue, described below). My question as stated above is how do I boot into FreeBSD from the Linux installed grub bootloader... properly?

Here is the current configuration:
FreeBSD 11.2 running on a T430 not using UEFI/EFI, SSD is a GPT disk split into five partitions - 128K boot, 17G freebsd-swap, 63G ZFS, 137G linux-ext4, and 17G linux-swap. the ZFS partition is further split up, but that's not particularly relevant here.

After installing FreeBSD on the system, the system boots to FreeBSD and all is well with the world. After installing Linux on the system the system boots to Linux and if you're into that sort of thing, all is well with the world... but the bootloader knows nothing about FreeBSD anymore. So, I added the following file:

Code:
/etc/grub.d/40_custom 
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "FreeBSD" --class freebsd --class bsd --class os {
savedefault
insmod zfs
insmod part_gpt
search -s -l zroot
kfreebsd /ROOT/default/@/boot/kernel/kernel
kfreebsd_module_elf /ROOT/default/@/boot/kernel/opensolaris.ko
kfreebsd_module_elf /ROOT/default/@/boot/kernel/zfs.ko
kfreebsd_module /ROOT/default/@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
set kFreeBSD.vfs.root.mountfrom=zfs:zroot/ROOT/default
set kFreeBSD.hw.psm.synaptics_support=1
}

after updating grub, the system will boot FreeBSD or Linux and all appears to be well with the world, switching back and forth at will.

However, when I later attempt to update the installation using freebsd-update install, things go awry, the updater tries to copy the world into /boot/kernel.old and has a bunch of cross-device linkage issues. After investigating a bit, it seems that the syctl for the kernel shows /kernel as the location of the kernel, rather than /boot/kernel/kernel, which is where it really is. If I set the sysctl and rerun the updater, it is successful, so it's not the end of the world. But it would appear that my grub configuration is somehow flawed.

So... what should it look like? Is there a better, more canonical approach to loading a root on ZFS kernel from grub?
 
Back
Top