Index: tools/boot/install-boot.sh =================================================================== --- tools/boot/install-boot.sh +++ tools/boot/install-boot.sh @@ -27,7 +27,7 @@ gpart show $dev | tail +2 | awk '$4 == "'$part'" { print $3; }' } -boot_nogeli_gpt_zfs_legacy() { +boot_nogeli_gpt_ufs_legacy() { dev=$1 dst=$2 @@ -35,20 +35,34 @@ if [ -z "$idx" ] ; then die "No freebsd-boot partition found" fi - doit gpart bootcode -b ${gpt0} -p ${gptzfs2} -i $idx $dev - exit 0 + doit gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev } -boot_nogeli_gpt_ufs_legacy() { +boot_nogeli_gpt_ufs_uefi() { dev=$1 dst=$2 + idx=$(find-part $dev "efi") + if [ -z "$idx" ] ; then + die "No efi ESP partition found" + fi + doit gpart bootcode -p ${efi2} -i $idx $dev +} + +boot_nogeli_gpt_ufs_both() { + boot_nogeli_gpt_ufs_legacy $1 $2 $3 + boot_nogeli_gpt_ufs_uefi $1 $2 $3 +} + +boot_nogeli_gpt_zfs_legacy() { + dev=$1 + dst=$2 + idx=$(find-part $dev "freebsd-boot") if [ -z "$idx" ] ; then die "No freebsd-boot partition found" fi - doit gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev - exit 0 + doit gpart bootcode -b ${gpt0} -p ${gptzfs2} -i $idx $dev } boot_nogeli_gpt_zfs_uefi() { @@ -60,61 +74,109 @@ die "No efi ESP partition found" fi doit gpart bootcode -p ${efi2} -i $idx $dev - exit 0 } boot_nogeli_gpt_zfs_both() { + boot_nogeli_gpt_zfs_legacy $1 $2 $3 + boot_nogeli_gpt_zfs_uefi $1 $2 $3 +} + +boot_nogeli_mbr_ufs_legacy() { dev=$1 dst=$2 - # XXX: Should this be copy/pasted, or should it call both _uefi and _legacy - idx=$(find-part $dev "efi") - if [ -z "$idx" ] ; then - die "No efi ESP partition found" + doit gpart bootcode -b ${mbr0} ${dev} + s=$(find-part $dev "freebsd-ufs") + if [ -z "$s" ] ; then + die "No freebsd-ufs slice found" fi - doit gpart bootcode -p ${efi2} -i $idx $dev + doit gpart bootcode -p ${mbr2} ${dev}s${s} +} - idx=$(find-part $dev "freebsd-boot") - if [ -z "$idx" ] ; then - die "No freebsd-boot partition found" - fi - doit gpart bootcode -b ${gpt0} -p ${gptzfs2} -i $idx $dev - exit 0 +boot_nogeli_mbr_ufs_uefi() { } +boot_nogeli_mbr_ufs_both() { +} + boot_nogeli_mbr_zfs_legacy() { dev=$1 dst=$2 # search to find the BSD slice - s=$(findpart $dev "freebsd-zfs") + s=$(find-part $dev "freebsd") if [ -z "$s" ] ; then + die "No BSD slice found" + fi + idx=$(find-part ${dev}s${s} "freebsd-zfs") + if [ -z "$idx" ] ; then die "No freebsd-zfs slice found" fi # search to find the freebsd-zfs partition within the slice # Or just assume it is 'a' because it has to be since it fails otherwise + doit gpart bootcode -b ${dst}/boot/mbr ${dev} dd if=${dst}/boot/zfsboot of=/tmp/zfsboot1 count=1 - doit gpart bootcode -b /tmp/zfsboo1 ${dev}s${s} # Put boot1 into the start of part + doit gpart bootcode -b /tmp/zfsboot1 ${dev}s${s} # Put boot1 into the start of part sysctl kern.geom.debugflags=0x10 # Put boot2 into ZFS boot slot - doit dd if=${dst}/boot/zfsboot of=/dev/${dev}s${s} iseek=1 seek=1024 + doit dd if=${dst}/boot/zfsboot of=/dev/${dev}s${s}a skip=1 seek=1024 sysctl kern.geom.debugflags=0x0 +} - exit 0 +boot_nogeli_mbr_zfs_uefi() { } -boot_nogeli_mbr_ufs_legacy() { - dev=$1 - dst=$2 +boot_nogeli_mbr_zfs_both() { +} - doit gpart bootcode -b ${mbr0} ${dev} - s=$(findpart $dev "freebsd-ufs") - if [ -z "$s" ] ; then - die "No freebsd-ufs slice found" - fi - doit gpart bootcode -p ${mbr2} ${dev}s${s} - exit 0 +boot_geli_gpt_ufs_legacy() { + boot_nogeli_gpt_ufs_legacy $1 $2 $3 } +boot_geli_gpt_ufs_uefi() { + boot_nogeli_gpt_ufs_uefi $1 $2 $3 +} + +boot_geli_gpt_ufs_both() { + boot_nogeli_gpt_ufs_both $1 $2 $3 +} + +boot_geli_gpt_zfs_legacy() { + boot_nogeli_gpt_zfs_legacy $1 $2 $3 +} + +boot_geli_gpt_zfs_uefi() { + boot_nogeli_gpt_zfs_uefi $1 $2 $3 +} + +boot_geli_gpt_zfs_both() { + boot_nogeli_gpt_zfs_both $1 $2 $3 +} + +# GELI+MBR is not a valid configuration +boot_geli_mbr_ufs_legacy() { + exit 1 +} + +boot_geli_mbr_ufs_uefi() { + exit 1 +} + +boot_geli_mbr_ufs_both() { + exit 1 +} + +boot_geli_mbr_zfs_legacy() { + exit 1 +} + +boot_geli_mbr_zfs_uefi() { + exit 1 +} + +boot_geli_mbr_zfs_both() { + exit 1 +} + boot_nogeli_vtoc8_ufs_ofw() { dev=$1 dst=$2 @@ -122,7 +184,6 @@ # For non-native builds, ensure that geom_part(4) supports VTOC8. kldload geom_part_vtoc8.ko doit gpart bootcode -p ${vtoc8} ${dev} - exit 0 } DESTDIR=/ Index: tools/boot/rootgen.sh =================================================================== --- tools/boot/rootgen.sh +++ tools/boot/rootgen.sh @@ -51,7 +51,7 @@ /dev/ada0p2 / ufs rw 1 1 EOF # XXX need to make msdos part for this to work XXXX - cp ${src}/boot/boot.efifat ${img}.p1 + cp ${src}/boot/boot1.efifat ${img}.p1 makefs -t ffs -B little -s 200m ${img}.p2 ${src} mkimg -s gpt -b ${src}/boot/pmbr \ -p efi:=${img}.p1 \ @@ -67,7 +67,7 @@ /dev/ada0p3 / ufs rw 1 1 EOF # XXX need to make msdos part for this to work XXXX - cp ${src}/boot/boot.efifat ${img}.p1 + cp ${src}/boot/boot1.efifat ${img}.p1 makefs -t ffs -B little -s 200m ${img}.p3 ${src} # p1 is boot for uefi, p2 is boot for gpt, p3 is / mkimg -b ${src}/boot/pmbr -s gpt \ @@ -219,6 +219,45 @@ } mk_nogeli_mbr_zfs_legacy() { + src=$1 + img=$2 + mntpt=$3 + geli=$4 + scheme=$5 + fs=$6 + bios=$7 + pool=nogeli-mbr-zfs-legacy + + dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512)) + md=$(mdconfig -f ${img}) + gpart create -s mbr ${md} + gpart add -t freebsd ${md} + gpart set -a active -i 1 ${md} + gpart create -s bsd ${md}s1 + gpart add -t freebsd-zfs ${md}s1 + # install-boot will make this bootable + zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}s1a + zpool set bootfs=${pool} ${pool} + zfs create -po mountpoint=/ ${pool}/ROOT/default + # NB: The online guides go nuts customizing /var and other mountpoints here, no need + cpsys ${src} ${mntpt} + df + # need to make a couple of tweaks + cat > ${mntpt}/boot/loader.conf < ${mntpt}/boot/loader.conf < ${mntpt}/etc/fstab < ${mntpt}/boot/loader.conf < ${mntpt}/etc/fstab < ${mntpt}/boot/loader.conf < ${mntpt}/etc/fstab < ${mntpt}/boot/loader.conf < ${mntpt}/boot/loader.conf < ${mntpt}/boot/loader.conf <