Prepare for later EFI boot

This commit is contained in:
Jørn Åne de Jong 2022-05-27 22:04:42 +02:00 committed by Nico Schottelius
parent 39ff637064
commit 906754e841

View file

@ -65,7 +65,8 @@ ufsdisk="$(mktemp /var/tmp/ufsdisk.XXXXX)"
truncate -s 6G "$ufsdisk"
mdconfig -a -t vnode -f "$ufsdisk" -u md1
gpart create -s gpt /dev/md1
gpart add -t freebsd-boot -l bootfs -b 40 -s 512K md1
#gpart add -t efi -l efiboot0 -s 260M md1
gpart add -t freebsd-boot -l gptboot0 -b 40 -s 512K md1
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 md1
gpart add -t freebsd-ufs -l rootfs -b 1M -s 5G md1
newfs -U /dev/md1p2
@ -81,7 +82,8 @@ zfsdisk="$(mktemp /var/tmp/zfsdisk.XXXXX)"
truncate -s 6G "$zfsdisk"
mdconfig -a -t vnode -f "$zfsdisk" -u md0
gpart create -s gpt /dev/md0
gpart add -t freebsd-boot -l bootfs -b 40 -s 512K md0
#gpart add -t efi -l efiboot0 -s 260M md1
gpart add -t freebsd-boot -l gptboot0 -b 40 -s 512K md0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 md0
gpart add -t freebsd-zfs -l zfs0 -b 1M -s 5G md0
zpool create -O compression=on -o ashift=12 -o "altroot=$ZFSTARGET" -m none -t "$ZPOOL_TMP" "$ZPOOL" md0p2
@ -133,7 +135,6 @@ mount_nullfs /var/tmp "$UFSTARGET/var/tmp"
make -C "$CLOUDSETUP_WORK/" PREFIX="$UFSTARGET/usr/local" install
# Configure new system.
printf '# Device\tMountpoint\tFStype\tOptions\t\tDump\tPass#\n' >"$UFSTARGET/etc/fstab"
touch "$UFSTARGET/firstboot"
sysrc -f "$UFSTARGET/boot/loader.conf" \
zfs_load=YES \
@ -175,8 +176,13 @@ rm -rf "$UFSTARGET/var/db/freebsd-update/"* ||:
zfs set compression=zstd-19 "$ZPOOL_TMP/ROOT/default"
umount "$UFSTARGET/dev" "$UFSTARGET/tmp" "$UFSTARGET/var/tmp"
rsync -aH --fileflags --inplace "$UFSTARGET/." "$ZFSTARGET"
sysrc -f "$UFSTARGET/boot/loader.conf" -x zfs_load
printf '%s\t%s\t\t%s\t%s\t%s\t%s\n' /dev/gpt/rootfs / ufs rw,noatime 1 1 >>"$UFSTARGET/etc/fstab"
printf '# Device\tMountpoint\tFStype\tOptions\t\tDump\tPass#\n' \
>"$ZFSTARGET/etc/fstab"
printf '# Device\tMountpoint\tFStype\tOptions\t\tDump\tPass#\n%s\t%s\t\t%s\t%s\t%s\t%s\n' \
/dev/gpt/rootfs / ufs rw,noatime 1 1 \
>"$UFSTARGET/etc/fstab"
sync ||:
zfs inherit compression "$ZPOOL_TMP/ROOT/default"