oops, I meant to send this to debian-boot.

On Thu, Jul 24, 2008 at 02:59:17PM -0700, Ryan Niebur wrote:
> On Thu, Jul 24, 2008 at 09:45:26PM +0200, Frans Pop wrote:
> > One more...
> > 
> > Patch 1:
> > +                     let SELECTED++
> > 
> > I don't think we use that syntax anywhere else in D-I, at least I cannot 
> > remember seeing it. Please use 'SELECTED=$(($SELECTED + 1))' instead.
> 
> The code that I took out was using 'let SELECTED++', and so is the rest of 
> mdcfg.sh, so that's what I used.
> But I changed it in my new patches.
> 
> On Thu, Jul 24, 2008 at 09:39:15PM +0200, Frans Pop wrote:
> > +   # Loop until at least one device has been selected for RAID 1
> > 
> > Comment is incorrect. We want only 1 device, not "at least". So it should 
> > be: "# For RAID 1 only one device can be selected"
> > 
> 
> The code tests to make sure that it's greater than 1 and less than or equal 
> to the number of devices you want.
> 
> The rest of the changes (and the debconf template error Christian pointed 
> out) are fixed in these new patches.
> 
> -- 
> _________________________
> Ryan Niebur
> [EMAIL PROTECTED]

-- 
_________________________
Ryan Niebur
[EMAIL PROTECTED]
From 5169863b855c702c05e7d4b01581fe4ccf11ecb4 Mon Sep 17 00:00:00 2001
From: Ryan Niebur <[EMAIL PROTECTED]>
Date: Sun, 20 Jul 2008 00:14:17 -0700
Subject: [PATCH] reuse code

---
 packages/mdcfg/mdcfg.sh |  242 +++++++++++++----------------------------------
 1 files changed, 65 insertions(+), 177 deletions(-)

diff --git a/packages/mdcfg/mdcfg.sh b/packages/mdcfg/mdcfg.sh
index 37a1f09..f0758b3 100755
--- a/packages/mdcfg/mdcfg.sh
+++ b/packages/mdcfg/mdcfg.sh
@@ -103,12 +103,12 @@ md_createmain() {
 		fi
 
 		case "$RAID_SEL" in
-		    RAID5)
-			md_create_raid5 ;;
-		    RAID1)
-			md_create_raid1 ;;
+		    RAID5|RAID1)
+			md_create_array "$RAID_SEL" ;;
 		    RAID0)
 			md_create_raid0 ;;
+		    *)
+			return 1 ;;
 		esac
 	fi
 }
@@ -199,228 +199,116 @@ md_create_raid0() {
 		      -n $SELECTED $RAID_DEVICES
 }
 
-md_create_raid1() {
+md_create_array(){
 	OK=0
 
-	db_set mdcfg/raid1devcount 2
+	LEVEL=${1#RAID}
 
-	# Get the count of active devices
-	while [ $OK -eq 0 ]; do
-		db_input critical mdcfg/raid1devcount
-		db_go
-		if [ $? -eq 30 ]; then
-			return
-		fi
-
-		# Figure out, if the user entered a number
-		db_get mdcfg/raid1devcount
-		RET=$(echo $RET | sed -e "s/[[:space:]]//g")
-		if [ "$RET" ]; then
-			let "OK=${RET}>0 && ${RET}<99"
-		fi
-	done
-
-	db_set mdcfg/raid1sparecount "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_go
-		if [ $? -eq 30 ]; then
-			return
-		fi
-		db_get mdcfg/raid1sparecount
-		RET=$(echo $RET | sed -e "s/[[:space:]]//g")
-		if [ "$RET" ]; then
-			let "OK=${RET}>=0 && ${RET}<99"
-		fi
-	done
-
-	db_get mdcfg/raid1devcount
-	DEV_COUNT="$RET"
-	db_get mdcfg/raid1sparecount
-	SPARE_COUNT="$RET"
-	REQUIRED=$(($DEV_COUNT + $SPARE_COUNT))
-
-	db_set mdcfg/raid1devs ""
-	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
-		db_go
-		if [ $? -eq 30 ]; then
-			return
-		fi
-
-		db_get mdcfg/raid1devs
-		SELECTED=0
-		for i in $RET; do
-			DEVICE=$(echo $i | sed -e "s/,//")
-			let SELECTED++
-		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
-
-	# Remove partitions selected in raid1devs from the PARTITION list
-	db_get mdcfg/raid1devs
-
-	prune_partitions "$RET"
-
-	db_set mdcfg/raid1sparedevs ""
-	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/raid1sparedevs COUNT "$SPARE_COUNT"
-			db_subst mdcfg/raid1sparedevs PARTITIONS "$PARTITIONS"
-			db_input critical mdcfg/raid1sparedevs
-			db_go
-			if [ $? -eq 30 ]; then
-				return
-			fi
-
-			db_get mdcfg/raid1sparedevs
-			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/raid1devs
-	RAID_DEVICES=$(echo $RET | sed -e "s/,//g")
-
-	db_get mdcfg/raid1sparedevs
-	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++
-	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 raid1 \
-		      -n $DEV_COUNT -x $SPARE_COUNT $RAID_DEVICES $MISSING_DEVICES \
-		      $SPARE_DEVICES $MISSING_SPARES
-}
-
-md_create_raid5() {
-	OK=0
+	case "$1" in
+	    RAID1)
+		MIN_SIZE=2 ;;
+	    RAID5)
+		MIN_SIZE=3 ;;
+	    *)
+		return ;;
+	esac
 
