Download raw body.
New 'Select root disk by size' install option
For systems with more than one disk, the order of sd(4) devices make it
very likely that autoinstall will destroy a volume intended only for
data. In the following example, sd1 (at sdmmc0) is the intended target,
but if an NVMe or a second SATA devices is added, the correct choice
will become sd2:
sd0: ATA, ST5000LM000-2U81, 0001 naa.5000c500eb875982 (4657.5G)
sd1: Samsung, BJTD4R, 0000 (29.1G)
To guard against this, you really have to reboot, double-check the
device assignments, then reboot again to begin the install.
The attached patch allows autoinstall to sort disks based on expected
size. Devices between 1 and 1000GB are presented as the default choice:
Select root disk by size? (range in GB) [1-1000]
Available disks are: sd0 sd1 sd2 sd3.
Which disk is the root disk? ('?' for details) [sd2] ?
sd0: VirtIO, Block Device (0.5G)
sd1: VirtIO, Block Device (4096.0G)
sd2: VirtIO, Block Device (5.0G)
sd3: VirtIO, Block Device (10.0G)
As before, any disk may be selected, but this provides a mechanism for
picking a plausible install target.
M distrib/miniroot/install.sub | 14+ 2-
1 file changed, 14 insertions(+), 2 deletions(-)
commit - 3ef2b96be9966a1f84c2f3fa4bd67478f0f4f427
commit + c2aab348274a0ce641ccc0be6571e9cfebdee06a
blob - dea8764f006a2cdfc4fb07984009b313d0e6e4a6
blob + 8ca3676c4c316c09714179de0f749ae96dbbeb94
--- distrib/miniroot/install.sub
+++ distrib/miniroot/install.sub
@@ -2432,15 +2432,27 @@ is_rootdisk() {
# Get global root information. ie. ROOTDISK, ROOTDEV and SWAPDEV.
get_rootinfo() {
local _rootdisks=$(get_dkdevs_root) _dkdev
+ local _size_gb _size_min=1 _size_max=1000
local _q="Which disk is the root disk? ('?' for details)"
-
if [[ $MODE == install ]]; then
# Prefer disks bigger than 1G as small ones tend to be install
# media, softraid(4) key disks or tiny USB sticks or SD cards.
+ # Also avoid large storage devices if other disks are available.
+ while :; do
+ ask_until "Select root disk by size? (range in GB)" "$_size_min-$_size_max"
+ _size_min=${resp%%-*}
+ _size_max=${resp##*-}
+ [[ $_size_max -gt $_size_min ]] && break
+ echo "Invalid range"
+ done
+
for _dkdev in $_rootdisks; do
- diskinfo $_dkdev | grep -q '(0\..*G)$' &&
+ _size_gb=$(diskinfo $_dkdev | sed -E 's/.*\(([0-9]+).*\)$/\1/')
+ [[ $_size_gb -ge $_size_min ]] ||
_rootdisks="$(rmel "$_dkdev" $_rootdisks) $_dkdev"
+ [[ $_size_gb -lt $_size_max ]] ||
+ _rootdisks="$(rmel "$_dkdev" $_rootdisks) $_dkdev"
done
fi
New 'Select root disk by size' install option