While I know everyone is probably waiting impatiently for my Fortran follow-up (I assure you all, I do have a working Fortran-based web application development framework – I just want to pretty it up a bit more <grin>), I thought I’d take a moment and diverge to talk about something I’m doing to help a fellow BSD aficionado out.
I’m in the process of standing up a BSD Users Group (BUG) in Indianapolis, IN (https://indybug.org) and in the process, met someone who was interested in dual booting a BSD and Linux on his HP laptop. In the past, I cheated with my Thinkpad x220 (which is now an x230 but that’s another story) by just using two drives and leveraging the boot menu to decide which one to boot. My primary SSD is OpenBSD-current and my m.SATA drive runs Arch for those times that I need something from the Linux world.
Well, this individual only has the ability to have a single drive in his laptop and would like to do the hard thing of dual booting. Also, it turns out this is a UEFI machine. Given that, I decided to roll up my sleeves and see what I could make happen. Since we have EFI support in OpenBSD 6.0 now, I thought I’d give it a whirl in a Virtual Machine under VMWare Fusion on my Mac.
First things first, I needed to figure out how to set up a UEFI VM. There were no obvious checkboxes to be found in the UI so, after some Googling, I found out that I just needed to add a line to the *.vmx file that contains the settings for the VM. I created a generic 64-bit VM with 2 cores, a 40 GB IDE drive and 2GB of RAM, added firmware = “efi” to the VMX file and fired it up to see what happens. Sure enough, I got an EFI boot screen from VMWare instead of the traditional BIOS one. Looks like that first step was easier than I thought.
Next, I downloaded the OpenBSD 6.0 install60.iso image and booted. No joy. I fiddled around with it for some time and was unable to boot that image from the EFI version of VMWare Fusion. Given that there is more than one way to skin a cat, I downloaded the latest Ubuntu 16.04 desktop ISO and was able to successfully boot that. Therefore, I decided I’d install Ubuntu first and then layer on the OpenBSD install from that.
The only non default settings I chose were:
- Install 3rd party software
- Installation type of “something else” so I could control the partitioning
- I created a 64MB EFI partition at the front of the disk
- Next, I created a 20GB primary partition at the beginning of the space, mounted as the root (/) filesystem
- I then added a 4096MB swap partition for Ubuntu
- Finally, I used the rest of the free space to create a Reserved BIOS Boot Area
FAT32partition that was not associated with a mount point – this is where I will be installing OpenBSD You will get a warning about the FAT32 partition not being used and that’s fine. We don’t want Linux to use it. That will be where we’ll install OpenBSD If you are asked about “forcing the system to be UEFI only” that’s what you want to do. Remember, our goal is to create a UEFI dual booting system.
- Everything else should be the defaults. Just create your user and sit back and wait for the install to finish.
So I got that done and got ready to boot off of the OpenBSD installation ISO. And that’s when it hit me. Nothing has changed since I tried to boot off of it last time. Doh! OK, so I downloaded the install60.fs file and dd’ed it to a USB drive, mapped the USB drive to the VM and rebooted. Hitting <ESC> quickly and repeatedly, I ended up at the UEFI boot device selection screen in VMWare and was able to boot off of the USB drive. So I ended up at the initial install prompt.
I mashed through the defaults in the OpenBSD installer until I got to the disk partitioning. Since I told VMWare to make my hard drive an IDE one, I knew I was playing around with wd0 and not sd0 (my USB key). I dumped into fdisk by selecting to (E)dit the partition scheme and saw my setup from Linux. First was the EFI partition (I am guessing I’ll have to copy my bootx64.efi file to that at some point), second was the Linux etx4 partition, third was my Linux swap partition and fourth was a weird looking one that is the “Reserved BIOS Boot” partition. That’s the one I’ll fiddle with.
Issuing the command “edit 3” allowed me to fiddle with that partition #3 (remember, we start counting at zero). I set it’s type to “A6” (OpenBSD) and then took the defaults with the exception of naming it “OpenBSD”. A quick “write” followed by a “quit” allowed me to update my new partition and get back to the installer.
I took the (a)uto layout for the filesystem setup and let the installer create all of the filesystems. Once that was done, I continued mashing defaults for the rest of the install and just let it do a full install of everything (including X) on the system with the files coming from the USB drive. When I got dumped to the prompt at the end, that’s where I knew I needed to play around a bit.
I mounted the EFI partition (mount /mnt /dev/wd0i) and poked around. It looks like the OpenBSD installer already created an /EFI/BOOT folder and stuck our boot loaders in it. This might mean I can just reboot from the hard drive and it will just work. I’ll give it a shot and see. Sure enough, mashing <ESC> at the boot screen allowed me to choose between Ubuntu (the default) and an unlabeled hot mess that turned out to be OpenBSD. Now I’m going to push the envelope and try to get rEFInd on this thing to have a pretty boot menu.
I rebooted to Ubuntu and hit the rEFInd web page so I could download the Linux installer. I installed the .deb file and the ran “sudo refind-install”. It installed just fine. I rebooted and sure enough I could switch between Ubuntu and a weird icon in the middle that turned out to be OpenBSD.
I guess I have achieved my goal of dual booting Linux and OpenBSD on a UEFI install. Now to see if my new friend can do the same by following this.