Bug 243997

Summary: bsdinstall should not format EFI partition
Product: Base System Reporter: David Demelier <markand>
Component: binAssignee: freebsd-sysinstall (Nobody) <sysinstall>
Status: Open ---    
Severity: Affects Some People CC: andrey, emaste, grahamperrin, re
Priority: --- Keywords: install, needs-qa
Version: 12.1-RELEASEFlags: koobs: maintainer-feedback? (re)
Hardware: amd64   
OS: Any   

Description David Demelier 2020-02-09 09:45:24 UTC
Hi,

FreeBSD makes a bit complicated to dual boot an UEFI install when using the bsdinstall partition tool.

Even though you don't modify the EFI partition (if already existing) FreeBSD will format it and therefore losing all your previous systems EFI loaders.

The script should not format the EFI partition and use it if already existing or propose the user to create one if not found.

Steps to reproduce:

1. Install any operating system that is not FreeBSD with a EFI partition
2. Boot FreeBSD installer
3. Create a freebsd-ufs partition (do not use auto partitioning!)
4. Install will format the EFI partition and you lose all your data on it.
Comment 1 Andrey Fesenko 2020-02-11 21:51:32 UTC
13-Current not format too

bsdinstall script, work 2019

 PARTITIONS="$DISKSLICE GPT { 512K freebsd-boot, 1M efi, auto freebsd-ufs / }
 #!/bin/sh -x
 # Make diskname independante
 gpart modify -l freebsd-boot -i 1 ada0
 gpart modify -l efi -i 2 ada0
 gpart modify -l root -i 3 ada0
 # Make EFI happy
 mount_msdosfs /dev/gpt/efi /media/
 mkdir -p /media/EFI/BOOT/
 cp /boot/loader.efi /media/EFI/BOOT/BOOTX86.efi
 umount /media/

FreeBSD-13.0-CURRENT-amd64-20200206-r357606-disc1.iso not format efi partition
Comment 2 Andrey Fesenko 2020-02-11 21:53:26 UTC
(In reply to David Demelier from comment #0)
sorry, misunderstand you bug
Comment 3 Ed Maste freebsd_committer freebsd_triage 2020-02-12 22:50:19 UTC
Yes we shouldn't format an existing EFI partition.
Comment 4 David Demelier 2020-02-13 07:47:25 UTC
(In reply to Andrey Fesenko from comment #1)

I've tried to check the 12.1 version code in bsdinstall but could not find that part. I've only tried in 12.1 though.

Has it changed in 13-CURRENT? I'll give a try to make sure.
Comment 5 Mike Karels freebsd_committer freebsd_triage 2023-07-31 17:52:42 UTC
I tested this with FreeBSD 13.2, albeit with two FreeBSD installs on separate partitions.  I was asked whether to reinstall the FreeBSD EFI loader, I said no, and the EFI partition was not reformatted.  Maybe this is fixed now.  I don't think I have a good test with a non-FreeBSD OS, but I'm open to suggestions.