/DualBoot /X |
Goal
Dual boot FreeBSD 12.0-CURRENT r315864 and Ubuntu Linux (Zesty Zapus) 17.04 Final Beta in GRUB 2 on Lenovo Yoga 3 14 with UEFI.
Steps
It could be optimized.
- Create USB sticks with FreeBSD, Ubuntu and GParted.
- Set BIOS to try a UEFI boot first instead of Legacy.
- Boot GParted and create a new GPT partition table on the hard drive.
- Boot the Ubuntu Live USB and let it install itself. It should create an ESP and EXT4 partitions (Ubuntu will not create an ESP partition if you didn't set to try UEFI boot in BIOS).
- Boot GParted and resize the Ubuntu EXT4 partition to make some space for the FreeBSD installation. Do not format this space - it makes things easier for FreeBSD during auto detecting free partitions.
Boot the FreeBSD USB and choose an option for automatic UFS partitioning (I've not tried it yet with ZFS). Choose Partition instead of Entire Disk and the installer will figure out the rest for you. Write down the name of the partition with the EFI label (mine was called ada0p4).
Boot Ubuntu from your hard drive and add the following lines to /boot/grub/custom.cfg (the file has to be called like that):
menuentry "FreeBSD" { insmod part_gpt insmod fat insmod chain set root=(hd0,gptX) chainloader /efi/boot/BOOTx64.efi }
Change X to the partition number of your FreeBSD EFI partition (e.g. my partition was ada0p4 so set root=(hd0,gpt4) worked for me).
Done. You might need to hit the Escape key once when the screen turns Ubuntu-like purple for the first time after turning on the machine to access GRUB 2 as Ubuntu hides it by default. Alternatively, you might add the following lines to /boot/grub/custom.cfg:
set default="3" set timeout=5 set timeout_style=menu
References
See also
Working GRUB config for booting FreeBSD with UEFI (unix.stackexchange.com)
Dual boot FreeBSD 10 and Linux Mint 17 (tiggeron.blogspot.com)