-	db_set mdcfg/raid5devcount "3"
+	db_set mdcfg/raid${LEVEL}devcount "$MIN_SIZE"
 
 	# Get the count of active devices
 	while [ $OK -eq 0 ]; do
-		db_input critical mdcfg/raid5devcount
+		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/raid5devcount
+		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/raid5sparecount "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/raid5sparecount
+		db_input critical mdcfg/raid${LEVEL}sparecount
 		db_go
 		if [ $? -eq 30 ]; then
 			return
 		fi
-		db_get mdcfg/raid5sparecount
+		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/raid5devcount
+	db_get mdcfg/raid${LEVEL}devcount
 	DEV_COUNT="$RET"
-	if [ $DEV_COUNT -lt 3 ]; then
-		DEV_COUNT=3 # Minimum number for RAID5
+	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/raid5sparecount
+	db_get mdcfg/raid${LEVEL}sparecount
 	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
+	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/raid5devs ""
+	db_set mdcfg/raid${LEVEL}devs ""
 	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
+	# Loop until the correct number of active devices has been selected for RAID 5
+	# 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/raid5devs
+		db_get mdcfg/raid${LEVEL}devs
 		SELECTED=0
 		for i in $RET; do
 			DEVICE=$(echo $i | sed -e "s/,//")
-			let SELECTED++
+			SELECTED=$(($SELECTED + 1))
 		done
 	done
 
-	# Remove partitions selected in raid5devs from the PARTITION list
-	db_get mdcfg/raid5devs
+	MISSING_DEVICES=""
+	if [ $LEVEL -eq 1 ]; then
+		# Add "missing" for as many devices as weren't selected
+		while [ $SELECTED -lt $DEV_COUNT ]; do
+			MISSING_DEVICES="$MISSING_DEVICES missing"
+			SELECTED=$(($SELECTED + 1))
+		done
+	fi
+
+	# Remove partitions selected in raid${LEVEL}devs from the PARTITION list
+	db_get mdcfg/raid${LEVEL}devs
 
 	prune_partitions "$RET"
 
-	db_set mdcfg/raid5sparedevs ""
+	db_set mdcfg/raid${LEVEL}sparedevs ""
 	SELECTED=0
 	if [ $SPARE_COUNT -gt 0 ]; then
 		FIRST=1
