On Sun, Feb 10, 2008 at 07:51:35PM +0100, Jérémy Bobbio wrote: > Attached is a patch against partman-auto-raid/5 (released with Etch) > that allows the preseeding of RAID + LVM setup. *ahem* Here it is. -- Jérémy Bobbio .''`. lunar@debian.org : :Ⓐ : # apt-get install anarchism `. `'` `-
Index: debian/changelog =================================================================== --- debian/changelog (revision 50831) +++ debian/changelog (working copy) @@ -1,3 +1,9 @@ +partman-auto-raid (5.0~0) UNRELEASED; urgency=low + + * Add the ability to preseed LVM over RAID. + + -- Jérémy Bobbio <lunar@debian.org> Mon, 21 Jan 2008 19:54:40 +0100 + partman-auto-raid (5) unstable; urgency=low [ Updated translations ] Index: auto.d/initial_auto_raid_fs =================================================================== --- auto.d/initial_auto_raid_fs (revision 50831) +++ auto.d/initial_auto_raid_fs (working copy) @@ -29,16 +29,22 @@ fi cd $id - if [ "$fstype" = swap ]; then + case "$fstype" in + swap) rm -f filesystem mountpoint use_filesystem options echo "swap" >method - else + ;; + lvm) + # Skip, handled separatly + ;; + *) echo "$fstype" >filesystem echo "$mountpoint" >mountpoint echo "format" >method touch use_filesystem mkdir options - fi + ;; + esac touch format touch formatable Index: auto.d/_numbers =================================================================== --- auto.d/_numbers (revision 50831) +++ auto.d/_numbers (working copy) @@ -1,2 +1,3 @@ 50 initial_auto_raid +54 initial_auto_raid_lvm 55 initial_auto_raid_fs Index: auto.d/initial_auto_raid_lvm =================================================================== --- auto.d/initial_auto_raid_lvm (revision 0) +++ auto.d/initial_auto_raid_lvm (revision 0) @@ -0,0 +1,64 @@ +#!/bin/sh + +# Apply LVM partitioning on top of a RAID preseed +# This needs to run before initial_auto_raid_fs as auto_lvm_perform will +# restart partman and otherwise forget about RAID partitions settings. + +. /lib/partman/definitions.sh +. /lib/partman/recipes.sh +. /lib/partman/auto-lvm_tools.sh + +# Check we have the stashed value of the first RAID dev we created +db_get partman-auto-raid/raidnum +if [ -z "$RET" ]; then + logger -t partman-auto-raid "Error: cannot determine device number for RAID device" + db_set partman-auto-raid/error false + db_input critical partman-auto-raid/error + db_go + exit 1 +fi +raidnum=$RET + +# We've already checked that there is a recipe +db_get partman-auto-raid/recipe +recipes=$RET + +pv_devices='' +# Try to act on each recipe we were given +while [ -n "$recipes" ]; do + tmp=$recipes + recipes=$(echo $tmp | sed -e 's/^[^.]*\.\(.*\)$/\1/'); + recipe=$(echo $tmp | sed -e 's/^\([^.]*\)\..*$/\1/'); + + if [ "$recipe" = "$recipes" ]; then + recipes='' + fi + + # Do the recipe! + echo $recipe >/tmp/partman-auto-raid-fs-recipe + read raidtype devcount sparecount fstype mountpoint devs \ + </tmp/partman-auto-raid-fs-recipe + if [ "$fstype" = lvm ]; then + pv_devices="${pv_devices:+$pv_devices }/dev/md$raidnum" + fi + + raidnum=$(($raidnum + 1)) +done + +db_get partman-auto/expert_recipe_file +recipe="$RET" + +decode_recipe $recipe lvm + +# Do nothing if there is no "lvmok" partitions. +if ! echo "$scheme" | grep -q "lvmok"; then + exit 0 +fi + +expand_scheme + +# Be sure the modules are loaded +modprobe dm-mod >/dev/null 2>&1 || true +modprobe lvm-mod >/dev/null 2>&1 || true + +auto_lvm_perform Property changes on: auto.d/initial_auto_raid_lvm ___________________________________________________________________ Name: svn:executable + * Index: README =================================================================== --- README (revision 50831) +++ README (working copy) @@ -23,3 +23,64 @@ -- Simon Huggins <huggie@earth.li> sponsored by Black Cat Networks http://www.blackcatnetworks.co.uk/ + +It is also possible to preseed LVM over RAID. The following example will +create a RAID 1 setup on two hard drives with: + + /dev/md0 as /boot (ext3) + /dev/md1 as a LVM physical volume + /dev/mapper/<hostname>-root as / (ext3) + /dev/mapper/<hostname>-swap_1 as swap + /dev/mapper/<hostname>-home as /home (ext3) + +--- 8< --- +d-i partman-auto/method string raid + +d-i partman-auto/disk string /dev/discs/disc0/disc /dev/discs/disc1/disc + +d-i partman-auto-raid/recipe string \ + 1 2 0 ext3 /boot \ + /dev/discs/disc0/part1#/dev/discs/disc1/part1 \ + . \ + 1 2 0 lvm - \ + /dev/discs/disc0/part5#/dev/discs/disc1/part5 \ + . + +# Please note that RAID partitions are tagged as "lvmignore" +# and LVM logical volumes as "defaultignore" and "lvmok". +d-i partman-auto/expert_recipe string \ + multiraid :: \ + 100 512 256 raid \ + $lvmignore{ } \ + $primary{ } \ + method{ raid } \ + . \ + 900 5000 4000 raid \ + $lvmignore{ } \ + method{ raid } \ + . \ + 700 5000 4000 ext3 \ + $defaultignore{ } \ + $lvmok{ } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ ext3 } \ + mountpoint{ / } \ + . \ + 64 512 300% linux-swap \ + $defaultignore{ } \ + $lvmok{ } \ + method{ swap } \ + format{ } \ + . \ + 100 1000 1000000000 ext3 \ + $defaultignore{ } \ + $lvmok{ } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ ext3 } \ + mountpoint{ /home } \ + . +--- >8 ---
Attachment:
signature.asc
Description: Digital signature