Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Feb 2021 22:40:55 +0100
From:      Stefan Esser <se@freebsd.org>
To:        Warner Losh <imp@bsdimp.com>, Greg Rivers <gcr+freebsd-stable@tharned.org>
Cc:        FreeBSD-STABLE Mailing List <freebsd-stable@freebsd.org>
Subject:   Re: FreeBSD 13/stable and zpool upgrade
Message-ID:  <371a184d-21c7-fb16-df26-ff19c6718cdd@freebsd.org>
In-Reply-To: <CANCZdfphKtsYvUauo%2BFe8Hg%2B3TEFjkEthk=B5So0=WHsRFDpxQ@mail.gmail.com>
References:  <ac735a6b-b82e-36e4-eb66-d2c0d422cc75@lapinbilly.eu> <CANCZdfrm0dpQ6tyggj-VStTz1zTz8wvqZ35ePn5Dc-o66nC4JQ@mail.gmail.com> <YDACWGA4mLKXiuAb@home.opsec.eu> <2027600.x0N0T6uNKo@no.place.like.home> <CANCZdfphKtsYvUauo%2BFe8Hg%2B3TEFjkEthk=B5So0=WHsRFDpxQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--ARGH3UhTQvUf6gHZmHoQy21gVvB69YCS5
Content-Type: multipart/mixed; boundary="RE6kC5ckjMPAlFN5YxdZeWIu99npz7Qgb";
 protected-headers="v1"
From: Stefan Esser <se@freebsd.org>
To: Warner Losh <imp@bsdimp.com>, Greg Rivers <gcr+freebsd-stable@tharned.org>
Cc: FreeBSD-STABLE Mailing List <freebsd-stable@freebsd.org>
Message-ID: <371a184d-21c7-fb16-df26-ff19c6718cdd@freebsd.org>
Subject: Re: FreeBSD 13/stable and zpool upgrade
References: <ac735a6b-b82e-36e4-eb66-d2c0d422cc75@lapinbilly.eu>
 <CANCZdfrm0dpQ6tyggj-VStTz1zTz8wvqZ35ePn5Dc-o66nC4JQ@mail.gmail.com>
 <YDACWGA4mLKXiuAb@home.opsec.eu> <2027600.x0N0T6uNKo@no.place.like.home>
 <CANCZdfphKtsYvUauo+Fe8Hg+3TEFjkEthk=B5So0=WHsRFDpxQ@mail.gmail.com>
In-Reply-To: <CANCZdfphKtsYvUauo+Fe8Hg+3TEFjkEthk=B5So0=WHsRFDpxQ@mail.gmail.com>

--RE6kC5ckjMPAlFN5YxdZeWIu99npz7Qgb
Content-Type: multipart/mixed;
 boundary="------------02C30B0CF2875C26057FA7A9"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------02C30B0CF2875C26057FA7A9
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: quoted-printable

Am 19.02.21 um 22:07 schrieb Warner Losh:
>> To avoid confusion and errors, I think a proper boot1.efifat should be=
 put
>> back into the base system so that people don't have to track the above=

>> recipe (which is likely to change).
>>
>=20
> There's no safe way to do this. The old process has been deprecated bec=
ause
> it is dangerous and inflexible.
>=20
> For upgrading from an old-style installation, the new process is actual=
ly
> fairly simple:
>=20
> mount -t msdos /dev/daXsY /mnt
> cp /boot/loader.efi /mnt/efi/boot/bootx64.efi
> umount /mnt
>=20
> Though if you're using eftbootmgr to select things, you'll need to copy=
 to
> efi/freebsd/loader.efi. Different BIOS vendors have a number of differe=
nt
> bugs that make this trickier than it should be, alas.

I have been using the attached script to update book blocks on EFI
or GPT ZFS MBR boot disks for quite some time.

More partition schemes and boot block types could be supported by
extending the covered cases and/or passing the partition type (GPT
vs. MBR).

Regards, STefan

--------------02C30B0CF2875C26057FA7A9
Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
 name="update-bootcode"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
 filename="update-bootcode"

#!/bin/sh

MOUNTPOINT=3D/.efi

BOOT1=3D/boot/pmbr
BOOT2=3D/boot/gptzfsboot
BOOTEFI=3D/boot/loader.efi

update_gptzfsboot ()
{
	disk=3D$1
	partname=3D$2

	if strings /dev/$partname | grep -q ZFS; then
		index=3D${partname##*p}
		gpart bootcode -b $BOOT1 -p $BOOT2 -i $index $disk
	fi
}

update_efiboot ()
{
	disk=3D$1
	partname=3D$2
	efidir=3D$MOUNTPOINT/efi/boot

        umount $MOUNTPOINT 2>/dev/null
        if mount -t msdos "/dev/$partname" $MOUNTPOINT; then
		mkdir -p $efidir
                rm -f $efidir/BOOTx64o.efi
                mv $efidir/BOOTx64.efi $efidir/BOOTx64o.efi
                cp $BOOTEFI /.efi/efi/boot/BOOTx64.efi
                umount $MOUNTPOINT
        fi
}

while read line
do
	set - $line

	if [ "$1" =3D "=3D>" ]; then
		disk=3D$4
		partscheme=3D$5
	else
		partname=3D$3
		parttype=3D$4

		case $parttype in
		efi)
			update_efiboot $disk $partname
			;;
		freebsd-boot)
			update_gptzfsboot $disk $partname
			;;
		esac
	fi

done <<*EOF
$(gpart show -p)
*EOF

--------------02C30B0CF2875C26057FA7A9--

--RE6kC5ckjMPAlFN5YxdZeWIu99npz7Qgb--

--ARGH3UhTQvUf6gHZmHoQy21gVvB69YCS5
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEEo3HqZZwL7MgrcVMTR+u171r99UQFAmAwMGcFAwAAAAAACgkQR+u171r99USH
rQgAmJkJw2e/2sNprf2u86K4aXcFkgCua4nt/cMX02D281Lk905tnTj7Z0qNTqa2t92BfcfjlM9q
jZz+5Q2wmn7xl/TZnrbxaRYonSMdZBpdTGsc/ru7ra8+oXCLhbiL69ZuTvo29TtFqqCuVOLI/+Mt
CzB7d5wmOGsrWU6pyVyrFpXqWxuotfm80A/2qFlK2yQxF/J1Mnw+VhUYUZEXkKUAP0cocE2R27a2
eJQ4buHBvWYUKAQ7Y/PlcgB7XeEhL4CE1E9hw4eCVn7SI4mMqvakwMs9VSolz9PY93gduqvM1Kol
5AMXbgrzfH2Vj5J0slUwzV7v2y7PVfSn7hR71OwKVw==
=Bvw0
-----END PGP SIGNATURE-----

--ARGH3UhTQvUf6gHZmHoQy21gVvB69YCS5--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?371a184d-21c7-fb16-df26-ff19c6718cdd>