@@ -428,15 +316,15 @@ md_create_raid5() {
 		# 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_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/raid5sparedevs
+			db_get mdcfg/raid${LEVEL}sparedevs
 			SELECTED=0
 			for i in $RET; do
 				DEVICE=$(echo $i | sed -e "s/,//")
@@ -448,10 +336,10 @@ md_create_raid5() {
 	# The number of spares the user has selected
 	NAMED_SPARES=$SELECTED
 
-	db_get mdcfg/raid5devs
+	db_get mdcfg/raid${LEVEL}devs
 	RAID_DEVICES=$(echo $RET | sed -e "s/,//g")
 
-	db_get mdcfg/raid5sparedevs
+	db_get mdcfg/raid${LEVEL}sparedevs
 	SPARE_DEVICES=$(echo $RET | sed -e "s/,//g")
 
 	MISSING_SPARES=""
@@ -475,9 +363,9 @@ md_create_raid5() {
 	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 \
+		mdadm --create /dev/md$MD_NUM --auto=yes --force -R -l raid${LEVEL} \
 		      -n $DEV_COUNT -x $SPARE_COUNT $RAID_DEVICES \
-		      $SPARE_DEVICES $MISSING_SPARES
+		      $MISSING_DEVICES $SPARE_DEVICES $MISSING_SPARES
 }
 
 md_mainmenu() {
-- 
1.5.6.2

From fdfb45504b2a4afa170cc587021060dc485412bf Mon Sep 17 00:00:00 2001
From: Ryan Niebur <[EMAIL PROTECTED]>
Date: Fri, 18 Jul 2008 13:29:32 -0700
Subject: [PATCH] raid 10 and raid 6

---
 packages/kernel/kernel-wedge/modules/md-modules |    1 +
 packages/mdcfg/debian/mdcfg-utils.templates     |   98 ++++++++++++++++++++++-
 packages/mdcfg/mdcfg.sh                         |   30 ++++++-
 packages/partman/partman-auto-raid/auto-raidcfg |    7 +-
 packages/partman/partman-base/lib/base.sh       |    2 +-
 5 files changed, 129 insertions(+), 9 deletions(-)

diff --git a/packages/kernel/kernel-wedge/modules/md-modules b/packages/kernel/kernel-wedge/modules/md-modules
index cf8921c..f1c165a 100644
--- a/packages/kernel/kernel-wedge/modules/md-modules
+++ b/packages/kernel/kernel-wedge/modules/md-modules
@@ -8,6 +8,7 @@ raid0
 raid1
 raid5 ?
 raid456 ?
+raid10
 xor
 dm-mirror ?
 dm-snapshot ?
diff --git a/packages/mdcfg/debian/mdcfg-utils.templates b/packages/mdcfg/debian/mdcfg-utils.templates
index ddd9e65..7eb3dd1 100644
--- a/packages/mdcfg/debian/mdcfg-utils.templates
+++ b/packages/mdcfg/debian/mdcfg-utils.templates
@@ -46,8 +46,8 @@ _Description: Not enough RAID partitions available
 Template: mdcfg/createmain
 Type: select
 # :sl3:
-# flag:translate:4
-__Choices: RAID0, RAID1, RAID5, Cancel
+#flag:translate:6
+__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 @@ _Description: Spare devices for the RAID5 multidisk device:
  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 four 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 (arrangement of the copies) followed
+ by a number (number of copies of each chunk). The number must be
+ smaller or equal to 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
+ .
+ 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 two 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 @@ _Description: Active devices for the RAID5 multidisk device:
  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:
diff --git a/packages/mdcfg/mdcfg.sh b/packages/mdcfg/mdcfg.sh
index f0758b3..a2c9967 100755
--- a/packages/mdcfg/mdcfg.sh
+++ b/packages/mdcfg/mdcfg.sh
@@ -103,7 +103,7 @@ md_createmain() {
 		fi
 
 		case "$RAID_SEL" in
-		    RAID5|RAID1)
+		    RAID10|RAID6|RAID5|RAID1)
 			md_create_array "$RAID_SEL" ;;
 		    RAID0)
 			md_create_raid0 ;;
@@ -209,6 +209,10 @@ md_create_array(){
 		MIN_SIZE=2 ;;
 	    RAID5)
 		MIN_SIZE=3 ;;
+	    RAID6)
+		MIN_SIZE=4 ;;
+	    RAID10)
+		MIN_SIZE=2 ;;
 	    *)
 		return ;;
 	esac
