Convert to EFI boot loader

Christian Barthel bch at
Sun Mar 29 20:19:28 UTC 2020


I'd like to convert an existing FreeBSD 12.1 installation (that
is using GPT / freebsd-boot / encrypted ZFS) to EFI (the reason
for this is that I want to plug the disk into a ThinkPad X230
instead of a ThinkPad X201). 

The former layout on the X201 notebook using the legacy
freebsd-boot partition looks like: 

40         7814037088  ada0  GPT (3.6T)
40               1024     1  freebsd-boot (512K)
1064              984        - free - (492K)
2048         16777216     2  freebsd-swap (8.0G)
16779264   7797256192     3  freebsd-zfs (3.6T)
7814035456       1672        - free - (836K)

I then adapted this layout with the commands:

gpart delete -i 1 ada0
gpart delete -i 2 ada0
gpart add -b 40 -s 409600 -t efi ada0
gpart add -b 409640 -s 1024 -t freebsd-boot ada0
gpart add -b 411648 -s 7G -t freebsd-swap ada0

The current layout looks like this:

$ sudo gpart show /dev/ada0
=>        40  7814037088  ada0  GPT  (3.6T)
          40      409600     1  efi  (200M)
      409640        1024     2  freebsd-boot  (512K)
      410664         984        - free -  (492K)
      411648    16777216     3  freebsd-swap  (8.0G)
    17188864  7796846592     4  freebsd-zfs  (3.6T)
  7814035456        1672        - free -  (836K)

I then did the above commands to install the bootloader: 

gpart bootcode -p /boot/boot1.efifat -i 1 ada0 (*)
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 ada0

I can mount ada0p1 and see the efi/boot/BOOTx64.efi loader.  But
when I am trying to start the system on the X230, it's not
working: pressing <f12> on the Lenovo X230 and selecting the disk
does not boot the system.  It tries a different source
afterwards.  Am I missing something?

Additional observations:

Interestingly enough, the disk still boots on the X201 (maybe due
to the legacy freebsd-boot loader at index 2?).

The X230 BIOS option is set to "UEFI Only".  I tested "Legacy"
and "Both" as well.  With the "Legacy" option being selected, I
get the message that "No gptzfsboot loader found" (or something
similar to this).

Instead of using the above (*) gpart(1) command, I also tried
  dd if=/boot/boot1.efifat of=/devada0p1
but there was no visible change to the gpart(1) command.  

I discovered a similar article at [1] and the author is doing
almost the same.


Christian Barthel <bch at>

More information about the freebsd-questions mailing list