(UEFI) Accidentally deleted FreeBSD bootloader, how to work around this?

Hi,

I accidentally deleted the bootloader entry generated by FreeBSD's installer in my UEFI firmware. I used to see an entry, when I pressed F9 (which lists all available bootloaders), that pertained to FreeBSD, but I did some deleting with efibootmgr of bootloaders I didn't need anymore and I must have accidentally deleted FreeBSD's bootloader. How do I get it back? I have around 10 different Linux distros installed to my PC, each with their own bootloader shown when I press F9. My default bootloader is GRUB installed by my openSUSE Tumbleweed system. I made a few attempts to make a bootable GRUB entry for FreeBSD 11.2. In one attempt I tried adding:

Code:
menuentry "FreeBSD 11.2" {
insmod ufs2
set root=(hd1,gpt3)
kfreebsd /boot/loader
}

(based on https://unix.stackexchange.com/a/354301/27613, where /dev/sdb3, or /dev/ada1s3 in FreeBSD notation, is my FreeBSD UFS root partition) to my openSUSE Tumbleweed's grub.cfg file. In another attempt I tried adding:

Code:
menuentry "FreeBSD" --class freebsd --class bsd --class os {
 insmod ufs2
 insmod bsd
 set root=(hd1,gpt3)
 kfreebsd /boot/kernel/kernel
 kfreebsd_loadenv /boot/device.hints
 set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ada1s3
 set kFreeBSD.vfs.root.mountfrom.options=rw
 set kFreeBSD.hw.psm.synaptics_support=1
}

based on https://unix.stackexchange.com/questions/109272/add-freebsd-to-grub2-boot-menu/109278#109278 to this same file and neither booted properly. Both entries, when booted separately, gave:

IMG_20180823_100300-cropped.jpg


. Even after waiting a minute for things to change I was stuck with this screen.

So I'm here to ask if anyone has a way around this stuff up of mine.

Thanks for your time,
Brenton
 
(based on https://unix.stackexchange.com/a/354301/27613, where /dev/sdb3, or /dev/ada1s3 in FreeBSD notation, is my FreeBSD UFS root partition)
The device names of the filesystems in FreeBSD depend on the partition scheme used.
I can't see how you came up with /dev/ada1s3 from the examples on stackexchange, since they talk about GPT, while your example is for MBR.

You should boot into the FreeBSD installer and run gpart show -p from the shell. The FreeBSD efi partition is 200M in size and the freebsd-ufs partition right after it, is (usually) the partition FreeBSD should boot from.
In case you somehow managed to delete the content of the efi partition FreeBSD installed, then from the shell run gpart bootcode -p /boot/boo1.efifat -i [I]partnum /dev/[/I]
Run gpart show (without the -p) to see the partition numbers.
 
There's no EFI partition that FreeBSD installed. There is one I had already at /dev/sda1, which is used by Linux, but FreeBSD only installed:

/dev/sdb2 - FreeBSD boot partition, 512K in size
/dev/sdb3 - FreeBSD UFS partition, 89 G in size
/dev/sdb4 - FreeBSD swap partition, 4 G in size

I don't use MBR, both my disks have GPT partition tables.
 
Could you please use gpart to display all this? Not only will that tell us the right device to use but it will also display any empty space(s) between the partitions if there is some. Which seems likely because it seems a bit odd to me that FreeBSD would install it's EFI bootloader onto another disk than the system disk.
 
Well how I am meant to get you the full output is a mystery to me, given that my PC has a WiFi chip incompatible with FreeBSD (although I have ordered an atheros chip to fix this, but it won't be here for a fortnight, at least) and an ethernet cable isn't a viable option. The best I can do is give you this photo of what I see when I run gpart show:

IMG_20180823_212206.jpg


Hopefully, that was sufficiently helpful. I tried running:

Code:
gpart bootcode -p /boot/boo1.efifat -i 3 /dev/

(I thought partnum was meant to be the UFS partition number; not sure if the 1 in boo1.efifat was a typo, so I tried with 1 replaced with t too, with the same result) and it didn't seem to get what I meant.
 
Why has everyone gone silent? Would it help if I showed you the output of:

Code:
fdisk /dev/sda -l

so you can see the details of /dev/sda too (as I can't see it in the photo)? If so here it is:

Code:
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: D6295BA0-7C8B-4F33-BAF6-B6DF757614A6

Device          Start        End   Sectors  Size Type
/dev/sda1        2048     264191    262144  128M EFI System
/dev/sda2      264192   17041407  16777216    8G Linux swap
/dev/sda3    17041408  121899007 104857600   50G Linux filesystem
/dev/sda4   121899008  331614207 209715200  100G Linux filesystem
/dev/sda5   331614208  541337599 209723392  100G Linux LVM
/dev/sda6   541337600  741337087 199999488 95.4G Linux filesystem
/dev/sda7   741337088  838936575  97599488 46.6G Linux filesystem
/dev/sda8   941336576 1151051775 209715200  100G Linux filesystem
/dev/sda9  1151051776 1360766975 209715200  100G Linux filesystem
/dev/sda10 1360766976 1465618431 104851456   50G Linux filesystem
/dev/sda11 1570482176 1780197375 209715200  100G Linux filesystem
/dev/sda12 1780197376 1953523711 173326336 82.7G Linux filesystem
/dev/sda13  838936576  839516159    579584  283M Linux filesystem
/dev/sda14 1465618432 1570482175 104863744   50G Linux LVM
/dev/sda15  839516160  941336575 101820416 48.6G Linux filesystem

Partition table entries are not in disk order.
 
I re-entered the installer's shell and ran the command, but with
Code:
| head -n no
after it, here's the pictures that show the rest of the output (the lines cut out in my last photo):

IMG_20180824_163046.jpg
IMG_20180824_163204.jpg
 
Back
Top