Bug#543786: partman-auto-raid: having to name devices explicitly is clumsy
On Fri, Aug 28, 2009 at 02:53:56PM +0200, Max Vozeler wrote:
> On Wed, Aug 26, 2009 at 11:09:47PM +0100, Colin Watson wrote:
> > Attached is a patch which introduces new syntax, looking like this:
>
> > Any comments? I think this is a noticeable improvement, so I'll commit
> > it next week or so if there are no objections.
>
> ENOPATCH. :-)
Gah. One of these days I'll make my mailer automatically whine at me if
I do that.
Really attached now.
--
Colin Watson [cjwatson@debian.org]
Index: debian/changelog
===================================================================
--- debian/changelog (revision 60467)
+++ debian/changelog (working copy)
@@ -2,6 +2,9 @@
* Stop documenting devfs syntax in README.
* Upgrade to debhelper v7.
+ * Add raidid= syntax to partman-auto-raid/recipe to make it possible to
+ preseed RAID creation without having to guess partition device names in
+ advance.
-- Colin Watson <cjwatson@debian.org> Wed, 26 Aug 2009 17:56:38 +0100
Index: auto-raidcfg
===================================================================
--- auto-raidcfg (revision 60467)
+++ auto-raidcfg (working copy)
@@ -4,6 +4,20 @@
# Mostly based on mdcfg
+expand_raidid() {
+ new_raid_devices=
+ for raid_device; do
+ if [ "${raid_device#raidid=}" != "$raid_device" ]; then
+ for match in $(cat "/var/lib/partman/raidids/${raid_device#raidid=}"); do
+ new_raid_devices="${new_raid_devices:+$new_raid_devices }$match"
+ done
+ else
+ new_raid_devices="${new_raid_devices:+$new_raid_devices }$raid_device"
+ fi
+ done
+ echo "$new_raid_devices"
+}
+
create_raid() {
RAID_TYPE="$1"
DEV_COUNT="$2"
@@ -21,12 +35,14 @@
FS_TYPE="$4"
MOUNTPOINT="$5"
- DEVICES="$6"
+ RAID_DEVICES="$6"
SPARE_DEVICES="$7"
- RAID_DEVICES=$(echo $DEVICES | sed -e "s/#/ /g")
+ RAID_DEVICES=$(echo $RAID_DEVICES | sed -e "s/#/ /g")
+ RAID_DEVICES="$(expand_raidid $RAID_DEVICES)"
SPARE_DEVICES=$(echo $SPARE_DEVICES | sed -e "s/#/ /g")
+ SPARE_DEVICES="$(expand_raidid $SPARE_DEVICES)"
NAMED_SPARES=$(echo $SPARE_DEVICES | wc -w)
Index: display.d/initial_auto_raid
===================================================================
--- display.d/initial_auto_raid (revision 60467)
+++ display.d/initial_auto_raid (working copy)
@@ -16,6 +16,22 @@
mkdir -p /var/lib/partman
touch /var/lib/partman/initial_auto_raid
+# Look around for raidids before stopping parted_server
+rm -rf /var/lib/partman/raidids
+mkdir -p /var/lib/partman/raidids
+for dev in $DEVICES/*; do
+ [ -d "$dev" ] || continue
+ cd "$dev"
+ open_dialog PARTITIONS
+ while { read_line num id size type fs path name; [ "$id" ]; }; do
+ [ -f "$id/raidid" ] || continue
+ raidid="$(cat "$id/raidid")"
+ echo "$path" >>"/var/lib/partman/raidids/$raidid"
+ done
+ close_dialog
+done
+cd /
+
confirm_changes partman-md || exit 1
commit_changes partman/text/commit_failed || exit $?
Index: README
===================================================================
--- README (revision 60467)
+++ README (working copy)
@@ -38,13 +38,12 @@
d-i partman-auto/disk string /dev/sda /dev/sdb
+# raidid can be anything, as long as it doesn't contain spaces or slashes
+# and matches something in raidid{ } in partman-auto/expert_recipe. You can
+# use hash separated lists of ordinary device names instead if you prefer.
d-i partman-auto-raid/recipe string \
- 1 2 0 ext3 /boot \
- /dev/sda1#/dev/sdb1 \
- . \
- 1 2 0 lvm - \
- /dev/sda5#/dev/sdb5 \
- .
+ 1 2 0 ext3 /boot raidid=1 . \
+ 1 2 0 lvm - raidid=2 .
# Please note that RAID partitions are tagged as "lvmignore"
# and LVM logical volumes as "defaultignore" and "lvmok".
@@ -54,10 +53,12 @@
$lvmignore{ } \
$primary{ } \
method{ raid } \
+ raidid{ 1 } \
. \
900 5000 4000 raid \
$lvmignore{ } \
method{ raid } \
+ raidid{ 2 } \
. \
700 5000 4000 ext3 \
$defaultignore{ } \
Reply to: