From nobody Fri Jul 16 20:13:13 2021 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1A43E127E954 for ; Fri, 16 Jul 2021 20:13:21 +0000 (UTC) (envelope-from freebsd@grem.de) Received: from mail.evolve.de (mail.evolve.de [213.239.217.29]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA512 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mail.evolve.de", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GRMr058lyz4kPS; Fri, 16 Jul 2021 20:13:20 +0000 (UTC) (envelope-from freebsd@grem.de) Received: by mail.evolve.de (OpenSMTPD) with ESMTP id 06941b82; Fri, 16 Jul 2021 20:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=grem.de; h=content-type :content-transfer-encoding:mime-version:subject:from:in-reply-to :date:cc:message-id:references:to; s=20180501; bh=9FLn+qAdeLXRyH VkiaUS8Vi7p+U=; b=KSUoQWyC9DcsIIyp8bpH34UofArdwD6o4yohGmMavCm4oL bVnHWIFI26U0+FrDqHVM2VvHmNJDJy288zkPkL4pXo3v4dTB3oln6My0Sy2SIvmc LTK/js/RPOA3aADP8+zhA9alVbsFfgnXmtTXaKgLDCfgDffh/c8/FknJkG8WQ4pj JWocqFOduMHmEXh6QElitPmr3d+DHRIZnpRvz7yvm5mdRiNTUw2/uVdTALJGPBoB yHSNc3pwOWdP+u0115DYritaQzhxAVtgdt47ogf6iEXknph3+/t4LrXcJGEMaUKe 8CrpnXK2CxiyrFU4on40TU2b8yqxWXADmYSAZglA== DomainKey-Signature: a=rsa-sha1; c=nofws; d=grem.de; h=content-type :content-transfer-encoding:mime-version:subject:from:in-reply-to :date:cc:message-id:references:to; q=dns; s=20180501; b=uGafciHW 1dqMDEmw4tdsBJi4iMa8bDNUb8rgT30jHB1gNFSzR0fF6wVtCT+pWdVhg5ZVksTa tvHcA8hWGSbU+kIiy2X+c/s8nQBnrXb7+yg3iPFhdtBrpZZPeGUXn9buUAu1byAJ 2Zqx4s+DazmtlnGC8TPmI9YexS9Ku+jpS6NOHJONFQZKWmW8HcxUq0XtuKT6mJzf SKbRz67vH3mpVNbRddZn8C8plSExsAJa6hKNkeF4bTFqYV0EY3SXEDishilmWRNW SOmJbQlbRKK/a/7+fzxme93bcCEmVD8pa74UlWpvRbIyHhKAv0BBDambOTxRrQhz frpk3qPe+MFCvg== Received: by mail.evolve.de (OpenSMTPD) with ESMTPSA id 1047786e (TLSv1.3:AEAD-CHACHA20-POLY1305-SHA256:256:NO); Fri, 16 Jul 2021 20:13:14 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org Mime-Version: 1.0 (1.0) Subject: Re: EFI boot partition overwritten From: Michael Gmelin In-Reply-To: Date: Fri, 16 Jul 2021 22:13:13 +0200 Cc: Thomas Laus , Current FreeBSD Message-Id: References: To: Warner Losh X-Mailer: iPhone Mail (18F72) X-Rspamd-Queue-Id: 4GRMr058lyz4kPS X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N > On 16. Jul 2021, at 19:38, Warner Losh wrote: >=20 > =EF=BB=BFOn Fri, Jul 16, 2021 at 6:14 AM Thomas Laus wrot= e: >=20 >> Group: >>=20 >> This is an issue for more than just CURRENT. The 'usr/src/UPDATING' >> file has the instructions for updating the ZFS bootblocks but not the >> EFI partition. I recently upgraded a RELEASE-12.2 to RELEASE-13.0. The >> freebsd-update procedure did not upgrade the ZFS bootblocks. I forgot >> that this PC was UEFI only and overwrote the first partition with the >> gptzfsboot code. That made my system un-bootable. I found the recovery >> procedure on one of the FreeBSD forums and was able to reformat the EFI >> MSDOS partition, create the proper directory structure, and copy the >> loader.efi file to the correct location and filename using the Live >> Filesystem running on the installation CD. >>=20 >> I searched the man pages and the UPDATING file for instructions but came >> up empty and had to resort to finding the answer on one of the forums. >> The filenames have changed since FreeBSD first supported EFI and some of >> the forum instructions are out of date. My problem must be fairly >> common and the recovery procedure should be in a man page with a >> footnote or man reference somewhere on the install media. >>=20 >> Since CURRENT receives more updates to the EFI boot loader than the >> release versions, there should be instructions in the CURRENT >> 'usr/src/UPDATING' file on how to update the EFI bootcode. >>=20 >=20 > There should be. Yes. Last time I went hunting for a place to shoe-horn it= > in, I got distracted by something else. >=20 > The instructions are relatively straight forward. I'm writing them here fo= r > your benefit, and also in case someone wants to send me a diff/pull reques= t > to include them. Or better yet, put this in the handbook and we can > reference > a location from there. >=20 > 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 installation= s > as differing numbers of partitions will change the '-i' parameters. >=20 > Frist, you need a partition that's of the right type. For GPT that type is= > `efi` > as shown in `gpart show ` eg > # gpart show ada0 > =3D> 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) >=20 > 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. >=20 > 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 sinc= e > 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 >=20 > 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 >=20 > If you are using efibootmgr to set a location to boot from, generally peop= le > 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. >=20 It would be cool to also update the loader.efi man page to be a bit more use= ful (this is what 'zpool upgrade' refers to/will refer to in the future). -m > Warner