Solved Non-destructive reuse of existing EFI partition possible?

Hi!

I'm currently trying to install FreeBSD 14.1 on a Thinkpad T14 Gen3 (Intel) with the interactive bsdinstall TUI but have some questions regarding the partitioning step.

My plan is to run FreeBSD alongside Windows 11 on a single SSD using the BIOS to switch between installed EFI bootloaders. AFAICS that would only require for FreeBSD to install its EFI loader into the existing EFI partition that is already used by Windows.

I prepared the disk by creating some free storage space. During installation I use "Auto (UFS)" with the
"Partition" option to let the installer create a partition layout for me in the existing free space:
freebsd_partitions.jpg

Inspecting "nda0p1" with "Modify" does not seem to give me an option to prevent formatting of the partition. When selecting "Finish" I'm informed that all changes will now be written to disk.

Am I correct with my assumption that this action would format nda0p1 and erase any EFI loaders already installed there? If so, is it possible to retain those loaders and only add the one from FreeBSD to it?

- fiwlt
 
Don't let the installer touch the existing EFI partition or create a new one. At the end of the install you're asked if you want to make additional changes, this will drop you to a shell. Copy loader.efi by hand to EFI/FreeBSD/loader.efi and fix the boot order using efibootmgr(8). Then exit the shell and the installer will finish and reboot.
 
Don't let the installer touch the existing EFI partition or create a new one. At the end of the install you're asked if you want to make additional changes, this will drop you to a shell. Copy loader.efi by hand to EFI/FreeBSD/loader.efi and fix the boot order using efibootmgr(8). Then exit the shell and the installer will finish and reboot.
Thanks for the reply! I understand now how installing the FreeBSD EFI loader works.

However, I'm still not clear about how to make sure that the existing partition is not touched. At the moment I'm assuming all partitions with an assigned mount point are changed. Removing the mount point with Modify from the efi partition is not accepted. If i create the root / and swap partitions manually, the efi partition is always added as mounted on /boot/efi after i add the root partition.

Do i need to perform a manual installation on the shell (create & format partitions, extract kernel.txz, base.txz, ...)?
 
I'm looking at ways to install Windows 11 on my new HP without breaking the existing EFI partition. I managed to clone the Windows 10 from my soon to become sandbox laptop, even getting the Windows bits into the EFI partition. It worked for 15 minutes after which Windows blue screened and failed to boot thereafter. I'm reluctant to install Windows from an ISO for fear of blowing away the /EFI/FreeBSD directory in the EFI partition.
 
Ok, made some progress. I used the installer up until partitioning, then dropped into a shell with the Shell option. Steps to create swap + single UFS root partition and mount/enable swap (GPT disk /dev/nda0 in my case, may vary dependant on hardware):

1) create swap partition, 4GB size:
gpart add -t freebsd-swap -s 4G -l freebsd-swap nda0
This created a swap on new partition /dev/nda0p6 in my case.

2) enable swap:
swapon /dev/nda0p6

3) create UFS partition (no size parameter => use remaining free disk space)
gpart add -t freebsd-ufs -l system nda0
Adds new UFS partition /dev/nda0p7 in my case.

4) format new root partition as UFS:
newfs -U /dev/nda0p7

5) mount new root partition on /mnt for installation of base system:
mount /dev/nda0p7 /mnt

Exiting the shell after this continues the installation with network mirror selection (bootonly installation medium).

After the installation I mounted the efi partition with
mount -t msdosfs /dev/nda0p1 /boot/efi
and copied the loader with
cp /mnt/boot/loader.efi /boot/efi/EFI/FreeBSD
then enabled it with efibootmgr:
efibootmgr -a -c -l /boot/efi/EFI/FreeBSD/loader.efi -L FreeBSD
Output:
efi_boot_freebsd.jpg


Looked fine to me. However after a shutdown -r now this new boot option is nowhere to be found. Secure boot is OFF, not sure what I'm missing here.
 
First, before installing a new operating system (like FreeBSD) on your computer, make a backup of all important data.

However, I'm still not clear about how to make sure that the existing partition is not touched.

Do i need to perform a manual installation on the shell (create & format partitions, extract kernel.txz, base.txz, ...)?
Just make a backup of the EFI partition (e.g. with dd(8)) and if the FreeBSD installer overwrites it, restore from the backup. No need to perform a manual installation.
 
I'm reluctant to install Windows from an ISO for fear of blowing away the /EFI/FreeBSD directory in the EFI partition.
You can always recreate the /EFI/FreeBSD directory and put any version of loader.efi in it. The EFI partition contains a normal writable filesystem. I don't understand why you are scared to touch it. I would be more worried about the Windows installer destroying all FreeBSD partitions.
 
efibootmgr(8) "not working" was a classic case of PEBKAC: there's an option in the Thinkpad BIOS under Startup called Boot Order Lock that prevents changes to the UEFI boot order when enabled. I had no issues with adding the FreeBSD EFI boot entry after disabling this lock.

Additionally:
  • Make sure to create a basic fstab(5) when creating your partitions, otherwise you'll be greeted with a mountroot prompt when booting into FreeBSD.
  • When using a bootonly installation medium, use the ethernet interface for this laptop model. The wifi is very unstable and has low throughput.

So: problem solved, FreeBSD + Windows 11 bootable with the UEFI boot manager!
 
Back
Top