diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 13:54:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 13:54:25 +0000 |
commit | 9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a (patch) | |
tree | 2efb72864cc69e174c9c5ee33efb88a5f1553b48 /modules.d/90dmraid | |
parent | Initial commit. (diff) | |
download | dracut-9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a.tar.xz dracut-9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a.zip |
Adding upstream version 060+5.upstream/060+5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules.d/90dmraid')
-rw-r--r-- | modules.d/90dmraid/61-dmraid-imsm.rules | 28 | ||||
-rwxr-xr-x | modules.d/90dmraid/dmraid.sh | 46 | ||||
-rwxr-xr-x | modules.d/90dmraid/module-setup.sh | 87 | ||||
-rwxr-xr-x | modules.d/90dmraid/parse-dm.sh | 27 |
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 |