Hello,

Finally found some free time.

What would you think of making the "Which disk is the root disk?"
question default to the first softraid device you have configured,
if any.

The thinking is if you bothered to actually configure a softraid
device, it's probably because you actually intend to use it, right?

Whenever I use softraid (either for crypto, or actual raid) it's
always held my / ever since booting from it has been supported.
I suspect this may be the case for others as wells.

If you think this describes the majority of softraid users, then
I propose the following:


Index: install.sub
===================================================================
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.799
diff -u -p -r1.799 install.sub
--- install.sub 18 Nov 2014 19:00:16 -0000      1.799
+++ install.sub 25 Nov 2014 14:05:15 -0000
@@ -149,15 +149,23 @@ scan_dmesg() {
 
 scan_disknames() {
        local IFS=,
-       bsort $(for _n in $(sysctl -n hw.disknames); do echo "${_n%%:*} "; done 
| sed -n "$1")
+       bsort $(for _n in $(sysctl -n hw.disknames); do echo "${_n%%:*} "; done)
 }
 
-get_dkdevs () {
-       echo $(scan_disknames "${MDDKDEVS:-/^[sw]d[0-9][0-9]* /s/ .*//p}")
+filter_dkdevs() {
+       sed -n "${MDDKDEVS:-/^[sw]d[0-9][0-9]* /s/ .*//p}"
 }
 
-get_cddevs () {
-       echo $(scan_disknames "${MDCDDEVS:-/^cd[0-9][0-9]* /s/ .*//p}")
+filter_cddevs() {
+       sed -n "${MDCDDEVS:-/^cd[0-9][0-9]* /s/ .*//p}"
+}
+
+get_dkdevs() {
+       echo $(scan_disknames | filter_dkdevs)
+}
+
+get_cddevs() {
+       echo $(scan_disknames | filter_cddevs)
 }
 
 get_ifdevs() {
@@ -166,6 +174,13 @@ get_ifdevs() {
                sed -n 's/^\(.*\):.*/\1/p'
 }
 
+guess_rootdev() {
+       local _raid _dev
+       _raid=$(bioctl -i softraid0 2>/dev/null | grep ^softraid)
+       _dev=$(for _n in $_raid; do echo "$_n "; done | filter_dkdevs | sed 1q)
+       [ -n "$_dev" ] && echo "$_dev" || get_dkdevs | sed 's/ .*//'
+}
+
 get_drive() {
        ask_which "$1" "contains the $MODE media" "$2" "$3"
        [[ $resp == done ]] && return 1
@@ -2249,7 +2264,7 @@ diskinfo() {
 while :; do
        echo "Available disks are: $(get_dkdevs | sed 's/^$/none/')."
        _ask "Which disk is the root disk? ('?' for details)" \
-               $(get_dkdevs | sed 's/ .*//') || continue
+               $(guess_rootdev) || continue
        case $resp in
        "?")    diskinfo $(get_dkdevs);;
        '')     ;;

Reply via email to