From nobody Fri Jul 16 17:35:11 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 26A0112A27B1 for ; Fri, 16 Jul 2021 17:35:24 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GRJKm0M2Tz3jQ5 for ; Fri, 16 Jul 2021 17:35:23 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qv1-xf36.google.com with SMTP id f3so4948988qvm.2 for ; Fri, 16 Jul 2021 10:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=R5tiUtfooyZqa13rWbvzz/s77kzyZlroNJlQcZXAZHo=; b=pj7qMBJufKme3bX6oI54MB7HUxrubTOaFRpTEm7dv5zAIF9Uv+1RKGS34XWCU4nXT3 X5i57uPDPjgFtB2UZAx/IkJvUJcNShaeZcjHj7/oUAFki9I15kC+H58k3n5t/syeV6SN GiF8y4e9d1ESapz2T5GeX5FMtg+rPoi0D0aGIwV6ZOAuALwNR+Vhd73ouP0dPpX7HfPw pPzPduvYgpcjKaf/pA04SIKhF+F76vhWnuKAkIYzPVgly0RjDlpqXNdUVMi+kMPOalia zomBiXNL++q1lOQPHe3FelZ6hiWuv2BQtB4Ne8+J0/ZTGGTLZ6OMrqwc1fS1ScQIg7Dj /p1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=R5tiUtfooyZqa13rWbvzz/s77kzyZlroNJlQcZXAZHo=; b=n8urfQeMjgomzf0LNwhH5zxhwp519jyyZOTG0Hp95VDqC6y1zE2F5JGV/7fDm2T5yZ H7Deu08KgSqJ1qmeFppdJpKSjazn7bRsnBcJCFohD13StKgkF0hA+b3ueOBTXaWHi9j7 qR6btJC3dCbk7nSC6Xc7n1o0Eb0Z+3RRkyx8jnJBwnT3erbzQVSmXUoRQc0DhPIXxBDR REyAeeSrODjDAiksFbG3rfjM0JILufm2elD3zttqIu1LXWfhM3ns/YiVqCcUc8bOQ9pH i9bwudEeXnyZr+cmrXtPo8QCzP8jTdr13TIXXeeaoUuLG/VUvAxXjcftcaNlWezF69Uj 3yyg== X-Gm-Message-State: AOAM530aI/vja4v7pVu00BaXpq5j15TkqHfEhB1J/aqBTnk41eA4ZxQN A4R6amxlQ7C2UTKj4u3skSJ5kPIyv1NtBBN6ghNWrg== X-Google-Smtp-Source: ABdhPJyxK5gvlmoAMXOnIOYi5s4HxtOTytf4age1oqydZ3mZ00/p3pPCgo24uWJI0g04NpDrT8/VOh43de2AWgbouDI= X-Received: by 2002:ad4:5ded:: with SMTP id jn13mr9859386qvb.24.1626456922599; Fri, 16 Jul 2021 10:35:22 -0700 (PDT) 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 References: <0100017aaf3bd028-56a36bdb-37e1-4d14-9d10-4ff2367110d4-000000@email.amazonses.com> In-Reply-To: <0100017aaf3bd028-56a36bdb-37e1-4d14-9d10-4ff2367110d4-000000@email.amazonses.com> From: Warner Losh Date: Fri, 16 Jul 2021 11:35:11 -0600 Message-ID: Subject: Re: EFI boot partition overwritten To: Thomas Laus Cc: Current FreeBSD Content-Type: multipart/alternative; boundary="0000000000001d469b05c7410393" X-Rspamd-Queue-Id: 4GRJKm0M2Tz3jQ5 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: Y --0000000000001d469b05c7410393 Content-Type: text/plain; charset="UTF-8" On Fri, Jul 16, 2021 at 6:14 AM Thomas Laus wrote: > Group: > > 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. > > 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. > > 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. > 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 ` 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) 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 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 --0000000000001d469b05c7410393--