aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Krylov <phil@krylov.eu>2025-06-22 02:39:30 +0000
committerWarner Losh <imp@FreeBSD.org>2026-06-10 12:35:02 +0000
commita62eaf71ddb7463cf51d2be8be6506befbcfff8d (patch)
tree5ce859dde13d323d68cb82bbf84c7bd461cb03d5
parent925f53682469ea12c017b48114b16e8f1627fb0b (diff)
bsdinstall(8): Fix GPT label conflicts with disks not managed by us
Signed-off-by: Phil Krylov <phil@krylov.eu> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1735
-rwxr-xr-xusr.sbin/bsdinstall/scripts/zfsboot19
1 files changed, 19 insertions, 0 deletions
diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot
index a973b03d17fd..dbf7e19c6f5b 100755
--- a/usr.sbin/bsdinstall/scripts/zfsboot
+++ b/usr.sbin/bsdinstall/scripts/zfsboot
@@ -242,6 +242,7 @@ ZPOOL_SET='zpool set %s "%s"'
hline_alnum_arrows_punc_tab_enter="Use alnum, arrows, punctuation, TAB or ENTER"
hline_arrows_space_tab_enter="Use arrows, SPACE, TAB or ENTER"
hline_arrows_tab_enter="Press arrows, TAB or ENTER"
+msg_all_possible_gpt_labels_already_taken="All possible GPT labels already taken"
msg_an_unknown_error_occurred="An unknown error occurred"
msg_back="Back"
msg_cancel="Cancel"
@@ -841,6 +842,24 @@ zfs_create_diskpart()
case "$ZFSBOOT_PARTITION_SCHEME" in
""|GPT*) f_dprintf "$funcname: Creating GPT layout..."
#
+ # 0. Check for potential GPT label conflicts with disks not
+ # managed by us and adjust $index accordingly
+ #
+ while [ -e /dev/gpt/efiboot$index ] ||
+ [ -e /dev/gpt/gptboot$index ] ||
+ [ -e /dev/gpt/boot$index ] ||
+ [ -e /dev/gpt/swap$index ] ||
+ [ -e /dev/gpt/zfs$index ]; do
+ index=$(( $index + 1 ))
+ if [ $index -ge 4096 ]; then
+ f_dprintf "$funcname: all possible GPT labels already taken"
+ msg_error="$msg_error: $funcname" f_show_err \
+ "$msg_all_possible_gpt_labels_already_taken"
+ return $FAILURE
+ fi
+ done
+
+ #
# 1. Create GPT layout using labels
#
f_eval_catch $funcname gpart "$GPART_CREATE" gpt $disk ||