dracut-systemd/dracut-initqueue: only start service if really needed
[dracut.git] / modules.d / 90mdraid / parse-md.sh
blob24fc6d3ff9ae5de707def0f48c1e2926889dfd78
1 #!/bin/sh
3 MD_UUID=$(getargs rd.md.uuid -d rd_MD_UUID=)
5 if ( ! [ -n "$MD_UUID" ] && ! getargbool 0 rd.auto ) || ! getargbool 1 rd.md -d -n rd_NO_MD; then
6 info "rd.md=0: removing MD RAID activation"
7 udevproperty rd_NO_MD=1
8 else
9 # rewrite the md rules to only process the specified raid array
10 if [ -n "$MD_UUID" ]; then
11 for f in /etc/udev/rules.d/65-md-incremental*.rules; do
12 [ -e "$f" ] || continue
13 while read line || [ -n "$line" ]; do
14 if [ "${line%%UUID CHECK}" != "$line" ]; then
15 printf 'IMPORT{program}="/sbin/mdadm --examine --export $tempnode"\n'
16 for uuid in $MD_UUID; do
17 printf 'ENV{MD_UUID}=="%s", GOTO="md_uuid_ok"\n' $uuid
18 printf 'ENV{ID_FS_UUID}=="%s", GOTO="md_uuid_ok"\n' $uuid
19 done;
20 printf 'GOTO="md_end"\n'
21 printf 'LABEL="md_uuid_ok"\n'
22 else
23 echo "$line"
25 done < "${f}" > "${f}.new"
26 mv "${f}.new" "$f"
27 done
32 if [ -e /etc/mdadm.conf ] && getargbool 1 rd.md.conf -d -n rd_NO_MDADMCONF; then
33 udevproperty rd_MDADMCONF=1
34 rm -f -- $hookdir/pre-pivot/*mdraid-cleanup.sh
37 if ! getargbool 1 rd.md.conf -d -n rd_NO_MDADMCONF; then
38 rm -f -- /etc/mdadm/mdadm.conf /etc/mdadm.conf
39 ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
42 # noiswmd nodmraid for anaconda / rc.sysinit compatibility
43 # note nodmraid really means nobiosraid, so we don't want MDIMSM then either
44 if ! getargbool 1 rd.md.imsm -d -n rd_NO_MDIMSM -n noiswmd -n nodmraid; then
45 info "no MD RAID for imsm/isw raids"
46 udevproperty rd_NO_MDIMSM=1
49 # same thing with ddf containers
50 if ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF -n noddfmd -n nodmraid; then
51 info "no MD RAID for SNIA ddf raids"
52 udevproperty rd_NO_MDDDF=1
55 strstr "$(mdadm --help-options 2>&1)" offroot && udevproperty rd_MD_OFFROOT=--offroot