Hi,

Currently disks can only be entered in the [sw]d[0-9][0-9] format at the
"Which disk is the root disk?" prompt. This is great for humans, but
things get tricky when doing an autoinstall upgrade on systems where
connected disks change frequently.

This diff lets you put the DUID in the response file.

If anyone has a better way to determine the disk from the duid, I am all
ears :D

Cheers,
Aaron

Index: distrib/miniroot/install.sub
===================================================================
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1065
diff -u -p -r1.1065 install.sub
--- distrib/miniroot/install.sub        21 Feb 2018 20:02:37 -0000      1.1065
+++ distrib/miniroot/install.sub        2 Mar 2018 14:03:45 -0000
@@ -2201,6 +2201,24 @@ set_timezone() {
        done
 }

+# Determine the disk name from supplied disk uid.
+# - If our supplied value doesn't match the uid RE,
+#   assume it is a disk.
+duid_to_disk() {
+       local _in=$1 _tdisk _disk
+
+       echo "$_in" | sed -n '/^[a-f0-9]\{16\}/p' | grep -q "$_in"
+       if (($? == 0)); then
+               _tdisk=$(disklabel "$_in" | grep "^# /dev")
+               _tdisk=${_tdisk##* /dev/r}
+               _disk=${_tdisk%%c:*}
+
+               echo $_disk
+       else
+               echo $_in
+       fi
+}
+
 # Determine if the supplied disk is a potential root disk, by:
 # - Check the disklabel if there is an 'a' partition of type 4.2BSD
 # - Mount the partition (read-only) and look for typical root filesystem layout
@@ -2231,7 +2249,8 @@ get_rootinfo() {
                case $resp in
                "?")    diskinfo $(get_dkdevs);;
                '')     ;;
-               *)      if isin "$resp" $(get_dkdevs); then
+               *)      resp=$(duid_to_disk "$resp")
+                       if isin "$resp" $(get_dkdevs); then
                                [[ $MODE == install ]] && break
                                is_rootdisk "$resp" && break
                                echo "$resp is not a valid root disk."

--
PGP: 0x1F81112D62A9ADCE / 3586 3350 BFEA C101 DB1A  4AF0 1F81 112D 62A9 ADCE

Reply via email to