[readonly/geninitrd: 454/1068] - initial dm-multpath hooks
draenog
draenog at pld-linux.org
Sat Nov 2 19:50:32 CET 2013
commit 2cc3ae8b276de38ca4b0b6bde949ae19f6c02a9a
Author: Elan Ruusamäe <glen at pld-linux.org>
Date: Wed Oct 24 14:46:53 2007 +0000
- initial dm-multpath hooks
svn-id: @8850
geninitrd | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 84 insertions(+), 12 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 2eac254..c63c0e6 100755
--- a/geninitrd
+++ b/geninitrd
@@ -71,6 +71,10 @@ if [ -x /sbin/dmraid-initrd ]; then
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 @@ usage () {
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 @@ while [ $# -gt 0 ]; do
--without-dmraid)
USE_DMRAID=
;;
+ --without-multipath)
+ USE_MULTPATH=
+ ;;
--with=*)
BASICMODULES="$BASICMODULES `echo $1 | awk -F= '{print $2;}'`"
;;
@@ -1020,11 +1027,17 @@ fi
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 @@ initrd_gen_udev() {
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 @@ initrd_gen_lvm() {
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 @@ initrd_gen_lvm() {
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 @@ if [ "$dmraid_devices" ]; then
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
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/147754ca159d40ca5eb541074dc043d8cbd92090
More information about the pld-cvs-commit
mailing list