here are the patches

-- 
_________________________
Ryan Niebur
[EMAIL PROTECTED]
From 02fdf30a500022136d089606a6cb0d18d885fbd9 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 |  240 +++++++++++++----------------------------------
 1 files changed, 64 insertions(+), 176 deletions(-)

diff --git a/packages/mdcfg/mdcfg.sh b/packages/mdcfg/mdcfg.sh
index 37a1f09..d329511 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,215 +199,94 @@ md_create_raid0() {
 		      -n $SELECTED $RAID_DEVICES
 }
 
-md_create_raid1() {
+md_create_array(){
 	OK=0
 
-	db_set mdcfg/raid1devcount 2
-
-	# 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
-}
+	case "$1" in
+	    RAID1)
+		MIN_SIZE=2 ;;
+	    RAID5)
+		MIN_SIZE=3 ;;
+	    *)
+		return ;;
+	esac
 
-md_create_raid5() {
-	OK=0
+	LEVEL=${1#RAID}
 
-	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/,//")
@@ -415,12 +294,21 @@ md_create_raid5() {
 		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"
+			let SELECTED++
+		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 027c047b466014ba46391906174dc9a22ebc850b 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     |   96 ++++++++++++++++++++++-
 packages/mdcfg/mdcfg.sh                         |   30 ++++++-
 packages/partman/partman-auto-raid/auto-raidcfg |    7 +-
 packages/partman/partman-base/lib/base.sh       |    2 +-
 5 files changed, 128 insertions(+), 8 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..b4ec893 100644
--- a/packages/mdcfg/debian/mdcfg-utils.templates
+++ b/packages/mdcfg/debian/mdcfg-utils.templates
@@ -47,7 +47,7 @@ Template: mdcfg/createmain
 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 @@ _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 d329511..8f0e5a6 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 ;;
@@ -207,6 +207,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 c8deae599c5a86831a8fdae49486c51752ac4401 Mon Sep 17 00:00:00 2001
From: Ryan Niebur <[EMAIL PROTECTED]>
Date: Sun, 20 Jul 2008 11:57:09 -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 b4ec893..3d24d09 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 8f0e5a6..505d94d 100755
--- a/packages/mdcfg/mdcfg.sh
+++ b/packages/mdcfg/mdcfg.sh
@@ -217,18 +217,23 @@ md_create_array(){
 
 	LEVEL=${1#RAID}
 
-	db_set mdcfg/raid${LEVEL}devcount "$MIN_SIZE"
+	for i in devcount devs sparecount sparedevs; do
+		db_subst mdcfg/raid$i LEVEL "$LEVEL"
+	done
+	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