Here is a patch that adds support for RAID6 and RAID10 to the debian installer.
-- _________________________ Ryan Niebur [EMAIL PROTECTED]
Index: kernel/kernel-wedge/modules/md-modules =================================================================== --- kernel/kernel-wedge/modules/md-modules (revision 54408) +++ kernel/kernel-wedge/modules/md-modules (working copy) @@ -8,6 +8,7 @@ raid1 raid5 ? raid456 ? +raid10 xor dm-mirror ? dm-snapshot ? Index: mdcfg/debian/mdcfg-utils.templates =================================================================== --- mdcfg/debian/mdcfg-utils.templates (revision 54408) +++ mdcfg/debian/mdcfg-utils.templates (working copy) @@ -47,7 +47,7 @@ Type: select # :sl3: # flag:translate:4 -__Choices: RAID0, RAID1, RAID5, Cancel +__Choices: RAID0, RAID1, RAID5, RAID6, RAID10, Cancel # :sl3: _Description: Multidisk device type: Please choose the type of the multidisk device to be created. @@ -107,6 +107,80 @@ devices, the remaining partitions will be added to the array as "missing". You will be able to add them later to the array. +Template: mdcfg/raid6devcount +Type: string +# :sl3: +_Description: Number of active devices for the RAID6 array: + The RAID6 array will consist of both active and spare partitions. The active + partitions are those used, while the spare devices will only be used if one or + more of the active devices fail. A minimum of three active devices is + required. + . + NOTE: this setting cannot be changed later. + +Template: mdcfg/raid6sparecount +Type: string +# :sl3: +_Description: Number of spare devices for the RAID6 array: + +Template: mdcfg/raid6sparedevs +Type: multiselect +Choices: ${PARTITIONS} +# :sl3: +_Description: Spare devices for the RAID6 multidisk device: + You have chosen to create an RAID6 array with ${COUNT} spare devices. + . + Please choose which partitions will be used as spare devices. + You may choose up to ${COUNT} partitions. If you choose less than ${COUNT} + devices, the remaining partitions will be added to the array as "missing". + You will be able to add them later to the array. + +Template: mdcfg/raid10layout +Type: string +# :sl3: +_Description: Layout of the RAID10 multidisk device: + The layout must be n, o, or f followed by a number. + . + The number is the number of copies of each chunk. + It has to be equal to or smaller than the number of active devices. + . + The letter is the arrangement of the copies. + n - near copies: Multiple copies of one data block are at similar offsets in different devices. + f - far copies: Multiple copies have very different offsets + o - offset copies: Rather than the chunks being duplicated within a stripe, whole stripes are duplicated but are rotated by one device so duplicate blocks are on different devices. + . + The default setting is n2. + . + NOTE: this setting cannot be changed later. + +Template: mdcfg/raid10devcount +Type: string +# :sl3: +_Description: Number of active devices for the RAID10 array: + The RAID10 array will consist of both active and spare partitions. The active + partitions are those used, while the spare devices will only be used if one or + more of the active devices fail. A minimum of four active devices is + required. + . + NOTE: this setting cannot be changed later. + +Template: mdcfg/raid10sparecount +Type: string +# :sl3: +_Description: Number of spare devices for the RAID10 array: + +Template: mdcfg/raid10sparedevs +Type: multiselect +Choices: ${PARTITIONS} +# :sl3: +_Description: Spare devices for the RAID10 multidisk device: + You have chosen to create an RAID10 array with ${COUNT} spare devices. + . + Please choose which partitions will be used as spare devices. + You may choose up to ${COUNT} partitions. If you choose less than ${COUNT} + devices, the remaining partitions will be added to the array as "missing". + You will be able to add them later to the array. + Template: mdcfg/raid0devs Type: multiselect Choices: ${PARTITIONS} @@ -135,6 +209,26 @@ Please choose which partitions are active devices. You must select exactly ${COUNT} partitions. +Template: mdcfg/raid6devs +Type: multiselect +Choices: ${PARTITIONS} +# :sl3: +_Description: Active devices for the RAID6 multidisk device: + You have chosen to create an RAID6 array with ${COUNT} active devices. + . + Please choose which partitions are active devices. + You must select exactly ${COUNT} partitions. + +Template: mdcfg/raid10devs +Type: multiselect +Choices: ${PARTITIONS} +# :sl3: +_Description: Active devices for the RAID10 multidisk device: + You have chosen to create an RAID10 array with ${COUNT} active devices. + . + Please choose which partitions are active devices. + You must select exactly ${COUNT} partitions. + Template: mdcfg/deletemenu Type: select # :sl3: Index: mdcfg/mdcfg.sh =================================================================== --- mdcfg/mdcfg.sh (revision 54408) +++ mdcfg/mdcfg.sh (working copy) @@ -102,70 +102,10 @@ return fi - case "$RAID_SEL" in - RAID5) - md_create_raid5 ;; - RAID1) - md_create_raid1 ;; - RAID0) - md_create_raid0 ;; - esac + md_create_array "$RAID_SEL" fi } -# This will set PARTITIONS and NUM_PART global variables -get_partitions() { - PARTITIONS="" - - # Get a list of RAID partitions. This only works if there is no - # filesystem on the partitions, which is fine by us. - RAW_PARTITIONS=$(/usr/lib/partconf/find-partitions --ignore-fstype 2>/dev/null | \ - grep "[[:space:]]RAID[[:space:]]" | cut -f1) - - # Convert it into a proper list form for a select question - # (comma seperated) - NUM_PART=0 - for i in $RAW_PARTITIONS; do - DEV=$(echo $i | sed -e "s/\/dev\///") - REALDEV=$(mapdevfs "$i") - MAPPEDDEV=$(echo "$REALDEV" | sed -e "s/\/dev\///") - - if grep -Eq "($DEV|$MAPPEDDEV)" /proc/mdstat; then - continue - fi - - PARTITIONS="${PARTITIONS:+$PARTITIONS, }$REALDEV" - NUM_PART=$(($NUM_PART + 1)) - done - - if [ -z "$PARTITIONS" ]; then - db_input critical mdcfg/noparts - db_go - return 1 - fi - return 0 -} - -prune_partitions() { - CHOSEN="$1" - OLDIFS="$IFS" - IFS=, - NEW_PARTITIONS="" - for i in $PARTITIONS; do - found=0 - for j in $CHOSEN; do - if [ "$i" = "$j" ]; then - found=1 - fi - done - if [ $found -eq 0 ]; then - NEW_PARTITIONS="${NEW_PARTITIONS:+$NEW_PARTITIONS,}$i" - fi - done - IFS=$OLDIFS - PARTITIONS=$NEW_PARTITIONS -} - md_create_raid0() { db_subst mdcfg/raid0devs PARTITIONS "$PARTITIONS" db_set mdcfg/raid0devs "" @@ -199,66 +139,104 @@ -n $SELECTED $RAID_DEVICES } -md_create_raid1() { +md_create_array(){ OK=0 - db_set mdcfg/raid1devcount 2 + case "$1" in + RAID10) + MIN_SIZE=2 ;; + RAID6) + MIN_SIZE=4 ;; + RAID5) + MIN_SIZE=3 ;; + RAID1) + MIN_SIZE=2 ;; + RAID0) + md_create_raid0; return ;; + *) + return ;; + esac + LEVEL=$(echo "$1" | sed s/RAID//) + + DEFAULT="$MIN_SIZE" + if [ "$LEVEL" = "10" ]; then + DEFAULT=4 + fi + + db_set mdcfg/raid${LEVEL}devcount "$DEFAULT" + # Get the count of active devices while [ $OK -eq 0 ]; do - db_input critical mdcfg/raid1devcount + db_input critical mdcfg/raid${LEVEL}devcount db_go if [ $? -eq 30 ]; then return fi # Figure out, if the user entered a number - db_get mdcfg/raid1devcount + db_get mdcfg/raid${LEVEL}devcount RET=$(echo $RET | sed -e "s/[[:space:]]//g") if [ "$RET" ]; then let "OK=${RET}>0 && ${RET}<99" fi done - db_set mdcfg/raid1sparecount "0" + + db_set mdcfg/raid${LEVEL}sparecount "0" OK=0 # Same procedure as above, but get the number of spare partitions # this time. # TODO: Make a general function for this kind of stuff while [ $OK -eq 0 ]; do - db_input critical mdcfg/raid1sparecount + db_input critical mdcfg/raid${LEVEL}sparecount db_go if [ $? -eq 30 ]; then return fi - db_get mdcfg/raid1sparecount + db_get mdcfg/raid${LEVEL}sparecount RET=$(echo $RET | sed -e "s/[[:space:]]//g") if [ "$RET" ]; then let "OK=${RET}>=0 && ${RET}<99" fi done - db_get mdcfg/raid1devcount + db_get mdcfg/raid${LEVEL}devcount DEV_COUNT="$RET" - db_get mdcfg/raid1sparecount + if [ "$LEVEL" -ne "1" ]; then + if [ $DEV_COUNT -lt $MIN_SIZE ]; then + DEV_COUNT=$MIN_SIZE # Minimum number for the selected RAID level + fi + fi + db_get mdcfg/raid${LEVEL}sparecount SPARE_COUNT="$RET" REQUIRED=$(($DEV_COUNT + $SPARE_COUNT)) + if [ "$LEVEL" -ne "1" ]; then + if [ $REQUIRED -gt $NUM_PART ]; then + db_subst mdcfg/notenoughparts NUM_PART "$NUM_PART" + db_subst mdcfg/notenoughparts REQUIRED "$REQUIRED" + db_input critical mdcfg/notenoughparts + db_go mdcfg/notenoughparts + return + fi + fi - db_set mdcfg/raid1devs "" + db_set mdcfg/raid${LEVEL}devs "" SELECTED=0 - # Loop until at least one device has been selected - until [ $SELECTED -gt 0 ] && [ $SELECTED -le $DEV_COUNT ]; do - db_subst mdcfg/raid1devs COUNT "$DEV_COUNT" - db_subst mdcfg/raid1devs PARTITIONS "$PARTITIONS" - db_input critical mdcfg/raid1devs + # Loop until the correct number of active devices has been selected for RAID 5 and 10 + # Loop until at least one device has been selected for RAID 1 + until ([ "$LEVEL" -ne "1" ] && [ $SELECTED -eq $DEV_COUNT ]) || ([ "$LEVEL" -eq "1" ] && [ $SELECTED -gt 0 ] && [ $SELECTED -le $DEV_COUNT ]); do + db_subst mdcfg/raid${LEVEL}devs COUNT "$DEV_COUNT" + db_subst mdcfg/raid${LEVEL}devs PARTITIONS "$PARTITIONS" + db_input critical mdcfg/raid${LEVEL}devs db_go if [ $? -eq 30 ]; then return fi - db_get mdcfg/raid1devs + db_get mdcfg/raid${LEVEL}devs SELECTED=0 for i in $RET; do DEVICE=$(echo $i | sed -e "s/,//") @@ -266,19 +244,21 @@ done done - # Add "missing" for as many devices as weren't selected - MISSING_DEVICES="" - while [ $SELECTED -lt $DEV_COUNT ]; do - MISSING_DEVICES="$MISSING_DEVICES missing" - let SELECTED++ - done + if [ "$LEVEL" -eq "1" ]; then + # Add "missing" for as many devices as weren't selected + MISSING_DEVICES="" + while [ $SELECTED -lt $DEV_COUNT ]; do + MISSING_DEVICES="$MISSING_DEVICES missing" + let SELECTED++ + done + fi - # Remove partitions selected in raid1devs from the PARTITION list - db_get mdcfg/raid1devs + # Remove partitions selected in raid${LEVEL}devs from the PARTITION list + db_get mdcfg/raid${LEVEL}devs prune_partitions "$RET" - db_set mdcfg/raid1sparedevs "" + db_set mdcfg/raid${LEVEL}sparedevs "" SELECTED=0 if [ $SPARE_COUNT -gt 0 ]; then FIRST=1 @@ -286,15 +266,15 @@ # That means any number less than or equal to the spare count. while [ $SELECTED -gt $SPARE_COUNT ] || [ $FIRST -eq 1 ]; do FIRST=0 - db_subst mdcfg/raid1sparedevs COUNT "$SPARE_COUNT" - db_subst mdcfg/raid1sparedevs PARTITIONS "$PARTITIONS" - db_input critical mdcfg/raid1sparedevs + db_subst mdcfg/raid${LEVEL}sparedevs COUNT "$SPARE_COUNT" + db_subst mdcfg/raid${LEVEL}sparedevs PARTITIONS "$PARTITIONS" + db_input critical mdcfg/raid${LEVEL}sparedevs db_go if [ $? -eq 30 ]; then return fi - db_get mdcfg/raid1sparedevs + db_get mdcfg/raid${LEVEL}sparedevs SELECTED=0 for i in $RET; do DEVICE=$(echo $i | sed -e "s/,//") @@ -303,13 +283,29 @@ done fi + if [ "$LEVEL" -eq "10" ]; then + db_set mdcfg/raid10layout "n2" + db_input low mdcfg/raid10layout + db_go + if [ $? -eq 30 ]; then return; fi + db_get mdcfg/raid10layout + LAYOUT="--layout=$RET" + until echo $LAYOUT | grep -Eq "^--layout=[nfo][0-9]{1,2}$" && [ "$(echo $LAYOUT | sed s/--layout=.//)" -le "$DEV_COUNT" ]; do + db_input critical mdcfg/raid10layout + db_go + if [ $? -eq 30 ]; then return; fi + db_get mdcfg/raid10layout + LAYOUT="--layout=$RET" + done + fi + # The number of spares the user has selected NAMED_SPARES=$SELECTED - db_get mdcfg/raid1devs + db_get mdcfg/raid${LEVEL}devs RAID_DEVICES=$(echo $RET | sed -e "s/,//g") - db_get mdcfg/raid1sparedevs + db_get mdcfg/raid${LEVEL}sparedevs SPARE_DEVICES=$(echo $RET | sed -e "s/,//g") MISSING_SPARES="" @@ -333,151 +329,62 @@ logger -t mdcfg "Raid devices count: $DEV_COUNT" logger -t mdcfg "Spare devices count: $SPARE_COUNT" log-output -t mdcfg \ - mdadm --create /dev/md$MD_NUM --auto=yes --force -R -l raid1 \ - -n $DEV_COUNT -x $SPARE_COUNT $RAID_DEVICES $MISSING_DEVICES \ - $SPARE_DEVICES $MISSING_SPARES + mdadm --create /dev/md$MD_NUM --auto=yes --force -R -l raid${LEVEL} $LAYOUT \ + -n $DEV_COUNT -x $SPARE_COUNT $RAID_DEVICES \ + $MISSING_DEVICES $SPARE_DEVICES $MISSING_SPARES } -md_create_raid5() { - OK=0 +# This will set PARTITIONS and NUM_PART global variables +get_partitions() { + PARTITIONS="" - db_set mdcfg/raid5devcount "3" + # Get a list of RAID partitions. This only works if there is no + # filesystem on the partitions, which is fine by us. + RAW_PARTITIONS=$(/usr/lib/partconf/find-partitions --ignore-fstype 2>/dev/null | \ + grep "[[:space:]]RAID[[:space:]]" | cut -f1) - # Get the count of active devices - while [ $OK -eq 0 ]; do - db_input critical mdcfg/raid5devcount - db_go - if [ $? -eq 30 ]; then - return - fi + # Convert it into a proper list form for a select question + # (comma seperated) + NUM_PART=0 + for i in $RAW_PARTITIONS; do + DEV=$(echo $i | sed -e "s/\/dev\///") + REALDEV=$(mapdevfs "$i") + MAPPEDDEV=$(echo "$REALDEV" | sed -e "s/\/dev\///") - # Figure out, if the user entered a number - db_get mdcfg/raid5devcount - RET=$(echo $RET | sed -e "s/[[:space:]]//g") - if [ "$RET" ]; then - let "OK=${RET}>0 && ${RET}<99" + if grep -Eq "($DEV|$MAPPEDDEV)" /proc/mdstat; then + continue fi - done - db_set mdcfg/raid5sparecount "0" - OK=0 - - # Same procedure as above, but get the number of spare partitions - # this time. - # TODO: Make a general function for this kind of stuff - while [ $OK -eq 0 ]; do - db_input critical mdcfg/raid5sparecount - db_go - if [ $? -eq 30 ]; then - return - fi - db_get mdcfg/raid5sparecount - RET=$(echo $RET | sed -e "s/[[:space:]]//g") - if [ "$RET" ]; then - let "OK=${RET}>=0 && ${RET}<99" - fi + PARTITIONS="${PARTITIONS:+$PARTITIONS, }$REALDEV" + NUM_PART=$(($NUM_PART + 1)) done - db_get mdcfg/raid5devcount - DEV_COUNT="$RET" - if [ $DEV_COUNT -lt 3 ]; then - DEV_COUNT=3 # Minimum number for RAID5 + if [ -z "$PARTITIONS" ]; then + db_input critical mdcfg/noparts + db_go + return 1 fi - db_get mdcfg/raid5sparecount - SPARE_COUNT="$RET" - REQUIRED=$(($DEV_COUNT + $SPARE_COUNT)) - if [ $REQUIRED -gt $NUM_PART ]; then - db_subst mdcfg/notenoughparts NUM_PART "$NUM_PART" - db_subst mdcfg/notenoughparts REQUIRED "$REQUIRED" - db_input critical mdcfg/notenoughparts - db_go mdcfg/notenoughparts - return - fi + return 0 +} - db_set mdcfg/raid5devs "" - SELECTED=0 - - # Loop until the correct number of active devices has been selected - while [ $SELECTED -ne $DEV_COUNT ]; do - db_subst mdcfg/raid5devs COUNT "$DEV_COUNT" - db_subst mdcfg/raid5devs PARTITIONS "$PARTITIONS" - db_input critical mdcfg/raid5devs - db_go - if [ $? -eq 30 ]; then - return - fi - - db_get mdcfg/raid5devs - SELECTED=0 - for i in $RET; do - DEVICE=$(echo $i | sed -e "s/,//") - let SELECTED++ - done - done - - # Remove partitions selected in raid5devs from the PARTITION list - db_get mdcfg/raid5devs - - prune_partitions "$RET" - - db_set mdcfg/raid5sparedevs "" - SELECTED=0 - if [ $SPARE_COUNT -gt 0 ]; then - FIRST=1 - # Loop until the correct number of devices has been selected. - # That means any number less than or equal to the spare count. - while [ $SELECTED -gt $SPARE_COUNT ] || [ $FIRST -eq 1 ]; do - FIRST=0 - db_subst mdcfg/raid5sparedevs COUNT "$SPARE_COUNT" - db_subst mdcfg/raid5sparedevs PARTITIONS "$PARTITIONS" - db_input critical mdcfg/raid5sparedevs - db_go - if [ $? -eq 30 ]; then - return +prune_partitions() { + CHOSEN="$1" + OLDIFS="$IFS" + IFS=, + NEW_PARTITIONS="" + for i in $PARTITIONS; do + found=0 + for j in $CHOSEN; do + if [ "$i" = "$j" ]; then + found=1 fi - - db_get mdcfg/raid5sparedevs - SELECTED=0 - for i in $RET; do - DEVICE=$(echo $i | sed -e "s/,//") - let SELECTED++ - done done - fi - - # The number of spares the user has selected - NAMED_SPARES=$SELECTED - - db_get mdcfg/raid5devs - RAID_DEVICES=$(echo $RET | sed -e "s/,//g") - - db_get mdcfg/raid5sparedevs - SPARE_DEVICES=$(echo $RET | sed -e "s/,//g") - - MISSING_SPARES="" - - COUNT=$NAMED_SPARES - while [ $COUNT -lt $SPARE_COUNT ]; do - MISSING_SPARES="$MISSING_SPARES missing" - let COUNT++ + if [ $found -eq 0 ]; then + NEW_PARTITIONS="${NEW_PARTITIONS:+$NEW_PARTITIONS,}$i" + fi done - - # Find the next available md-number - MD_NUM=$(grep ^md /proc/mdstat | \ - sed -e 's/^md\(.*\) : active .*/\1/' | sort | tail -n1) - if [ -z "$MD_NUM" ]; then - MD_NUM=0 - else - let MD_NUM++ - fi - - logger -t mdcfg "Selected spare count: $NAMED_SPARES" - logger -t mdcfg "Raid devices count: $DEV_COUNT" - logger -t mdcfg "Spare devices count: $SPARE_COUNT" - log-output -t mdcfg \ - mdadm --create /dev/md$MD_NUM --auto=yes --force -R -l raid5 \ - -n $DEV_COUNT -x $SPARE_COUNT $RAID_DEVICES \ - $SPARE_DEVICES $MISSING_SPARES + IFS=$OLDIFS + PARTITIONS=$NEW_PARTITIONS } md_mainmenu() { @@ -503,11 +410,12 @@ ### Main of script ### # Try to load the necesarry modules. -# Supported schemes: RAID 0, RAID 1, RAID 5 +# Supported schemes: RAID 0, RAID 1, RAID 5, RAID 6, RAID 10 depmod -a >/dev/null 2>&1 modprobe md >/dev/null 2>&1 || modprobe md-mod >/dev/null 2>&1 modprobe raid0 >/dev/null 2>&1 modprobe raid1 >/dev/null 2>&1 +modprobe raid10 >/dev/null 2>&1 # kernels >=2.6.18 have raid456 modprobe raid456 >/dev/null 2>&1 || modprobe raid5 >/dev/null 2>&1 Index: partman/partman-auto-raid/auto-raidcfg =================================================================== --- partman/partman-auto-raid/auto-raidcfg (revision 54408) +++ partman/partman-auto-raid/auto-raidcfg (working copy) @@ -14,6 +14,12 @@ exit 9 fi + if [ "$DEV_COUNT" -lt 4 ] && ([ $RAID_TYPE = "10" ] || [ $RAID_TYPE = "6" ]); then + db_input critical partman-auto-raid/notenoughparts + db_go partman-auto-raid/notenoughparts + exit 9 + fi + SPARE_COUNT="$3" REQUIRED=$(($DEV_COUNT + $SPARE_COUNT)) @@ -82,13 +88,14 @@ } # Try to load the necessary modules. -# Supported schemes: RAID 0, RAID 1, RAID 5 +# Supported schemes: RAID 0, RAID 1, RAID 5, RAID 6, RAID 10 depmod -a 1>/dev/null 2>&1 modprobe md 1>/dev/null 2>&1 || modprobe md-mod 1>/dev/null 2>&1 modprobe raid0 >/dev/null 2>&1 modprobe raid1 1>/dev/null 2>&1 # kernels >=2.6.18 have raid456 modprobe raid456 >/dev/null 2>&1 || modprobe raid5 >/dev/null 2>&1 +modprobe raid10 >/dev/null 2>&1 mkdir -p /dev/md # Make sure that we have md-support Index: partman/partman-base/lib/base.sh =================================================================== --- partman/partman-base/lib/base.sh (revision 54408) +++ partman/partman-base/lib/base.sh (working copy) @@ -728,7 +728,7 @@ ;; /dev/md*|/dev/md/*) device=`echo "$1" | sed -e "s/.*md\/\?\(.*\)/\1/"` - type=`grep "^md${device}[ :]" /proc/mdstat | sed -e "s/^.* : active raid\([[:alnum:]]\).*/\1/"` + type=`grep "^md${device}[ :]" /proc/mdstat | sed -e "s/^.* : active raid\([[:alnum:]]\{,2\}\).*/\1/"` db_metaget partman/text/raid_device description printf "$RET" ${type} ${device} ;;
signature.asc
Description: Digital signature