Re: EFI boot partition overwritten
- In reply to: Warner Losh : "Re: EFI boot partition overwritten"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 16 Jul 2021 19:55:11 UTC
On 7/16/21 1:35 PM, Warner Losh wrote: > > There should be. Yes. Last time I went hunting for a place to shoe-horn it > in, I got distracted by something else. > > The instructions are relatively straight forward. I'm writing them here for > your benefit, and also in case someone wants to send me a diff/pull request > to include them. Or better yet, put this in the handbook and we can > reference > a location from there. > > WARNING: This is a quick run-through of how to do this if you need to. > The example commands given might not be exactly right for all installations > as differing numbers of partitions will change the '-i' parameters. > > Frist, you need a partition that's of the right type. For GPT that type is > `efi` > as shown in `gpart show <boot-device>` eg > # gpart show ada0 > => 40 2000409184 ada0 GPT (954G) > 40 1600 - free - (800K) > 1640 1992292792 2 freebsd-ufs (950G) > 1992294432 7000000 3 freebsd-swap (3.3G) > 1999294432 1114792 4 efi (544M) > It looks like the default layout from the install media is 200M => 40 488397088 ada0 GPT (233G) 40 409600 1 efi (200M) 409640 1024 2 freebsd-boot (512K) 410664 984 - free - (492K) 411648 4194304 3 freebsd-swap (2.0G) 4605952 483790848 4 freebsd-zfs (231G) 488396800 328 - free - (164K) > If you don't have one, you'll need to create one. In the above exmaple, > I had installed the system with a tiny partition for booting with legacy > BIOS, but then moved to booting with UEFI. I did this by turning off > swapping and doing the following: > # gpart resize -i 3 -s 7000000 ada0 > I then created a new efi partition: > # gpart add -t efi ada0 > and I let it autosize. > > Next, I needed a FAT32 filesystem on that device. FAT16 usually will > work and often FAT12, but there are known examples of system integrators > that omit support for these last two (more the latter than the former since > it's viewed as a floppy only thing, and who uses floppies). I just used > newfs_msdos and mounted it: > # newfs_msdos -F 32 /dev/ada0p4 > # mount -t msdos /dev/ada0p4 /boot/efi > > Next, you need to put a bootloader on the system. Unless you have > special needs, loader.efi is that loader. > # mkdir -p /boot/efi/efi/boot > # cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi > All of the forums use uppercase for mountpoint/EFI/BOOT/BOOTX64.efi. Is that directory structure standard across motherboard manufacturers or is lower case allowed? > If you are using efibootmgr to set a location to boot from, generally people > create a freebsd directory (we've registered /efi/freebsd with the proper > folks > to avoid conflicts): > # mkdir -p /boot/efi/efi/freebsd > # cp /boot/loader.efi /boot/efi/efi/freebsd > # efibootmgr -c -a -k /boot/kernel/kernel -l > /boot/efi/efi/freebsd/loader.efi -L "FreeBSD Boot" > though some vendors impose limits on how many boot envs you can create > and some do not allow any at all. > Warner: Thanks for getting this effort rolling. I think that the best place for is in the Handbook since it is something that is not performed often. The /usr/src/UPDATING section can just refer to the section in the Handbook for the times the loader.efi is updated or requires re-installation. Tom -- Public Keys: PGP KeyID = 0x5F22FDC1 GnuPG KeyID = 0x620836CF