@@ -274,7 +278,7 @@ md_create_array(){
 	db_set mdcfg/raid${LEVEL}devs ""
 	SELECTED=0
 
-	# Loop until the correct number of active devices has been selected for RAID 5
+	# Loop until the correct number of active devices has been selected for RAID 5, 6, 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
@@ -333,6 +337,23 @@ md_create_array(){
 		done
 	fi
 
+	LAYOUT=""
+	if [ $LEVEL -eq 10 ]; then
+		OK=0
+		db_set mdcfg/raid10layout "n2"
+		while [ $OK -eq 0 ]; do
+			db_input low mdcfg/raid10layout
+			db_go
+			if [ $? -eq 30 ]; then return; fi
+			db_get mdcfg/raid10layout
+			if echo $RET | grep -Eq "^[nfo][0-9]{1,2}$" && \
+			    [ $(echo $RET | sed 's/.//') -le $DEV_COUNT ]; then
+				OK=1
+			fi
+		done
+		LAYOUT="--layout=$RET"
+	fi
+
 	# The number of spares the user has selected
 	NAMED_SPARES=$SELECTED
 
@@ -363,7 +384,7 @@ md_create_array(){
 	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 raid${LEVEL} \
+		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
 }
@@ -391,11 +412,12 @@ md_mainmenu() {
 ### 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
 
diff --git a/packages/partman/partman-auto-raid/auto-raidcfg b/packages/partman/partman-auto-raid/auto-raidcfg
index e91e182..fe77023 100755
--- a/packages/partman/partman-auto-raid/auto-raidcfg
+++ b/packages/partman/partman-auto-raid/auto-raidcfg
@@ -8,7 +8,9 @@ create_raid() {
 	RAID_TYPE="$1"
 	DEV_COUNT="$2"
 
-	if [ "$DEV_COUNT" -lt 3 ] && [ $RAID_TYPE = "5" ] ; then
+	if ([ "$DEV_COUNT" -lt 3 ] && [ $RAID_TYPE = "5" ]) ||
+	   ([ "$DEV_COUNT" -lt 4 ] && [ $RAID_TYPE = "6" ]) ||
+	   ([ "$DEV_COUNT" -lt 2 ] && [ $RAID_TYPE = "10" ]); then
 		db_input critical partman-auto-raid/notenoughparts
 		db_go partman-auto-raid/notenoughparts
 		exit 9
@@ -82,11 +84,12 @@ create_raid() {
 }
 
 # 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
+modprobe raid10 1>/dev/null 2>&1
 # kernels >=2.6.18 have raid456
 modprobe raid456 >/dev/null 2>&1 || modprobe raid5 >/dev/null 2>&1
 mkdir -p /dev/md
diff --git a/packages/partman/partman-base/lib/base.sh b/packages/partman/partman-base/lib/base.sh
index 91540f4..f10a62f 100644
--- a/packages/partman/partman-base/lib/base.sh
+++ b/packages/partman/partman-base/lib/base.sh
@@ -728,7 +728,7 @@ humandev () {
 	    ;;
 	/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}
 	    ;;
-- 
1.5.6.2

From 27baf4aac96ea68e67524ba586fa37c60b1ff3b6 Mon Sep 17 00:00:00 2001
From: Ryan Niebur <[EMAIL PROTECTED]>
Date: Thu, 24 Jul 2008 14:33:39 -0700
Subject: [PATCH] use generic templates

---
 packages/mdcfg/debian/mdcfg-utils.templates |  149 +++-----------------------
 packages/mdcfg/mdcfg.sh                     |   49 +++++----
 2 files changed, 45 insertions(+), 153 deletions(-)

diff --git a/packages/mdcfg/debian/mdcfg-utils.templates b/packages/mdcfg/debian/mdcfg-utils.templates
index 7eb3dd1..f05783d 100644
--- a/packages/mdcfg/debian/mdcfg-utils.templates
+++ b/packages/mdcfg/debian/mdcfg-utils.templates
@@ -52,83 +52,46 @@ __Choices: RAID0, RAID1, RAID5, RAID6, RAID10, Cancel
 _Description: Multidisk device type:
  Please choose the type of the multidisk device to be created.
 
-Template: mdcfg/raid1devcount
-Type: string
-# :sl3:
-_Description: Number of active devices for the RAID1 array:
- The RAID1 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.
- .
- NOTE: this setting cannot be changed later.
-
-Template: mdcfg/raid1sparecount
-Type: string
-# :sl3:
-_Description: Number of spare devices for the RAID1 array:
-
-Template: mdcfg/raid1sparedevs
+Template: mdcfg/raid0devs
 Type: multiselect
 Choices: ${PARTITIONS}
 # :sl3:
-_Description: Spare devices for the RAID1 multidisk device:
- You have chosen to create an RAID1 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.
+_Description: Active devices for the RAID0 multidisk device:
+ You have chosen to create a RAID0 array. Please choose the active devices
+ in this array.
 
-Template: mdcfg/raid5devcount
+Template: mdcfg/raiddevcount
 Type: string
 # :sl3:
-_Description: Number of active devices for the RAID5 array:
- The RAID5 array will consist of both active and spare partitions. The active
+_Description: Number of active devices for the RAID${LEVEL} array:
+ The RAID${LEVEL} 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
+ more of the active devices fail. A minimum of ${MINIMUM} active devices is
  required.
  .
  NOTE: this setting cannot be changed later.
 
-Template: mdcfg/raid5sparecount
-Type: string
-# :sl3:
-_Description: Number of spare devices for the RAID5 array:
-
-Template: mdcfg/raid5sparedevs
+Template: mdcfg/raiddevs
 Type: multiselect
 Choices: ${PARTITIONS}
 # :sl3:
-_Description: Spare devices for the RAID5 multidisk device:
- You have chosen to create an RAID5 array with ${COUNT} spare devices.
+_Description: Active devices for the RAID${LEVEL} multidisk device:
+ You have chosen to create a RAID${LEVEL} array with ${COUNT} active 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/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 four active devices is
- required.
- .
- NOTE: this setting cannot be changed later.
+ Please choose which partitions are active devices.
+ You must select exactly ${COUNT} partitions.
 
-Template: mdcfg/raid6sparecount
+Template: mdcfg/raidsparecount
 Type: string
 # :sl3:
-_Description: Number of spare devices for the RAID6 array:
+_Description: Number of spare devices for the RAID${LEVEL} array:
 
-Template: mdcfg/raid6sparedevs
+Template: mdcfg/raidsparedevs
 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.
+_Description: Spare devices for the RAID${LEVEL} multidisk device:
+ You have chosen to create a RAID${LEVEL} 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}
@@ -153,82 +116,6 @@ _Description: Layout of the RAID10 multidisk device:
  .
  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 two 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}
-# :sl3:
-_Description: Active devices for the RAID0 multidisk device:
- You have chosen to create a RAID0 array. Please choose the active devices
- in this array.
-
-Template: mdcfg/raid1devs
-Type: multiselect
-Choices: ${PARTITIONS}
-# :sl3:
-_Description: Active devices for the RAID1 multidisk device:
- You have chosen to create an RAID1 array with ${COUNT} active devices.
- .
- Please choose which partitions are active devices.
- You must select exactly ${COUNT} partitions.
-
-Template: mdcfg/raid5devs
-Type: multiselect
-Choices: ${PARTITIONS}
-# :sl3:
-_Description: Active devices for the RAID5 multidisk device:
- You have chosen to create an RAID5 array with ${COUNT} active devices.
- .
- 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:
diff --git a/packages/mdcfg/mdcfg.sh b/packages/mdcfg/mdcfg.sh
index a2c9967..f72b493 100755
--- a/packages/mdcfg/mdcfg.sh
+++ b/packages/mdcfg/mdcfg.sh
@@ -204,6 +204,10 @@ md_create_array(){
 
 	LEVEL=${1#RAID}
 
+	for i in devcount devs sparecount sparedevs; do
+		db_subst mdcfg/raid$i LEVEL "$LEVEL"
+	done
+
 	case "$1" in
 	    RAID1)
 		MIN_SIZE=2 ;;
@@ -217,18 +221,19 @@ md_create_array(){
 		return ;;
 	esac
 
-	db_set mdcfg/raid${LEVEL}devcount "$MIN_SIZE"
+	db_subst mdcfg/raiddevcount MINIMUM "$MIN_SIZE"
+	db_set mdcfg/raiddevcount "$MIN_SIZE"
 
 	# Get the count of active devices
 	while [ $OK -eq 0 ]; do
-		db_input critical mdcfg/raid${LEVEL}devcount
+		db_input critical mdcfg/raiddevcount
 		db_go
 		if [ $? -eq 30 ]; then
 			return
 		fi
 
 		# Figure out, if the user entered a number
-		db_get mdcfg/raid${LEVEL}devcount
+		db_get mdcfg/raiddevcount
 		RET=$(echo $RET | sed -e "s/[[:space:]]//g")
 		if [ "$RET" ]; then
 			let "OK=${RET}>0 && ${RET}<99"
@@ -236,33 +241,33 @@ md_create_array(){
 	done
 
 
-	db_set mdcfg/raid${LEVEL}sparecount "0"
+	db_set mdcfg/raidsparecount "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/raid${LEVEL}sparecount
+		db_input critical mdcfg/raidsparecount
 		db_go
 		if [ $? -eq 30 ]; then
 			return
 		fi
-		db_get mdcfg/raid${LEVEL}sparecount
+		db_get mdcfg/raidsparecount
 		RET=$(echo $RET | sed -e "s/[[:space:]]//g")
 		if [ "$RET" ]; then
 			let "OK=${RET}>=0 && ${RET}<99"
 		fi
 	done
 
-	db_get mdcfg/raid${LEVEL}devcount
+	db_get mdcfg/raiddevcount
 	DEV_COUNT="$RET"
 	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
+	db_get mdcfg/raidsparecount
 	SPARE_COUNT="$RET"
 	REQUIRED=$(($DEV_COUNT + $SPARE_COUNT))
 	if [ $LEVEL -ne 1 ]; then
@@ -275,22 +280,22 @@ md_create_array(){
 		fi
 	fi
 
-	db_set mdcfg/raid${LEVEL}devs ""
+	db_set mdcfg/raiddevs ""
 	SELECTED=0
 
 	# Loop until the correct number of active devices has been selected for RAID 5, 6, 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_subst mdcfg/raiddevs COUNT "$DEV_COUNT"
+		db_subst mdcfg/raiddevs PARTITIONS "$PARTITIONS"
+		db_input critical mdcfg/raiddevs
 		db_go
 		if [ $? -eq 30 ]; then
 			return
 		fi
 
-		db_get mdcfg/raid${LEVEL}devs
+		db_get mdcfg/raiddevs
 		SELECTED=0
 		for i in $RET; do
 			DEVICE=$(echo $i | sed -e "s/,//")
@@ -307,12 +312,12 @@ md_create_array(){
 		done
 	fi
 
-	# Remove partitions selected in raid${LEVEL}devs from the PARTITION list
-	db_get mdcfg/raid${LEVEL}devs
+	# Remove partitions selected in raiddevs from the PARTITION list
+	db_get mdcfg/raiddevs
 
 	prune_partitions "$RET"
 
-	db_set mdcfg/raid${LEVEL}sparedevs ""
+	db_set mdcfg/raidsparedevs ""
 	SELECTED=0
 	if [ $SPARE_COUNT -gt 0 ]; then
 		FIRST=1
@@ -320,15 +325,15 @@ md_create_array(){
 		# 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/raid${LEVEL}sparedevs COUNT "$SPARE_COUNT"
-			db_subst mdcfg/raid${LEVEL}sparedevs PARTITIONS "$PARTITIONS"
-			db_input critical mdcfg/raid${LEVEL}sparedevs
+			db_subst mdcfg/raidsparedevs COUNT "$SPARE_COUNT"
+			db_subst mdcfg/raidsparedevs PARTITIONS "$PARTITIONS"
+			db_input critical mdcfg/raidsparedevs
 			db_go
 			if [ $? -eq 30 ]; then
 				return
 			fi
 
-			db_get mdcfg/raid${LEVEL}sparedevs
+			db_get mdcfg/raidsparedevs
 			SELECTED=0
 			for i in $RET; do
 				DEVICE=$(echo $i | sed -e "s/,//")
@@ -357,10 +362,10 @@ md_create_array(){
 	# The number of spares the user has selected
 	NAMED_SPARES=$SELECTED
 
-	db_get mdcfg/raid${LEVEL}devs
+	db_get mdcfg/raiddevs
 	RAID_DEVICES=$(echo $RET | sed -e "s/,//g")
 
-	db_get mdcfg/raid${LEVEL}sparedevs
+	db_get mdcfg/raidsparedevs
 	SPARE_DEVICES=$(echo $RET | sed -e "s/,//g")
 
 	MISSING_SPARES=""
-- 
1.5.6.2

Attachment: signature.asc
Description: Digital signature

Reply via email to