[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#484421: Should support preseeding of LVM-over-RAID setups



Hi,

I've made some tests based on the patch proposed by Lunar. To fully
automate LVM over RAID setups, I've changed some parts of the
scripts :

1) Parted try to read a partition table on the RAID volume. I added a
commit.d script before parted to avoid that.

2) In the initial_auto_raid_lvm script, before starting
auto_lvm_perform, the vg map must be created with
auto_lvm_create_vg_map.

Here is a new patch proposal.

Cheers,

Philippe Le Brouster
diff -aburN -x .svn /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/commit.d/auto_raid_parted_hack ./commit.d/auto_raid_parted_hack
--- /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/commit.d/auto_raid_parted_hack	1970-01-01 01:00:00.000000000 +0100
+++ ./commit.d/auto_raid_parted_hack	2009-03-04 15:34:25.000000000 +0100
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+. /lib/partman/lib/base.sh
+. /lib/partman/lib/commit.sh
+
+for dev in $DEVICES/\=dev\=md*; do
+    [ -d "$dev" ] || continue
+    cd $dev
+    
+    id=$(ls -d 0-*)
+    fstype=""
+
+    [ -f "$id/filesystem" ] && fstype=$(cat $id/filesystem)
+
+    [ -z $fstype ] && continue    
+    case "$fstype" in
+        swap)
+            ;;
+        lvm)
+            ;;
+        *)
+            open_dialog DISK_UNCHANGED
+            close_dialog
+            ;;
+
+    esac
+done
+
diff -aburN -x .svn /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/commit.d/_numbers ./commit.d/_numbers
--- /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/commit.d/_numbers	1970-01-01 01:00:00.000000000 +0100
+++ ./commit.d/_numbers	2009-03-03 14:09:05.000000000 +0100
@@ -0,0 +1,2 @@
+29 auto_raid_parted_hack
+
diff -aburN -x .svn /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/debian/changelog ./debian/changelog
--- /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/debian/changelog	2008-09-22 02:04:43.000000000 +0200
+++ ./debian/changelog	2009-03-10 14:08:14.000000000 +0100
@@ -1,3 +1,10 @@
+partman-auto-raid (14+slis4.1.3~2) UNRELEASED; urgency=low
+
+  * Add the ability to preseed LVM over RAID based on the patch in #484421.
+
+
+ -- Philippe Le Brouster <plb@ac-grenoble.fr>  Mon, 09 Mar 2009 12:02:44 +0100
+
 partman-auto-raid (14) unstable; urgency=low
 
   [ Updated translations ]
diff -aburN -x .svn /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/debian/control ./debian/control
--- /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/debian/control	2008-08-09 21:26:06.000000000 +0200
+++ ./debian/control	2009-02-23 17:03:09.000000000 +0100
@@ -9,5 +9,5 @@
 Package: partman-auto-raid
 XC-Package-Type: udeb
 Architecture: all
-Depends: ${misc:Depends}, partman-base (>= 114), partman-basicfilesystems, partman-ext3, partman-auto (>= 58), partman-md
+Depends: ${misc:Depends}, partman-base (>= 114), partman-basicfilesystems, partman-ext3, partman-auto (>= 79), partman-md
 Description: Allow preseeded RAID installs
diff -aburN -x .svn /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/debian/rules ./debian/rules
--- /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/debian/rules	2008-08-09 21:26:06.000000000 +0200
+++ ./debian/rules	2009-03-03 13:36:47.000000000 +0100
@@ -17,6 +17,7 @@
 	dh_clean -k
 	dh_install auto-raidcfg bin
 	debian/install-rc display.d
+	debian/install-rc commit.d
 
 binary-arch: build install
 	dh_testdir
diff -aburN -x .svn /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/display.d/initial_auto_raid_fs ./display.d/initial_auto_raid_fs
--- /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/display.d/initial_auto_raid_fs	2008-08-09 21:26:07.000000000 +0200
+++ ./display.d/initial_auto_raid_fs	2009-03-04 17:19:16.000000000 +0100
@@ -29,16 +29,24 @@
 	fi
 	cd $id
 
