summaryrefslogtreecommitdiffstats
path: root/modules.d/90dmraid
diff options
context:
space:
mode:
Diffstat (limited to 'modules.d/90dmraid')
-rw-r--r--modules.d/90dmraid/61-dmraid-imsm.rules28
-rwxr-xr-xmodules.d/90dmraid/dmraid.sh46
-rwxr-xr-xmodules.d/90dmraid/module-setup.sh87
-rwxr-xr-xmodules.d/90dmraid/parse-dm.sh27
4 files changed, 188 insertions, 0 deletions
diff --git a/modules.d/90dmraid/61-dmraid-imsm.rules b/modules.d/90dmraid/61-dmraid-imsm.rules
new file mode 100644
index 0000000..8a6b215
--- /dev/null
+++ b/modules.d/90dmraid/61-dmraid-imsm.rules
@@ -0,0 +1,28 @@
+# This file causes block devices with RAID (dmraid) signatures to
+# automatically cause dmraid_scan to be run.
+# See udev(8) for syntax
+
+SUBSYSTEM!="block", GOTO="dm_end"
+ACTION!="add|change", GOTO="dm_end"
+# Also don't process disks that are slated to be a multipath device
+ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="dm_end"
+
+ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="dm_end"
+
+ENV{ID_FS_TYPE}!="*_raid_member", GOTO="dm_end"
+
+ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}!="?*", GOTO="dm_end"
+ENV{ID_FS_TYPE}=="ddf_raid_member", ENV{rd_NO_MDDDF}!="?*", GOTO="dm_end"
+
+ENV{rd_NO_DM}=="?*", GOTO="dm_end"
+
+OPTIONS:="nowatch"
+
+ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="dm_end"
+
+PROGRAM=="/bin/sh -c 'for i in $sys/$devpath/holders/dm-[0-9]*; do [ -e $$i ] && exit 0; done; exit 1;' ", \
+ GOTO="dm_end"
+
+RUN+="/sbin/initqueue --onetime --unique --settled /sbin/dmraid_scan $env{DEVNAME}"
+
+LABEL="dm_end"
diff --git a/modules.d/90dmraid/dmraid.sh b/modules.d/90dmraid/dmraid.sh
new file mode 100755
index 0000000..b517320
--- /dev/null
+++ b/modules.d/90dmraid/dmraid.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
+
+devenc=$(str_replace "$1" '/' '\2f')
+
+[ -e /tmp/dmraid."$devenc" ] && exit 0
+
+: > /tmp/dmraid."$devenc"
+
+DM_RAIDS=$(getargs rd.dm.uuid -d rd_DM_UUID=)
+
+if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then
+ # run dmraid if udev has settled
+ info "Scanning for dmraid devices $DM_RAIDS"
+ SETS=$(dmraid -c -s)
+
+ if [ "$SETS" = "no raid disks" -o "$SETS" = "no raid sets" ]; then
+ return
+ fi
+
+ info "Found dmraid sets:"
+ echo "$SETS" | vinfo
+
+ if [ -n "$DM_RAIDS" ]; then
+ # only activate specified DM RAIDS
+ for r in $DM_RAIDS; do
+ for s in $SETS; do
+ if [ "${s##"$r"}" != "$s" ]; then
+ info "Activating $s"
+ dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo
+ fi
+ done
+ done
+ else
+ # scan and activate all DM RAIDS
+ for s in $SETS; do
+ info "Activating $s"
+ dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo
+ [ -e "/dev/mapper/$s" ] && kpartx -a "/dev/mapper/$s" 2>&1 | vinfo
+ udevsettle
+ done
+ fi
+
+ need_shutdown
+fi
diff --git a/modules.d/90dmraid/module-setup.sh b/modules.d/90dmraid/module-setup.sh
new file mode 100755
index 0000000..482ae96
--- /dev/null
+++ b/modules.d/90dmraid/module-setup.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+# called by dracut
+check() {
+ local holder
+ local dev
+
+ # if we don't have dmraid installed on the host system, no point
+ # in trying to support it in the initramfs.
+ require_binaries dmraid || return 1
+ require_binaries kpartx || return 1
+
+ [[ $hostonly ]] || [[ $mount_needs ]] && {
+ for dev in "${!host_fs_types[@]}"; do
+ [[ ${host_fs_types[$dev]} != *_raid_member ]] && continue
+
+ DEVPATH=$(get_devpath_block "$dev")
+
+ for holder in "$DEVPATH"/holders/*; do
+ [[ -e $holder ]] || continue
+ [[ -e "$holder/dm" ]] && return 0
+ break
+ done
+
+ done
+ return 255
+ }
+
+ return 0
+}
+
+# called by dracut
+depends() {
+ echo dm rootfs-block
+ return 0
+}
+
+# called by dracut
+cmdline() {
+ local dev
+ local -A _activated
+
+ for dev in "${!host_fs_types[@]}"; do
+ local holder DEVPATH DM_NAME
+ [[ ${host_fs_types[$dev]} != *_raid_member ]] && continue
+
+ DEVPATH=$(get_devpath_block "$dev")
+
+ for holder in "$DEVPATH"/holders/*; do
+ [[ -e $holder ]] || continue
+ dev="/dev/${holder##*/}"
+ DM_NAME="$(dmsetup info -c --noheadings -o name "$dev" 2> /dev/null)"
+ [[ ${DM_NAME} ]] && break
+ done
+
+ [[ ${DM_NAME} ]] || continue
+
+ if ! [[ ${_activated[${DM_NAME}]} ]]; then
+ printf "%s" " rd.dm.uuid=${DM_NAME}"
+ _activated["${DM_NAME}"]=1
+ fi
+ done
+}
+
+# called by dracut
+install() {
+ local _raidconf
+
+ if [[ $hostonly_cmdline == "yes" ]]; then
+ _raidconf=$(cmdline)
+ [[ $_raidconf ]] && printf "%s\n" "$_raidconf" >> "${initdir}/etc/cmdline.d/90dmraid.conf"
+ fi
+
+ inst_multiple dmraid
+ inst_multiple -o kpartx
+ inst "$(command -v partx)" /sbin/partx
+
+ inst "$moddir/dmraid.sh" /sbin/dmraid_scan
+
+ inst_rules 66-kpartx.rules 67-kpartx-compat.rules
+
+ inst_libdir_file "libdmraid-events*.so*"
+
+ inst_rules "$moddir/61-dmraid-imsm.rules"
+ #inst "$moddir/dmraid-cleanup.sh" /sbin/dmraid-cleanup
+ inst_hook pre-trigger 30 "$moddir/parse-dm.sh"
+}
diff --git a/modules.d/90dmraid/parse-dm.sh b/modules.d/90dmraid/parse-dm.sh
new file mode 100755
index 0000000..d7a6b69
--- /dev/null
+++ b/modules.d/90dmraid/parse-dm.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# nodmraid for anaconda / rc.sysinit compatibility
+if ! getargbool 1 rd.dm -d -n rd_NO_DM || getarg "rd.dm=0" -d nodmraid; then
+ info "rd.dm=0: removing DM RAID activation"
+ udevproperty rd_NO_DM=1
+fi
+
+if ! command -v mdadm > /dev/null \
+ || ! getargbool 1 rd.md.imsm -d -n rd_NO_MDIMSM -n noiswmd \
+ || ! getargbool 1 rd.md -d -n rd_NO_MD; then
+ info "rd.md.imsm=0: no MD RAID for imsm/isw raids"
+ udevproperty rd_NO_MDIMSM=1
+fi
+
+if ! command -v mdadm > /dev/null \
+ || ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF -n noddfmd \
+ || ! getargbool 1 rd.md -d -n rd_NO_MD; then
+ info "rd.md.ddf=0: no MD RAID for SNIA ddf raids"
+ udevproperty rd_NO_MDDDF=1
+fi
+
+DM_RAIDS=$(getargs rd.dm.uuid -d rd_DM_UUID=)
+
+if [ -z "$DM_RAIDS" ] && ! getargbool 0 rd.auto; then
+ udevproperty rd_NO_DM=1
+fi