SVN: geninitrd/trunk/geninitrd

glen glen at pld-linux.org
Wed Oct 24 16:46:54 CEST 2007


Author: glen
Date: Wed Oct 24 16:46:53 2007
New Revision: 8850

Modified:
   geninitrd/trunk/geninitrd
Log:
- initial dm-multpath hooks

Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd	(original)
+++ geninitrd/trunk/geninitrd	Wed Oct 24 16:46:53 2007
@@ -71,6 +71,10 @@
 	USE_DMRAID="yes"
 fi
 
+if [ -x /sbin/multipath ]; then
+	USE_MULTIPATH="yes"
+fi
+
 usage () {
 	uname_r=$(uname -r)
 	echo "usage: $PROGRAM [--version] [-v] [-f] [--ifneeded] [--preload <module>]"
@@ -82,7 +86,7 @@
 	echo "       [--lvmtoolsversion=1|2] [--with-udev] [--without-udev]"
 	echo "       [--with-suspend] [--without-suspend]"
 	echo "       [--with-tuxonice] [--without-tuxonice]"
-	echo "       [--without-dmraid]"
+	echo "       [--without-dmraid] [--without-multipath]"
 	echo "       <initrd-image> <kernel-version>"
 	echo ""
 	echo "example:"
@@ -814,6 +818,9 @@
 	--without-dmraid)
 		USE_DMRAID=
 		;;
+	--without-multipath)
+		USE_MULTPATH=
+		;;
 	--with=*)
 		BASICMODULES="$BASICMODULES `echo $1 | awk -F= '{print $2;}'`"
 		;;
@@ -1020,11 +1027,17 @@
 if is_yes "$FB_SPLASH"; then
 	findmodule "-evdev"
 fi
+
+if is_yes "$USE_MULTIPATH"; then
+	findmodule "dm-multipath"
+	findmodule "dm-round-robin"
+	findmodule "dm-emc"
+fi
+
 if [ -n "$ifneeded" -a -z "$MODULES" ]; then
 	debug "No modules are needed -- not building initrd image."
 	exit 0
 fi
-
 debug "Using modules: $MODULES"
 
 MNTIMAGE="`mktemp -d /tmp/initrd.XXXXXX`"
@@ -1188,6 +1201,58 @@
 	fi
 }
 
+initrd_gen_multipath() {
+	set -x
+
+	inst_d /proc /sys /sbin /lib/udev
+#	inst /sbin/multipathd /sbin
+	inst /sbin/kpartx /sbin
+#	inst /bin/mountpoint /bin
+#	inst /sbin/devmap_name /sbin
+	inst /sbin/multipath /sbin
+	# for udev callouts
+	inst /sbin/scsi_id /lib/udev
+	for a in /sbin/mpath*; do
+	   inst $a /sbin
+	done
+
+	if [ -d /lib64 ]; then
+		lib=/lib64
+	else
+		lib=/lib
+	fi
+	inst_d $lib
+	inst /lib64/ld-linux-x86-64.so.2 $lib
+	for a in $(ldd /sbin/kpartx /sbin/multipath | awk '{print $3}'); do
+	   	inst $a $lib
+	done
+	for a in $(ldd $MNTIMAGE$lib/lib* | awk '{print $3}'); do
+	   	inst $a $lib
+	done
+
+	cat <<-'EOF' >> "$s"
+	mount -t proc none /proc
+	mount -t sysfs none /sys
+EOF
+
+	initrd_gen_tmpfs_dev
+	initrd_gen_devices
+
+	cat <<-'EOF' >> "$s"
+	/sbin/multipath -v 0
+
+	for a in /dev/mapper/*; do
+		[ $a = /dev/mapper/control ] && continue
+		kpartx -a $a
+	done
+	rm -f /dev/sd?* # XXX adjust lvm.conf instead. however at initrd creation time
+	sh
+
+	umount /sys
+	umount /proc
+EOF
+}
+
 initrd_gen_dmraid() {
 	if [ ! -x /sbin/dmraid-initrd ] ; then
 		die "/sbin/dmraid-initrd is missing missing!"
@@ -1370,15 +1435,17 @@
 		if is_yes "$raidfound"; then
 			echo "	md_component_detection = 1" >> "$MNTIMAGE/etc/lvm.conf"
 		fi
-		if [ "$dmraid_devices" ]; then
+		if [ "$dmraid_devices" ] || is_yes "$USE_MULTIPATH"; then
 			echo '	types = [ "device-mapper", 254 ]' >> "$MNTIMAGE/etc/lvm.conf"
+		fi
+		if [ "$dmraid_devices" ]; then
 			# ignore /dev/sd* devices that dmraid consists
-				echo '	filter = [' >> "$MNTIMAGE/etc/lvm.conf"
-				for dev in $dmraid_devices; do
-					debug "dmraid: ignoring $dev from LVM"
-					printf '  "r|^%s.*|",\n' $dev
-				done >> "$MNTIMAGE/etc/lvm.conf"
-				echo ']' >> "$MNTIMAGE/etc/lvm.conf"
+			echo '	filter = [' >> "$MNTIMAGE/etc/lvm.conf"
+			for dev in $dmraid_devices; do
+				debug "dmraid: ignoring $dev from LVM"
+				printf '  "r|^%s.*|",\n' $dev
+			done >> "$MNTIMAGE/etc/lvm.conf"
+			echo ']' >> "$MNTIMAGE/etc/lvm.conf"
 		fi
 		lvm dumpconfig | awk '/filter=/' >> "$MNTIMAGE/etc/lvm.conf"
 		echo "}" >> "$MNTIMAGE/etc/lvm.conf"
@@ -1391,16 +1458,17 @@
 		printk=\$(cat /proc/sys/kernel/printk)
 		echo 0 > /proc/sys/kernel/printk
 
+		export LVM_SYSTEM_DIR=/tmp
 		: 'Scanning for Volume Groups'
-		LVM_SYSTEM_DIR=/tmp lvm vgscan --mknodes --ignorelockingfailure 2>/dev/null
+		lvm vgscan --mknodes --ignorelockingfailure 2>/dev/null
 
 		: 'Activating Volume Groups'
-		LVM_SYSTEM_DIR=/tmp lvm vgchange --ignorelockingfailure -a y $VGVOLUME 2>/dev/null
+		lvm vgchange --ignorelockingfailure -a y $VGVOLUME 2>/dev/null
 
 		echo "\$printk" > /proc/sys/kernel/printk
 
 		# Find out major/minor
-		majmin="\$(LVM_SYSTEM_DIR=/tmp lvm lvdisplay --ignorelockingfailure -c $rootdev 2>/dev/null)"
+		majmin="\$(lvm lvdisplay --ignorelockingfailure -c $rootdev 2>/dev/null)"
 		majmin="\${majmin#*/}"
 		majmin="\${majmin#*:*:*:*:*:*:*:*:*:*:*:*}"
 		major="\${majmin%:*}"
@@ -1448,6 +1516,10 @@
 	initrd_gen_dmraid
 fi
 
+if [ "$USE_MULTIPATH" ]; then
+	initrd_gen_multipath
+fi
+
 if is_yes "$usenfs" ; then
 	initrd_gen_nfs
 elif is_yes "$USERAIDSTART" && is_yes "$raidfound"; then


More information about the pld-cvs-commit mailing list