Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/bsdinstall/scripts/zfsboot
Show First 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | |||||
GPART_ADD_ALIGN_INDEX_WITH_SIZE='gpart add %s -i %s -t %s -s %s "%s"' | GPART_ADD_ALIGN_INDEX_WITH_SIZE='gpart add %s -i %s -t %s -s %s "%s"' | ||||
GPART_ADD_ALIGN_LABEL='gpart add %s -l %s -t %s "%s"' | GPART_ADD_ALIGN_LABEL='gpart add %s -l %s -t %s "%s"' | ||||
GPART_ADD_ALIGN_LABEL_WITH_SIZE='gpart add %s -l %s -t %s -s %s "%s"' | GPART_ADD_ALIGN_LABEL_WITH_SIZE='gpart add %s -l %s -t %s -s %s "%s"' | ||||
GPART_BOOTCODE='gpart bootcode -b "%s" "%s"' | GPART_BOOTCODE='gpart bootcode -b "%s" "%s"' | ||||
GPART_BOOTCODE_PART='gpart bootcode -b "%s" -p "%s" -i %s "%s"' | GPART_BOOTCODE_PART='gpart bootcode -b "%s" -p "%s" -i %s "%s"' | ||||
GPART_CREATE='gpart create -s %s "%s"' | GPART_CREATE='gpart create -s %s "%s"' | ||||
GPART_DESTROY_F='gpart destroy -F "%s"' | GPART_DESTROY_F='gpart destroy -F "%s"' | ||||
GPART_SET_ACTIVE='gpart set -a active -i %s "%s"' | GPART_SET_ACTIVE='gpart set -a active -i %s "%s"' | ||||
GPART_SET_LENOVOFIX='gpart set -a lenovofix "%s"' | |||||
GPART_SET_PMBR_ACTIVE='gpart set -a active "%s"' | |||||
GRAID_DELETE='graid delete "%s"' | GRAID_DELETE='graid delete "%s"' | ||||
LN_SF='ln -sf "%s" "%s"' | LN_SF='ln -sf "%s" "%s"' | ||||
MKDIR_P='mkdir -p "%s"' | MKDIR_P='mkdir -p "%s"' | ||||
MOUNT_TYPE='mount -t %s "%s" "%s"' | MOUNT_TYPE='mount -t %s "%s" "%s"' | ||||
PRINTF_CONF="printf '%s=\"%%s\"\\\n' %s >> \"%s\"" | PRINTF_CONF="printf '%s=\"%%s\"\\\n' %s >> \"%s\"" | ||||
PRINTF_FSTAB='printf "$FSTAB_FMT" "%s" "%s" "%s" "%s" "%s" "%s" >> "%s"' | PRINTF_FSTAB='printf "$FSTAB_FMT" "%s" "%s" "%s" "%s" "%s" "%s" >> "%s"' | ||||
SHELL_TRUNCATE=':> "%s"' | SHELL_TRUNCATE=':> "%s"' | ||||
SWAP_GMIRROR_LABEL='gmirror label swap %s' | SWAP_GMIRROR_LABEL='gmirror label swap %s' | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
msg_no_disks_present_to_configure="No disk(s) present to configure" | msg_no_disks_present_to_configure="No disk(s) present to configure" | ||||
msg_no_disks_selected="No disks selected." | msg_no_disks_selected="No disks selected." | ||||
msg_not_enough_disks_selected="Not enough disks selected. (%u < %u minimum)" | msg_not_enough_disks_selected="Not enough disks selected. (%u < %u minimum)" | ||||
msg_null_disk_argument="NULL disk argument" | msg_null_disk_argument="NULL disk argument" | ||||
msg_null_index_argument="NULL index argument" | msg_null_index_argument="NULL index argument" | ||||
msg_null_poolname="NULL poolname" | msg_null_poolname="NULL poolname" | ||||
msg_ok="OK" | msg_ok="OK" | ||||
msg_partition_scheme="Partition Scheme" | msg_partition_scheme="Partition Scheme" | ||||
msg_partition_scheme_help="Toggle between GPT and MBR partitioning schemes" | msg_partition_scheme_help="Select partitioning scheme. GPT is recommended." | ||||
msg_please_enter_a_name_for_your_zpool="Please enter a name for your zpool:" | msg_please_enter_a_name_for_your_zpool="Please enter a name for your zpool:" | ||||
msg_please_enter_amount_of_swap_space="Please enter amount of swap space (SI-Unit suffixes\nrecommended; e.g., \`2g' for 2 Gigabytes):" | msg_please_enter_amount_of_swap_space="Please enter amount of swap space (SI-Unit suffixes\nrecommended; e.g., \`2g' for 2 Gigabytes):" | ||||
msg_please_select_one_or_more_disks="Please select one or more disks to create a zpool:" | msg_please_select_one_or_more_disks="Please select one or more disks to create a zpool:" | ||||
msg_pool_name="Pool Name" | msg_pool_name="Pool Name" | ||||
msg_pool_name_cannot_be_empty="Pool name cannot be empty." | msg_pool_name_cannot_be_empty="Pool name cannot be empty." | ||||
msg_pool_name_help="Customize the name of the zpool to be created (Required)" | msg_pool_name_help="Customize the name of the zpool to be created (Required)" | ||||
msg_pool_type_disks="Pool Type/Disks:" | msg_pool_type_disks="Pool Type/Disks:" | ||||
msg_pool_type_disks_help="Choose type of ZFS Virtual Device and disks to use (Required)" | msg_pool_type_disks_help="Choose type of ZFS Virtual Device and disks to use (Required)" | ||||
▲ Show 20 Lines • Show All 499 Lines • ▼ Show 20 Lines | if ! f_isinteger "$index"; then | ||||
msg_error="$msg_error: $funcname" \ | msg_error="$msg_error: $funcname" \ | ||||
f_show_err "$msg_invalid_index_argument" "$index" | f_show_err "$msg_invalid_index_argument" "$index" | ||||
return $FAILURE | return $FAILURE | ||||
fi | fi | ||||
f_dprintf "$funcname: disk=[%s] index=[%s]" "$disk" "$index" | f_dprintf "$funcname: disk=[%s] index=[%s]" "$disk" "$index" | ||||
# Check for unknown partition scheme before proceeding further | # Check for unknown partition scheme before proceeding further | ||||
case "$ZFSBOOT_PARTITION_SCHEME" in | case "$ZFSBOOT_PARTITION_SCHEME" in | ||||
""|MBR|GPT) : known good ;; | ""|MBR|GPT*) : known good ;; | ||||
*) | *) | ||||
f_dprintf "$funcname: %s is an unsupported partition scheme" \ | f_dprintf "$funcname: %s is an unsupported partition scheme" \ | ||||
"$ZFSBOOT_PARTITION_SCHEME" | "$ZFSBOOT_PARTITION_SCHEME" | ||||
msg_error="$msg_error: $funcname" f_show_err \ | msg_error="$msg_error: $funcname" f_show_err \ | ||||
"$msg_unsupported_partition_scheme" \ | "$msg_unsupported_partition_scheme" \ | ||||
"$ZFSBOOT_PARTITION_SCHEME" | "$ZFSBOOT_PARTITION_SCHEME" | ||||
return $FAILURE | return $FAILURE | ||||
esac | esac | ||||
Show All 30 Lines | zfs_create_diskpart() | ||||
# the system fails to boot. | # the system fails to boot. | ||||
# | # | ||||
if [ "$ZFSBOOT_FORCE_4K_SECTORS" ]; then | if [ "$ZFSBOOT_FORCE_4K_SECTORS" ]; then | ||||
align_small="-a 4k" | align_small="-a 4k" | ||||
align_big="-a 1m" | align_big="-a 1m" | ||||
fi | fi | ||||
case "$ZFSBOOT_PARTITION_SCHEME" in | case "$ZFSBOOT_PARTITION_SCHEME" in | ||||
""|GPT) f_dprintf "$funcname: Creating GPT layout..." | ""|GPT*) f_dprintf "$funcname: Creating GPT layout..." | ||||
# | # | ||||
# 1. Create GPT layout using labels | # 1. Create GPT layout using labels | ||||
# | # | ||||
f_eval_catch $funcname gpart "$GPART_CREATE" gpt $disk || | f_eval_catch $funcname gpart "$GPART_CREATE" gpt $disk || | ||||
return $FAILURE | return $FAILURE | ||||
# | # | ||||
# Apply workarounds if requested by the user | |||||
# | |||||
if [ "$ZFSBOOT_PARTITION_SCHEME" = "GPT + Lenovo Fix" ]; then | |||||
f_eval_catch $funcname gpart "$GPART_SET_LENOVOFIX" \ | |||||
$disk || return $FAILURE | |||||
elif [ "$ZFSBOOT_PARTITION_SCHEME" = "GPT + Active" ]; then | |||||
f_eval_catch $funcname gpart "$GPART_SET_PMBR_ACTIVE" \ | |||||
$disk || return $FAILURE | |||||
fi | |||||
# | |||||
# 2. Add small freebsd-boot partition labeled `boot#' | # 2. Add small freebsd-boot partition labeled `boot#' | ||||
# | # | ||||
f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_LABEL_WITH_SIZE" \ | f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_LABEL_WITH_SIZE" \ | ||||
"$align_small" gptboot$index freebsd-boot 512k $disk || | "$align_small" gptboot$index freebsd-boot 512k $disk || | ||||
return $FAILURE | return $FAILURE | ||||
f_eval_catch $funcname gpart "$GPART_BOOTCODE_PART" \ | f_eval_catch $funcname gpart "$GPART_BOOTCODE_PART" \ | ||||
/boot/pmbr /boot/gptzfsboot 1 $disk || | /boot/pmbr /boot/gptzfsboot 1 $disk || | ||||
return $FAILURE | return $FAILURE | ||||
▲ Show 20 Lines • Show All 734 Lines • ▼ Show 20 Lines | else | ||||
ZFSBOOT_FORCE_4K_SECTORS=1 | ZFSBOOT_FORCE_4K_SECTORS=1 | ||||
ZFSBOOT_GELI_ENCRYPTION=1 | ZFSBOOT_GELI_ENCRYPTION=1 | ||||
fi | fi | ||||
;; | ;; | ||||
?" $msg_partition_scheme") | ?" $msg_partition_scheme") | ||||
# Toggle between GPT and MBR | # Toggle between GPT and MBR | ||||
if [ "$ZFSBOOT_PARTITION_SCHEME" = GPT ]; then | if [ "$ZFSBOOT_PARTITION_SCHEME" = GPT ]; then | ||||
ZFSBOOT_PARTITION_SCHEME=MBR | ZFSBOOT_PARTITION_SCHEME=MBR | ||||
elif [ "$ZFSBOOT_PARTITION_SCHEME" = MBR ]; then | |||||
ZFSBOOT_PARTITION_SCHEME="GPT + Active" | |||||
elif [ "$ZFSBOOT_PARTITION_SCHEME" = "GPT + Active" ]; then | |||||
ZFSBOOT_PARTITION_SCHEME="GPT + Lenovo Fix" | |||||
else | else | ||||
ZFSBOOT_PARTITION_SCHEME=GPT | ZFSBOOT_PARTITION_SCHEME=GPT | ||||
fi | fi | ||||
;; | ;; | ||||
?" $msg_swap_size") | ?" $msg_swap_size") | ||||
# Prompt the user to input/change the swap size for each disk | # Prompt the user to input/change the swap size for each disk | ||||
while :; do | while :; do | ||||
f_dialog_input input \ | f_dialog_input input \ | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |