After getting a new hard disk for my Lenovo X230 a fresh installation was required, so I decided to try UEFI dual boot installation of Fedora and OpenBSD on a single disk. This guide uses the builtin BIOS boot manager to not depend on chainloading OpenBSD via GRUB or an external EFI boot manager like rEFind.
First of all, enable UEFI Boot in BIOS Setup. Navigate to the the "Startup" tab and select 'UEFI Only'. CSM Support, which enables legacy support on top of UEFI is automatically disabled:
We start with installing Fedora 24. The installer supports UEFI and Fedora will even be bootable with UEFI Secure Boot, as it is using a signed shim loader.
Make sure to select "I will configure partitioning" and do not assign all of the disk to Fedora. There should be space left at the end. Fedora will automatically create a FAT formatted EFI system partition that is required for UEFI boot.
Fedora creates a traditional Master Boot Record (MBR) with a single partition that covers the whole disk to protect from legacy system seeing the disk as empty. In addition it creates a GPT partition table that contains the actual partitions. After Fedora is installed, the disk partitions should look like this:
Fedora uses efibootmgr to add a new boot option to the BIOS boot manager. That means there will be an entry "Fedora" in the boot device list in BIOS setup and in the boot menu that is reachable with F12 during boot. We will use efibootmgr later on to create a similar entry for OpenBSD.
I have used the latest released OpenBSD version 6.0 for this guide, UEFI is supported since version 5.9 there is support for UEFI boot. Depending on the installation medium you might need to temporarily enable legacy boot in BIOS setup for the installation process (for example for booting from CD-ROM or PXE).
Having successfully booted the installer and after selecting the installation disk, you will be presented with the following options:
Use (W)hole disk MBR, whole disk (G)PT or (E)dit? [whole] e
Make sure to select (E)dit. Otherwise the installer will directly wipe your GPT partition table and you have to start over. After selecting (E) you get a little text what the installer expects from you:
You will now create two GPT partitions. The first must have an id
of 'EF' and be large enough to contain the OpenBSD boot programs,
at least 960 blocks. The second must have an id of 'A6' and will
contain your OpenBSD data. Neither may overlap other partitions.
Inside the fdisk command, the 'manual' command describes the fdisk
commands in detail.
Fedora created the EFI system partition with id 'EF' already, so the only thing left is to create the OpenBSD partition with id 'A6'. At the fdisk prompt, first print the partition partition table that was created by Fedora:
Disk: sd0 Usable LBA: 34 to 937703054 [937703088 Sectors]
GUID: 1876166f-3413-44c9-8b7e-9e559bccb79f
#: type [ start: size ]
guid name
------------------------------------------------------------------------
0: EFI Sys [ 2048: 1024000 ]
c1a42d93-a363-4104-ab7e-050d48291df7 EFI System Partition
1: Linux files* [ 1026048: 1024000 ]
d42b1596-d3cd-403f-8f6a-a191fa70f815
2: Linux files* [ 2050048: 325083136 ]
82e12efd-b0eb-4962-9e55-7a18c759611e
The next free partition would be 3, so type type 'e 3' and enter the parameters for the new GPT partition. The tricky part is to calculate the start offset of the new partition and type it correctly, as the default was 34 in my case (if I remember correctly). The start offset of partition 3 should be start + size of the previous partition 2, 2050048 + 325083136 = 327133184 in my case. The default for the size is good again, as we want to use all the remaining space for OpenBSD. The finished GPT partition table looks like this:
Disk: sd0 Usable LBA: 34 to 937703054 [937703088 Sectors]
GUID: 1876166f-3413-44c9-8b7e-9e559bccb79f
#: type [ start: size ]
guid name
------------------------------------------------------------------------
0: EFI Sys [ 2048: 1024000 ]
c1a42d93-a363-4104-ab7e-050d48291df7 EFI System Partition
1: Linux files* [ 1026048: 1024000 ]
d42b1596-d3cd-403f-8f6a-a191fa70f815
2: Linux files* [ 2050048: 325083136 ]
82e12efd-b0eb-4962-9e55-7a18c759611e
3: OpenBSD [ 327133184: 610569871 ]
c9377bdd-3b14-4002-8a22-c1dcd9595d2f
After writing the partition table ('write') and exiting fdisk ('quit'), follow the standard OpenBSD installation process. In my case I enabled full disk encryption for the OpenBSD part, so I had to follow some extra steps.
After finishing the installation remember to enable UEFI boot again in case you needed to disable for booting the installer. When booting, select the disk device as boot device. The UEFI BIOS will try to boot from the default path within the EFI system partition, which is 'EFI\BOOT\BOOTX64.EFI'. OpenBSD did place its UEFI bootloader there during installation:
[EFI System Partition]
`-- EFI
`-- BOOT
|-- BOOTX64.EFI
`-- BOOTIA32.EFI
There will be no dedicated boot entry created in the UEFI BIOS boot device list. See the next section on how to use efibootmgr on Fedora to create a Boot menu entry for OpenBSD.
First of all, mount the EFI partition in either OpenBSD or Fedora and create a subdirectory for OpenBSD and copy 'EFI\BOOT\BOOTX64.EFI' into that directory:
[EFI System Partition]
`-- EFI
|-- BOOT
| |-- BOOTX64.EFI
| `-- BOOTIA32.EFI
|-- FEDORA
| |-- BOOT.CSV
| :
|
`-- OPENBSD
`-- BOOTX64.EFI
Boot into Fedora and run the following command:
sudo efibootmgr --create \
--disk /dev/sda \
--part 1 \
--label 'OpenBSD' \
--loader '\EFI\OPENBSD\BOOTX64.EFI'
On next boot, the UEFI BIOS boot manager should show a new boot option:
Be aware that OpenBSD will install new versions of BOOTX64.EFI into the default path 'EFI\BOOT\BOOTX64.EFI' on upgrade. So you have to remember to update the copy that is referenced in the boot menu. Fedora created 'EFI\BOOT\BOOTX64.EFI' as well and might overwrite on update, therefore I believe creating a copy in subdirectory for OpenBSD is best to prevent it from becoming non-bootable.