Boot fails with error 19

I think the disc is probably still good mechanically, and is just annoyed with me for repeatedly swapping it in and out as I tried to recover from not having adequately marked all the hard drives before I moved house.

Having read Warren's documentation on gpart and gptboot I think I know what to do, but never having had to do it before and not wanting to end up with a worse mess, I'd appreciate it if someone knowledgeable would check this:

GPT-partitioned disc (scheme=gpt), p1 is efi, p2 is freebsd-ufs. Therefore

gpart bootcode -p /boot/gptboot -i 2 ada0

should be enough to fix things if the disc is still physically functional. Yes?
 
Read gpart(8)
This will install the bootcode on INDEX 2 and you don't want to do this unless it's your freebsd-boot partition there.
First type gpart show to see the ID of your boot partition.

Then depending of how you boot your computer using Legacy BIOS or UEFI you need to install the proper bootcode

For GPT with MBR (Legacy BIOS boot)
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
For ZFS you can use /boot/gptzfsboot

For GPT with EFI (UEFI boot)
dd if=/boot/boot1.efifat of=/dev/ada0p1

There's third variant with mixed boot with the following layout

ID - Type
1 - EFI (800k)
2 - freebsd-boot (512K)
3 - freebsd-ufs
4 - freebsd-swap

Edit2:
The new method is to manually format the FAT32 EFI partition instead of using boot1.EFIFAT image which is obsolete.

gpart create -s gpt da0
gpart add -t efi -s 40M da0
gpart add -t freebsd-ufs da0
newfs_msdos -F 32 -c 1 /dev/da0p1
mount -t msdosfs /dev/da0p1 /mnt
mkdir -p /mnt/EFI/BOOT
cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi
umount /mnt
newfs -U -L FreeBSD /dev/da0p2
 
Last edited:
I haven't seen that efi one. Where is it documented?

I'd supposed that the efi boot code only decides which partition gets booted and then hands off to the partition's own boot code.
 
IF you don't have EFI partition then you are using legacy BIOS boot. Some motherboards support mixed boot which first search for the first EFI partition and if none is found then switch to CSM which allow boot from legacy BIOS.
EFI partition holds the first stage of UEFI bootstrap. It's documented in both gpart(8) and uefi(8)

https://wiki.freebsd.org/UEFI (it need some update but it's a good source for information)

Edit:
Note that efifat is removed in the upcoming version. https://reviews.freebsd.org/D20562
 
Back
Top