have_md=no
# if we should init dmraid at boot
have_dmraid=no
-# if we should init dm-multipath at boot
-have_multipath=no
-# dm-multipath wwid which is used for rootfs
-MPATH_WWID=
usage() {
uname_r=$(uname -r)
esac
}
-# find dm-multipath modules for $devpath
-# returns false if $devpath is not dm-multipath
-find_modules_multipath() {
- local devpath="$1"
-
- DM_NAME=
- eval $(dm_export "$devpath")
- if [ -z "$DM_NAME" ]; then
- die "dm_export failed unexpectedly"
- fi
-
- # Partition:
- # DM_NAME=LUN-28p1
- # DM_UUID=part1-mpath-36006016002c11800a0aa05fbfae0db11
- # Disk:
- # DM_NAME=LUN-28
- # DM_UUID=mpath-36006016002c11800a0aa05fbfae0db11
- MPATH_WWID=${DM_UUID##*-}
-
- local info=$(multipath -l $MPATH_WWID)
- if [ -z "$info" ]; then
- return 1
- fi
-
- debug "Finding modules for dm-multipath (WWID=$MPATH_WWID)"
- have_multipath=yes
- local dev phydevs=$(echo "$info" | awk '$2 ~ /^[0-9]+:[0-9]+:[0-9]+:[0-9]+$/{printf("/dev/%s\n", $3)}')
- for dev in $phydevs; do
- find_modules_for_devpath $dev
- lvm_ignore_devices="$lvm_ignore_devices $dev"
- done
-
- local hw hwhandlers=$(echo "$info" | awk '/hwhandler=1/{sub(/.*hwhandler=1 /, ""); sub(/\]$/, ""); print}')
- for hw in $hwhandlers; do
- findmodule "dm-$hw"
- done
-
- local target targets=$(echo "$info" | awk '/prio=/{print $2}' | sort -u)
- for target in $targets; do
- findmodule "dm-$target"
- done
-
- findmodule "dm-mod"
- return 0
-}
# find dmraid modules for $devpath
# returns false if $devpath is not on dmraid
return
fi
- if is_yes "$USE_MULTIPATH" && [[ "$devpath" == /dev/mapper/* ]]; then
+ if is_multipath "$devpath"; then
if find_modules_multipath "$devpath"; then
return
fi
EOF
}
-initrd_gen_multipath() {
- inst_d /sbin /lib/udev /etc/multipath
- inst_exec /sbin/kpartx /sbin
- inst_exec /sbin/multipath /sbin
- # for udev callouts
- inst_exec /sbin/scsi_id /lib/udev
- inst_exec /sbin/mpath* /sbin
- egrep -v '^([ ]*$|#)' /etc/multipath.conf > $DESTDIR/etc/multipath.conf
-
- if [ -f /etc/multipath/bindings ]; then
- egrep -v '^([ ]*$|#)' /etc/multipath/bindings > $DESTDIR/etc/multipath/bindings
- else
- touch $DESTDIR/etc/multipath/bindings
- fi
-
- mount_dev
- initrd_gen_devices
-
- mount_sys
- echo "export MPATH_WWID=$MPATH_WWID" | add_linuxrc
- add_linuxrc <<-'EOF'
- # parse mpath_wwid= from kernel commandline
- for arg in $CMDLINE; do
- if [ "${arg##mpath_wwid=}" != "${arg}" ]; then
- MPATH_WWID=${arg##mpath_wwid=}
- if [ "$MPATH_WWID" = "*" ]; then
- # '*' would mean activate all WWID-s
- MPATH_WWID=
- echo "multipath: Activating all WWID-s"
- else
- echo "multipath: Activating WWID=$WWID"
- fi
- fi
- done
-
- debugshell
- /sbin/multipath -v 0 $MPATH_WWID
-
- for a in /dev/mapper/*; do
- [ $a = /dev/mapper/control ] && continue
- /sbin/kpartx -a -p p $a
- done
- debugshell
- EOF
-}
initrd_gen_dmraid() {
if [ ! -x /sbin/dmraid-initrd ]; then
# cryptsetup luks addon
. /etc/geninitrd/mod-luks.sh
-
-if [ -x /sbin/multipath ]; then
- USE_MULTIPATH=yes
-fi
+# dm-multipath addon
+. /etc/geninitrd/mod-multipath.sh
if [ -x /sbin/initrd-blkid ]; then
USE_BLKID=yes