Index: usr.sbin/bsdinstall/scripts/zfsboot =================================================================== --- usr.sbin/bsdinstall/scripts/zfsboot (revision 297697) +++ usr.sbin/bsdinstall/scripts/zfsboot (working copy) @@ -112,7 +118,7 @@ : ${ZFSBOOT_PARTITION_SCHEME:=} # -# Default partitioning scheme to use on disks +# Default boot type to use on disks # : ${ZFSBOOT_BOOT_TYPE:=} @@ -755,6 +761,21 @@ esac # + # Enable boot pool if encryption is desired + # + [ "$ZFSBOOT_GELI_ENCRYPTION" ] && ZFSBOOT_BOOT_POOL=1 + + # + # ZFSBOOT_BOOT_POOL and BIOS+UEFI boot type are incompatible + # + if [ "$ZFSBOOT_BOOT_POOL" -a "$ZFSBOOT_BOOT_TYPE" = "BIOS+UEFI" ]; then + f_dprintf "$funcname: ZFSBOOT_BOOT_POOL is incompatible with BIOS+UEFI boot type" + msg_error="$msg_error: $funcname" f_show_err \ + "ZFSBOOT_BOOT_POOL is incompatible with BIOS+UEFI boot type" + return $FAILURE + fi + + # # Destroy whatever partition layout is currently on disk. # NOTE: `-F' required to destroy if partitions still exist. # NOTE: Failure is ok here, blank disk will have nothing to destroy. @@ -769,11 +790,6 @@ f_eval_catch -d $funcname gpart "$GPART_DESTROY_F" $disk # - # Enable boot pool if encryption is desired - # - [ "$ZFSBOOT_GELI_ENCRYPTION" ] && ZFSBOOT_BOOT_POOL=1 - - # # Lay down the desired type of partition scheme # local setsize mbrindex align_small align_big @@ -813,7 +829,7 @@ # # 2. Add small freebsd-boot or efi partition # - if [ "$ZFSBOOT_BOOT_TYPE" = "UEFI" ]; then + if [ "$ZFSBOOT_BOOT_TYPE" = "UEFI" -o "$ZFSBOOT_BOOT_TYPE" = "BIOS+UEFI" ]; then f_eval_catch $funcname gpart \ "$GPART_ADD_ALIGN_LABEL_WITH_SIZE" \ "$align_small" efiboot$index efi 800k $disk || @@ -821,19 +837,32 @@ f_eval_catch $funcname gpart "$GPART_BOOTCODE_PARTONLY" \ /boot/boot1.efifat 1 $disk || return $FAILURE - else + fi + + if [ "$ZFSBOOT_BOOT_TYPE" = "BIOS" -o "$ZFSBOOT_BOOT_TYPE" = "BIOS+UEFI" ]; then f_eval_catch $funcname gpart \ "$GPART_ADD_ALIGN_LABEL_WITH_SIZE" \ "$align_small" gptboot$index freebsd-boot \ 512k $disk || return $FAILURE - f_eval_catch $funcname gpart "$GPART_BOOTCODE_PART" \ - /boot/pmbr /boot/gptzfsboot 1 $disk || - return $FAILURE + if [ "$ZFSBOOT_BOOT_TYPE" = "BIOS" ]; then + f_eval_catch $funcname gpart "$GPART_BOOTCODE_PART" \ + /boot/pmbr /boot/gptzfsboot 1 $disk || + return $FAILURE + else + f_eval_catch $funcname gpart "$GPART_BOOTCODE_PART" \ + /boot/pmbr /boot/gptzfsboot 2 $disk || + return $FAILURE + fi fi # NB: zpool will use the `zfs#' GPT labels - bootpart=p2 swappart=p2 targetpart=p2 - [ ${swapsize:-0} -gt 0 ] && targetpart=p3 + if [ "$ZFSBOOT_BOOT_TYPE" = "BIOS+UEFI" ]; then + bootpart=p3 swappart=p3 targetpart=p3 + [ ${swapsize:-0} -gt 0 ] && targetpart=p4 + else + bootpart=p2 swappart=p2 targetpart=p2 + [ ${swapsize:-0} -gt 0 ] && targetpart=p3 + fi # # Prepare boot pool if enabled (e.g., for geli(8)) @@ -1256,6 +1285,8 @@ f_dprintf "$funcname: Modifying directory permissions..." local dir for dir in /tmp /var/tmp; do + f_eval_catch $funcname mkdir "$MKDIR_P" \ + $BSDINSTALL_CHROOT$dir || return $FAILURE f_eval_catch $funcname chmod "$CHMOD_MODE" 1777 \ $BSDINSTALL_CHROOT$dir || return $FAILURE done @@ -1572,6 +1603,9 @@ if [ "$ZFSBOOT_PARTITION_SCHEME" = "GPT" -a "$ZFSBOOT_BOOT_TYPE" = "BIOS" ]; then ZFSBOOT_PARTITION_SCHEME="GPT" ZFSBOOT_BOOT_TYPE="UEFI" + elif [ "$ZFSBOOT_PARTITION_SCHEME" = "GPT" -a "$ZFSBOOT_BOOT_TYPE" = "UEFI" ]; then + ZFSBOOT_PARTITION_SCHEME="GPT" + ZFSBOOT_BOOT_TYPE="BIOS+UEFI" elif [ "$ZFSBOOT_PARTITION_SCHEME" = "GPT" ]; then ZFSBOOT_PARTITION_SCHEME="MBR" ZFSBOOT_BOOT_TYPE="BIOS"