6 # No mdadm? No mdraid support.
7 require_binaries mdadm ||
return 1
9 [[ $hostonly ]] ||
[[ $mount_needs ]] && {
10 for dev
in "${!host_fs_types[@]}"; do
11 [[ "${host_fs_types[$dev]}" != *_raid_member
]] && continue
13 DEVPATH
=$
(get_devpath_block
"$dev")
15 for holder
in "$DEVPATH"/holders
/*; do
16 [[ -e "$holder" ]] ||
continue
17 [[ -e "$holder/md" ]] && return 0
41 local _activated dev line UUID
44 for dev
in "${!host_fs_types[@]}"; do
45 [[ "${host_fs_types[$dev]}" != *_raid_member
]] && continue
48 /sbin
/mdadm
--examine --export $dev \
49 |
while read line ||
[ -n "$line" ]; do
50 [[ ${line#MD_UUID=} = $line ]] && continue
51 printf "%s" "${line#MD_UUID=} "
55 [[ -z "$UUID" ]] && continue
57 if ! [[ ${_activated[${UUID}]} ]]; then
58 printf "%s" " rd.md.uuid=${UUID}"
59 _activated
["${UUID}"]=1
69 inst_multiple
-o mdmon
70 inst $
(command -v partx
) /sbin
/partx
71 inst $
(command -v mdadm
) /sbin
/mdadm
73 if [[ $hostonly_cmdline == "yes" ]]; then
74 local _raidconf
=$
(cmdline
)
75 [[ $_raidconf ]] && printf "%s\n" "$_raidconf" >> "${initdir}/etc/cmdline.d/90mdraid.conf"
78 # <mdadm-3.3 udev rule
79 inst_rules
64-md-raid.rules
80 # >=mdadm-3.3 udev rules
81 inst_rules
63-md-raid-arrays.rules
64-md-raid-assembly.rules
82 # remove incremental assembly from stock rules, so they don't shadow
83 # 65-md-inc*.rules and its fine-grained controls, or cause other problems
84 # when we explicitly don't want certain components to be incrementally
86 for rule
in 64-md-raid.rules
64-md-raid-assembly.rules
; do
87 rule_path
="${initdir}${udevdir}/rules.d/${rule}"
88 [ -f "${rule_path}" ] && sed -i -r \
89 -e '/(RUN|IMPORT\{program\})\+?="[[:alpha:]/]*mdadm[[:blank:]]+(--incremental|-I)[[:blank:]]+(--export )?(\$env\{DEVNAME\}|\$tempnode|\$devnode)/d' \
93 inst_rules
"$moddir/65-md-incremental-imsm.rules"
95 inst_rules
"$moddir/59-persistent-storage-md.rules"
96 prepare_udev_rules
59-persistent-storage-md.rules
98 # guard against pre-3.0 mdadm versions, that can't handle containers
99 if ! mdadm
-Q -e imsm
/dev
/null
>/dev
/null
2>&1; then
100 inst_hook pre-trigger
30 "$moddir/md-noimsm.sh"
102 if ! mdadm
-Q -e ddf
/dev
/null
>/dev
/null
2>&1; then
103 inst_hook pre-trigger
30 "$moddir/md-noddf.sh"
106 if [[ $hostonly ]] ||
[[ $mdadmconf = "yes" ]]; then
107 if [ -f /etc
/mdadm.conf
]; then
108 inst
-H /etc
/mdadm.conf
110 [ -f /etc
/mdadm
/mdadm.conf
] && inst
-H /etc
/mdadm
/mdadm.conf
/etc
/mdadm.conf
112 if [ -d /etc
/mdadm.conf.d
]; then
114 inst_dir
/etc
/mdadm.conf.d
115 for f
in /etc
/mdadm.conf.d
/*.conf
; do
116 [ -f "$f" ] ||
continue
122 inst_hook pre-udev
30 "$moddir/mdmon-pre-udev.sh"
123 inst_hook pre-trigger
30 "$moddir/parse-md.sh"
124 inst_hook pre-mount
10 "$moddir/mdraid-waitclean.sh"
125 inst_hook cleanup
99 "$moddir/mdraid-needshutdown.sh"
126 inst_hook shutdown
30 "$moddir/md-shutdown.sh"
127 inst_script
"$moddir/mdraid-cleanup.sh" /sbin
/mdraid-cleanup
128 inst_script
"$moddir/mdraid_start.sh" /sbin
/mdraid_start
129 if dracut_module_included
"systemd"; then
130 if [ -e $systemdsystemunitdir/mdmon@.service
]; then
131 inst_simple
$systemdsystemunitdir/mdmon@.service
134 inst_hook pre-shutdown
30 "$moddir/mdmon-pre-shutdown.sh"