guess softraid as default rootdev for install/upgrade

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

guess softraid as default rootdev for install/upgrade

Jean-Philippe Ouellet
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 | Threaded
Open this post in threaded view
|

Re: guess softraid as default rootdev for install/upgrade

Stefan Sperling-5
On Wed, Nov 26, 2014 at 03:05:27AM -0500, Jean-Philippe Ouellet wrote:

> 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.

Yes, the installer doesn't support softraid automagically yet.
It does however already work well if you answer its questions correctly.
This is because the bootloaders and kernel are making softraid mostly
transparent to the installer (apart from the initial bioctl setup step).

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

Last I heard the idea was to push such logic into bioctl or a new utility
because scripting it sucks. (Perhaps jsing@ can elaborate on that?)
 
Various diffs have been suggested for RAID support in the installer,
by myself and others. So far they've been rejected because they weren't
good enough.

In your case: What if I have a RAID1 volume mounted on /storage?
I'll always get the wrong suggestion with your diff whereas it worked before.
What if I have a crypto and a RAID1 volume configured? How do you know
which one is the root disk I want to upgrade? A scripted guess is probably
just as bad as the current default.

I think this needs some support from the bootloader and kernel to work right.

>
> 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 | Threaded
Open this post in threaded view
|

Re: guess softraid as default rootdev for install/upgrade

Stuart Henderson-6
In reply to this post by Jean-Philippe Ouellet
On 2014/11/26 03:05, Jean-Philippe Ouellet wrote:
>
> 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.

softraid isn't the only place where the guessed value is incorrect;
if the information can be made available, a better default would be "the
disk you booted from".

Reply | Threaded
Open this post in threaded view
|

Re: guess softraid as default rootdev for install/upgrade

Ingo Schwarze
In reply to this post by Jean-Philippe Ouellet
Hi Jean-Philippe,

Jean-Philippe Ouellet wrote on Wed, Nov 26, 2014 at 03:05:27AM -0500:

> 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.

I don't like that.

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

But not necessarily for the root partition.

Granted, i'm using such a setup with even root on RAID on a few
machines right now, but only because some co-admins were very
strongly in favour of it, and my own inclination to avoid it
was not *that* strong.

On machines where i make the decision alone, i still keep the
operating system (root, usr, ...) and transient data (tmp, usr/obj,
var on non-server machines, ...) off RAID and only RAID user data
(home, usr/src on dev machines, var/www on webservers, ...).

Nick has explained many times what the advantages are, and why "just
RAID everything" is often indicative of a false sense of security
(or reliability, depending on the scenario), so i still think root
off RAID is the recommended way unless you have special needs.
I think the installer defaults should agree with what we recommend.

Yours,
  Ingo


> 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);;
>   '') ;;
>