Page MenuHomeFreeBSD

D3091.id6996.diff
No OneTemporary

D3091.id6996.diff

Index: usr.sbin/bsdinstall/scripts/zfsboot
===================================================================
--- usr.sbin/bsdinstall/scripts/zfsboot
+++ usr.sbin/bsdinstall/scripts/zfsboot
@@ -196,6 +196,8 @@
GPART_CREATE='gpart create -s %s "%s"'
GPART_DESTROY_F='gpart destroy -F "%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"'
LN_SF='ln -sf "%s" "%s"'
MKDIR_P='mkdir -p "%s"'
@@ -240,6 +242,7 @@
msg_freebsd_installer="FreeBSD Installer"
msg_geli_password="Enter a strong passphrase, used to protect your encryption keys. You will be required to enter this passphrase each time the system is booted"
msg_geli_setup="Initializing encryption on selected disks,\n this will take several seconds per disk"
+msg_gpt_active_fix="Your hardware is known to have issues booting from GPT partitions that are not set active. Would you like the installer to apply this workaround for you?"
msg_install="Install"
msg_install_desc="Proceed with Installation"
msg_install_help="Create ZFS boot pool with displayed options"
@@ -250,6 +253,7 @@
msg_invalid_virtual_device_type="Invalid Virtual Device type \`%s'"
msg_last_chance_are_you_sure="Last Chance! Are you sure you want to destroy\nthe current contents of the following disks:\n\n %s"
msg_last_chance_are_you_sure_color='\\ZrLast Chance!\\ZR Are you \\Z1sure\\Zn you want to \\Zr\\Z1destroy\\Zn\nthe current contents of the following disks:\n\n %s'
+msg_lenovo_fix="Your model of Lenovo is known to have a BIOS bug that prevents it booting from GPT partitions without UEFI. Would you like the installer to apply a workaround for you?"
msg_mirror_desc="Mirror - n-Way Mirroring"
msg_mirror_help="[2+ Disks] Mirroring provides the best performance, but the least storage"
msg_missing_disk_arguments="missing disk arguments"
@@ -263,7 +267,7 @@
msg_null_poolname="NULL poolname"
msg_ok="OK"
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_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:"
@@ -735,6 +739,48 @@
--yesno "$prompt" $height $width
}
+# dialog_workaround
+#
+# Ask the user if they wish to apply a workaround
+#
+dialog_workaround()
+{
+ local passed_msg="$1"
+ local title="$DIALOG_TITLE"
+ local btitle="$DIALOG_BACKTITLE"
+ local prompt # Calculated below
+ local hline="$hline_arrows_tab_enter"
+
+ local height=8 width=50 prefix=" "
+ local plen=${#prefix} list= line=
+ local max_width=$(( $width - 3 - $plen ))
+
+ local yes no defaultno extra_args format
+ if [ "$USE_XDIALOG" ]; then
+ yes=ok no=cancel defaultno=default-no
+ extra_args="--wrap --left"
+ format="$passed_msg"
+ else
+ yes=yes no=no defaultno=defaultno
+ extra_args="--cr-wrap"
+ format="$passed_msg"
+ fi
+
+ # Add height for Xdialog(1)
+ [ "$USE_XDIALOG" ] && height=$(( $height + $height / 5 + 3 ))
+
+ prompt=$( printf "$format" )
+ f_dprintf "%s: Workaround prompt" "$0"
+ $DIALOG \
+ --title "$title" \
+ --backtitle "$btitle" \
+ --hline "$hline" \
+ --$yes-label "$msg_yes" \
+ --$no-label "$msg_no" \
+ $extra_args \
+ --yesno "$prompt" $height $width
+}
+
# zfs_create_diskpart $disk $index
#
# For each block device to be used in the zpool, rather than just create the
@@ -779,7 +825,7 @@
# Check for unknown partition scheme before proceeding further
case "$ZFSBOOT_PARTITION_SCHEME" in
- ""|MBR|GPT) : known good ;;
+ ""|MBR|GPT*) : known good ;;
*)
f_dprintf "$funcname: %s is an unsupported partition scheme" \
"$ZFSBOOT_PARTITION_SCHEME"
@@ -826,7 +872,7 @@
fi
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
#
@@ -834,6 +880,17 @@
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#'
#
f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_LABEL_WITH_SIZE" \
@@ -1463,6 +1520,45 @@
fi
#
+# Try to detect known broken platforms and apply their workarounds
+#
+
+if f_interactive; then
+ sys_maker=$( kenv -q smbios.system.maker )
+ f_dprintf "smbios.system.maker=[%s]" "$sys_maker"
+ sys_model=$( smbios.system.product )
+ f_dprintf "smbios.system.product=[%s]" "$sys_model"
+ sys_version=$( kenv -q smbios.system.version )
+ f_dprintf "smbios.system.version=[%s]" "$sys_version"
+ case "$sys_maker" in
+ "LENOVO")
+ case "$sys_version" in
+ "ThinkPad X220"|"ThinkPad T420"|"ThinkPad T520")
+ dialog_workaround "$msg_lenovo_fix"
+ retval=$?
+ f_dprintf "lenovofix_prompt=[%s]" "$retval"
+ if [ $retval -eq $DIALOG_OK ]; then
+ ZFSBOOT_PARTITION_SCHEME="GPT + Lenovo Fix"
+ fi
+ ;;
+ esac
+ ;;
+ "Dell Inc.")
+ case "$sys_model" in
+ "Latitude E7440")
+ dialog_workaround "$msg_gpt_active_fix"
+ retval=$?
+ f_dprintf "gpt_active_fix_prompt=[%s]" "$retval"
+ if [ $retval -eq $DIALOG_OK ]; then
+ ZFSBOOT_PARTITION_SCHEME="GPT + Active"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+fi
+
+#
# Loop over the main menu until we've accomplished what we came here to do
#
while :; do
@@ -1584,6 +1680,10 @@
# Toggle between GPT and MBR
if [ "$ZFSBOOT_PARTITION_SCHEME" = GPT ]; then
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
ZFSBOOT_PARTITION_SCHEME=GPT
fi

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 22, 12:59 PM (21 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31980538
Default Alt Text
D3091.id6996.diff (6 KB)

Event Timeline