[Bug 264090] gpart bootcode safety checks

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 20 May 2022 09:54:58 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264090

--- Comment #4 from Piotr Florczyk <piotr.florczyk@gemius.com> ---
(In reply to Warner Losh from comment #1)
I know I don't have to but as I already mentioned... If you boot in UEFI
installer always defaults to BIOS+UEFI scheme and places freebsd-boot as second
partition. This changes holy index of that partition from 1 to 2.
I operate more than 100 of FreeBSD servers and this is first time I did a typo.
One could say that this is combination of:
- defaults in the installer (partition order, I understand why it defaults to
BIOS+UEFI)
- bad luck (efi partition not mounted on older installs)
- human error
but the point is it could be prevented if gpart did some checks.

If I understand correctly gpart bootcode overwrites first sector with code
which seeks for partition type freebsd-boot. I see no reason in allowing
writing boot code in other partition types.

I already had my lesson. This will prevent others from losing data. Currently
only mounted partitions are protected.

Case mentioned by Kurt is also valid.

-- 
You are receiving this mail because:
You are on the CC list for the bug.