-	if [ "$fstype" = swap ]; then
+	case "$fstype" in
+	    swap)
 		rm -f filesystem mountpoint use_filesystem options
 		echo swap >method
-	else
+		;;
+	    lvm)
+		# Register this RAID as a PV for initial_auto_raid_lvm
+		echo lvm >method
+		echo "/dev/md$raidnum" >>/var/lib/partman/initial_auto_raid_pvs
+		;;
+	    *)
 		echo "$fstype" >filesystem
 		echo "$mountpoint" >mountpoint
 		echo format >method
 		touch use_filesystem
 		mkdir options
-	fi
+		;;
+	esac
 	touch format
 	touch formatable
 
@@ -50,6 +58,7 @@
 	exit 0
 fi
 rm /var/lib/partman/do_initial_auto_raid_fs
+rm -f /var/lib/partman/initial_auto_raid_pvs
 
 # Check we have the stashed value of the first RAID dev we created
 db_get partman-auto-raid/raidnum
diff -aburN -x .svn /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/display.d/initial_auto_raid_lvm ./display.d/initial_auto_raid_lvm
--- /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/display.d/initial_auto_raid_lvm	1970-01-01 01:00:00.000000000 +0100
+++ ./display.d/initial_auto_raid_lvm	2009-03-04 16:55:54.000000000 +0100
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+#set -x
+
+# Apply LVM partitioning on top of a RAID preseed
+
+if ! [ -f /var/lib/partman/initial_auto_raid_pvs ] ||
+   ! [ -e /lib/partman/lib/auto-lvm.sh ]; then
+	exit 0
+fi
+
+. /lib/partman/lib/auto-lvm.sh
+
+# pv_devices is used by auto_lvm_perform()
+pv_devices="$(cat /var/lib/partman/initial_auto_raid_pvs)"
+rm -f /var/lib/partman/initial_auto_raid_pvs
+
+db_get partman-auto/expert_recipe_file
+recipe="$RET"
+
+nr_devices=0
+size=0
+for pv_device in $pv_devices; do
+	dev="$(dev_to_partman $pv_device)"
+	[ -f $dev/size ] || exit 1
+	size=$(($size + $(cat $dev/size)))
+	nr_devices=$(($nr_devices + 1))
+done
+
+if [ $nr_devices -eq 1 ]; then
+	dev="$(dev_to_partman $pv_devices)"
+	target="$(humandev $(cat $dev/device)) - $(cat $dev/model)"
+else
+	for pv_device in $pv_devices; do
+		dev="$(dev_to_partman $pv_device)"
+		target="${target:+$target }$(cat $dev/device)"
+	done
+	target="Multiple disks ($target)"
+fi
+target="$target: $(longint2human $size)"
+free_size=$(expr 0000000"$size" : '0*\(..*\)......$') # convert to megabytes
+
+choose_recipe lvm "$target" "$free_size" || return $?
+
+# 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_create_vg_map
+auto_lvm_perform
+
diff -aburN -x .svn /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/display.d/_numbers ./display.d/_numbers
--- /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/display.d/_numbers	2008-08-09 21:26:07.000000000 +0200
+++ ./display.d/_numbers	2009-02-23 17:03:09.000000000 +0100
@@ -1,2 +1,3 @@
 50 initial_auto_raid
 55 initial_auto_raid_fs
+56 initial_auto_raid_lvm
diff -aburN -x .svn /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/README ./README
--- /home/plb/debian/sources/official/lenny/partman/partman-auto-raid-14/README	2008-08-09 21:26:07.000000000 +0200
+++ ./README	2009-02-23 17:03:09.000000000 +0100
@@ -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/sda /dev/sdb
+
+d-i partman-auto-raid/recipe string			\
+	1 2 0 ext3 /boot				\
+		/dev/sda1#/dev/sdb1			\
+	.						\
+	1 2 0 lvm -					\
+		/dev/sda5#/dev/sdb5			\
+	.
+
+# 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 ---

Reply to: