FreeBSD 13/stable and zpool upgrade

Stefan Esser se at freebsd.org
Fri Feb 19 21:41:04 UTC 2021


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).
>>
> 
> There's no safe way to do this. The old process has been deprecated because
> it is dangerous and inflexible.
> 
> For upgrading from an old-style installation, the new process is actually
> fairly simple:
> 
> mount -t msdos /dev/daXsY /mnt
> cp /boot/loader.efi /mnt/efi/boot/bootx64.efi
> umount /mnt
> 
> 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 different
> 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
-------------- next part --------------
#!/bin/sh

MOUNTPOINT=/.efi

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

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

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

update_efiboot ()
{
	disk=$1
	partname=$2
	efidir=$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" = "=>" ]; then
		disk=$4
		partscheme=$5
	else
		partname=$3
		parttype=$4

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

done <<*EOF
$(gpart show -p)
*EOF
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20210219/23cdbf47/attachment.sig>


More information about the freebsd-stable mailing list