+# {{{ SW-RAID
+config_swraid(){
+ [ -n "$INSTALLED" ] && return 0
+
+ # notice: checkbootparam "forensic" is just for users who don't know how to really use the bootoption
+ if checkbootparam 'noraid' || checkbootparam 'noswraid' || \
+ checkbootparam 'forensic' || checkbootparam 'raid=noautodetect' ; then
+ ewarn "Skipping SW-RAID code as requested on boot commandline." ; eend 0
+ else
+ if ! [ -x /sbin/mdadm ] ; then
+ eerror "mdadm not available, can not execute it." ; eend 1
+ else
+
+ # if ! egrep -qv '^(MAILADDR.*|#.*|)$' /etc/mdadm/mdadm.conf 2>>$DEBUG ; then
+ # find out whether we have a valid configuration file already
+ if ! grep -q ARRAY /etc/mdadm/mdadm.conf 2>>$DEBUG ; then
+ einfo "Creating /etc/mdadm/mdadm.conf for use with mdadm."
+ [ -r /etc/mdadm/mdadm.conf ] && mv /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf.old
+ MDADM_MAILADDR__='root' /usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf ; eend $?
+ else
+ ewarn "/etc/mdadm/mdadm.conf looks like a configured mdadm setup, will not touch it." ; eend 0
+ fi
+
+ if ! checkbootparam 'swraid' ; then
+ eindent
+ einfo "Just run 'Start mdadm-raid' to assemble md arrays or boot using 'swraid' as bootoption for autostart."
+ eoutdent
+ else
+ einfo "Bootoption swraid found. Searching for software RAID arrays:"
+ eindent
+ IFSOLD=${IFS:-}
+ IFS='
+'
+ for line in $(mdadm --assemble --scan --auto=yes --symlink=no 2>&1) ; do
+ case $line in
+ *'No arrays found'*)
+ ewarn "$line" ; eend 0
+ ;;
+ *)
+ einfo "$line" ; eend 0
+ ;;
+ esac
+ done
+ IFS=$IFSOLD
+ eoutdent
+
+ if [ -r /proc/mdstat ] ; then
+ eindent
+ MDSTAT=$(grep '^md[0-9]' /proc/mdstat)
+ if [ -z "$MDSTAT" ] ; then
+ ewarn "No active arrays found" ; eend 0
+ else
+ IFSOLD=${IFS:-}
+ IFS='
+'
+ for line in $(grep '^md[0-9]' /proc/mdstat) ; do
+ einfo "active arrays: $line" ; eend 0
+ done
+ IFS=$IFSOLD
+ fi
+ eoutdent
+ fi # /proc/mdstat
+ fi # bootoption swraid
+
+ fi # is /sbin/mdadm executable?
+ fi # check for bootoptions
+}
+# }}}
+
+# {{{ dmraid
+config_dmraid(){
+ [ -n "$INSTALLED" ] && return 0
+
+ if checkbootparam 'nodmraid' ; then
+ ewarn "Skipping dmraid code as requested on boot commandline." ; eend 0
+ return 0
+ fi
+
+ if ! [ -x /sbin/dmraid ] ; then
+ eerror "dmraid not available, can not execute it." ; eend 1
+ return
+ fi
+
+ dmraid_wrapper() {
+ # usage: dmraid_wrapper <dmraid_option>
+ [ -n "$1" ] || return 1
+
+ IFSOLD=${IFS:-}
+ IFS='
+'
+ eindent
+
+ for line in $(dmraid $1 ; echo errcode:$?); do
+ case $line in
+ *'no block devices found'*)
+ einfo "No block devices found" ; eend 0
+ break
+ ;;
+ *'no raid disks'*)
+ einfo "No active dmraid devices found" ; eend 0
+ break
+ ;;
+ errcode:0)
+ eend 0;
+ ;;
+ errcode:1)
+ eend 1
+ ;;
+ *)
+ einfo "$line"
+ ;;
+ esac
+ done
+
+ eoutdent
+ IFS=$IFSOLD
+ }
+
+ if checkbootparam 'dmraid' ; then
+ local ACTION="$(getbootparam 'dmraid' 2>>$DEBUG)"
+ if [ "$ACTION" = "off" ] ; then
+ # Deactivates all active software RAID sets:
+ einfo "Deactivating present dmraid sets (as requested via dmraid=off):"
+ dmraid_wrapper -an
+ else
+ # Activate all software RAID sets discovered:
+ einfo "Activating present dmraid sets (as requested via dmraid):"
+ dmraid_wrapper -ay
+ fi
+
+ return
+ fi
+
+ # by default (no special bootoptions) discover all software RAID devices:
+ einfo "Searching for any present dmraid sets:"
+ dmraid_wrapper -r
+}
+# }}}
+
+# {{{ LVM (Logical Volumes)
+config_lvm(){
+ [ -n "$INSTALLED" ] && return 0
+
+ if checkbootparam 'nolvm' ; then
+ ewarn "Skipping LVM code as requested on boot commandline." ; eend 0
+ else
+ # Debian etch provides /etc/init.d/lvm only, newer suites provide /etc/init.d/lvm2
+ if ! [ -x /sbin/lvm -a -x /sbin/lvdisplay ] || ! [ -x /etc/init.d/lvm2 -o -x /etc/init.d/lvm ] ; then
+ eerror "LVM not available, can not execute it." ; eend 1
+ else
+ if lvdisplay 2>&1 | grep -v 'No volume groups found' >/dev/null 2>&1 ; then
+ einfo "You seem to have logical volumes (LVM) on your system."
+ eindent
+ einfo "Just run 'Start lvm2' to activate them or boot using 'lvm' as bootoption for autostart."
+ eend 0
+ if checkbootparam 'lvm' ; then
+ einfo "Bootoption LVM found. Searching for logical volumes:"
+ /etc/init.d/lvm2 start ; eend $?
+ fi
+ eoutdent
+ fi
+ fi # check for lvm binary
+ fi # check for bootoption nolvm
+}
+# }}}
+