Wednesday, May 31, 2023

Triple Booting in 2023: FreeBSD, Windows, and Ubuntu Linux

Before this evening, I don't think I had setup a dual boot system in more than 20 years. In that time I've run mostly MacOS X, FreeBSD, and Linux desktops, and run Windows and some other Unix variants through Parallels on the Mac. However, I recently purchased a Dell Precision 3260 Compact workstation and mounted it under the desk in my home office. I wanted a compact machine to re-aquaint myself with modern Linux/FreeBSD Desktop environment, have a non-Virtualized copy of Windows, and a PCIe expansion slot for GPU, data acquisition tinkering, etc, and I think this fits the bill nicely. UEFI firmware makes this much easier than the last time I did this, but I still wanted to take a few notes in case I have to do this again (on my next PC laptop, most likely):

Windows

I bought the workstation without an OS, but I was able to download the Windows 10 installation media, write it to a bootable USB key, and then transfer an extra copy of a full Windows 10 license I have for an unneeded Parallels virtual machine. I opted to give Windows the first full SSD then split the second SSD between FreeBSD and Linux, since they will mount large home directories from my NAS over NFS. Installation was straightforward, I downloaded a few drivers from the Dell website, then did the free upgrade to Windows 11. I created a 550MB EFI System partition in the Windows partition editor, and then let Windows create 100MB, 16MB, and 465GB parititions for the rest of the install.

FreeBSD

Second up was the FreeBSD install. I booted from a FreeBSD 14 memory stick and performed an install. The installer doesn't make it easy to split a disk with a ZFS partition between multiple operating systems. Rather than fiddle with it all manually, I opted for a UFS filesystem where I could specify half the ssd for FreeBSD and leave the remaining parts empty for the Linux install. The installer created a 260MB EFI partition, 233GB UFS root partition, and 8GB for swap. After a reboot I could boot into FreeBSD by pressing F12 and startup and manually selecting the second SSD to boot from, but the default would still boot into the Windows Boot Manager and load Windows 11.

Ubuntu Linux

Finally, I installed Ubuntu 22 LTS from a downloaded memory disk. The installer installed GRUB 2 and on first reboot it presented a menu with items for Windows Boot Manager and Ubuntu Linux, but no FreeBSD! I logged into Ubuntu and edited the /etc/grub.d/40_custom file to add the following:

  menuentry "FreeBSD" {
    set root=(hd1,1)
    chainloader (${root})/efi/boot/BOOTx64.efi
  }
  

Then ran the command sudo update-grub. The output shows that it finds the FreeBSD 14 partition but for some reason wasn't creating a menu item until I manually added the line above.

Conclusion

With this change, I now get a nice GRUB2 menu of FreeBSD, Linux, or Windows to boot into, just like I had with my noisy tower desktop computers with multiple hard disks of the late 1990s. This is a secondary PC to my primary Mac Pro desktop, but I am happy to get the flexibility to jump into other bare metal operating systems when needed.

Some things to follow up on:

  • FreeBSD's install could make it easier to install FreeBSD on ZFS on only part of the disk/ssd, like it does for UFS by just asking you how much total space you want to occupy then handling all the other details.
  • Ubuntu's GRUB2 bootloader doesn't include a menu item for FreeBSD even though it was able to detect the FreeBSD partition. It would be more user friendly if the default config files built the FreeBSD menu item without requiring the 4 lines above to be added.
  • The steps above created three EFI system partitions of various sizes. This was easiest but wastes a bit of disk space.

No comments: