Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jun 2026 12:36:03 +0000
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Cc:        Phil Krylov <phil@krylov.eu>
Subject:   git: a62eaf71ddb7 - main - bsdinstall(8): Fix GPT label conflicts with disks not managed by us
Message-ID:  <6a295a33.3c5e2.4e095571@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=a62eaf71ddb7463cf51d2be8be6506befbcfff8d

commit a62eaf71ddb7463cf51d2be8be6506befbcfff8d
Author:     Phil Krylov <phil@krylov.eu>
AuthorDate: 2025-06-22 02:39:30 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-06-10 12:35:02 +0000

    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
---
 usr.sbin/bsdinstall/scripts/zfsboot | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

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"
@@ -840,6 +841,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
 		#


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a295a33.3c5e2.4e095571>