Using a small ufs partition you have the flexibility to boot almost anything.
How.
Create a small ufs partition.
This creates a new device.
Format to ufs:
mount the DEVICE,
Copy over the /boot folder
Now edit the /mnt/bootpartition/boot/loader.conf file.
Three settings are important.
The partition where to boot from e.g., (the loader is intelligent so it can mostly be omited)
The default device to load the kernel from e.g.,
The root partition to mount, e.g. for booting on zpool MYZPOOL
When you load a kernel not located on the bootpartition the bootpartion itself does not need to have kernel.
So you can
Done
The freebsd bootloader resided on this bootpartition can now very easily be loaded via linux-grub using chainloading. For instance if the freebsd bootpartition is the first partition of the first disk with gpt,
Edit on the linux system /etc/grub.d/40_custom and add,
How.
Create a small ufs partition.
Code:
gpart add -t freebsd-ufs -a 4k -s SIZE -l LABEL GEOM
Format to ufs:
Code:
newfs -O 2 -U -j -L VOLNAME DEVICE
mount the DEVICE,
Code:
mkdir /mnt/bootpartition
mount DEVICE /mnt/bootpartition
Copy over the /boot folder
Code:
cp -axfvR /boot /mnt/bootpartition
Now edit the /mnt/bootpartition/boot/loader.conf file.
Three settings are important.
The partition where to boot from e.g., (the loader is intelligent so it can mostly be omited)
Code:
loaddev="disk2p9:"
The default device to load the kernel from e.g.,
Code:
currdev="zfs:MYZPOOL/ROOT/default:"
The root partition to mount, e.g. for booting on zpool MYZPOOL
Code:
vfs.root.mountfrom="zfs:MYZPOOL/ROOT/default"
When you load a kernel not located on the bootpartition the bootpartion itself does not need to have kernel.
So you can
Code:
rm -vfR /mnt/bootpartition/kernel
rm -vfR /mnt/bootpartition/kernel.old
Done
Code:
umount /mnt/bootpartition
The freebsd bootloader resided on this bootpartition can now very easily be loaded via linux-grub using chainloading. For instance if the freebsd bootpartition is the first partition of the first disk with gpt,
Edit on the linux system /etc/grub.d/40_custom and add,
Code:
menuentry "FreeBSD" {
insmod part_bsd
insmod part_gpt
insmod part_msdos
insmod ufs2
insmod chain
root=(hd0,gpt1)
kfreebsd /boot/loader
}
Code:
update-grub