]>
Commit | Line | Data |
---|---|---|
95d2dabc | 1 | #!/bin/bash |
95d2dabc | 2 | |
77403e00 DY |
3 | is_mpath() { |
4 | local _dev=$1 | |
5 | [ -e /sys/dev/block/$_dev/dm/uuid ] || return 1 | |
6 | [[ $(cat /sys/dev/block/$_dev/dm/uuid) =~ mpath- ]] && return 0 | |
7 | return 1 | |
8 | } | |
9 | ||
35e86ac1 KS |
10 | majmin_to_mpath_dev() { |
11 | local _dev | |
12 | for i in /dev/mapper/*; do | |
13 | [[ $i == /dev/mapper/control ]] && continue | |
14 | _dev=$(get_maj_min $i) | |
15 | if [ "$_dev" = "$1" ]; then | |
16 | echo $i | |
17 | return | |
18 | fi | |
19 | done | |
20 | } | |
21 | ||
8bcfd683 | 22 | # called by dracut |
95d2dabc | 23 | check() { |
29b10e65 | 24 | local _rootdev |
95d2dabc | 25 | |
5dc1be1d | 26 | [[ $hostonly ]] || [[ $mount_needs ]] && { |
1b0a362d | 27 | for_each_host_dev_and_slaves is_mpath || return 255 |
5dc1be1d | 28 | } |
95d2dabc | 29 | |
ee6b4434 FV |
30 | # if there's no multipath binary, no go. |
31 | require_binaries multipath || return 1 | |
32 | ||
95d2dabc HH |
33 | return 0 |
34 | } | |
35 | ||
8bcfd683 | 36 | # called by dracut |
95d2dabc HH |
37 | depends() { |
38 | echo rootfs-block | |
15976a06 | 39 | echo dm |
95d2dabc HH |
40 | return 0 |
41 | } | |
42 | ||
856f8265 HR |
43 | # called by dracut |
44 | cmdline() { | |
d842d5cf | 45 | for m in scsi_dh_alua scsi_dh_emc scsi_dh_rdac dm_multipath; do |
3f60444e | 46 | if grep -m 1 -q "$m" /proc/modules ; then |
856f8265 HR |
47 | printf 'rd.driver.pre=%s ' "$m" |
48 | fi | |
49 | done | |
50 | } | |
51 | ||
8bcfd683 | 52 | # called by dracut |
95d2dabc | 53 | installkernel() { |
9073ff54 | 54 | local _ret |
2d2c8c20 | 55 | local _arch=$(uname -m) |
794b2d2c HH |
56 | local _funcs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target' |
57 | local _s390 | |
2d2c8c20 | 58 | |
794b2d2c HH |
59 | if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then |
60 | _s390drivers="=drivers/s390/scsi" | |
61 | fi | |
95d2dabc | 62 | |
8d9ab275 | 63 | hostonly='' dracut_instmods -o -s "$_funcs" "=drivers/scsi" "=drivers/md" ${_s390drivers:+"$_s390drivers"} |
95d2dabc HH |
64 | } |
65 | ||
8bcfd683 | 66 | # called by dracut |
95d2dabc | 67 | install() { |
77403e00 | 68 | local _f _allow |
77403e00 | 69 | |
35e86ac1 KS |
70 | add_hostonly_mpath_conf() { |
71 | is_mpath $1 && { | |
72 | local _dev | |
73 | ||
74 | _dev=$(majmin_to_mpath_dev $1) | |
75 | [ -z "$_dev" ] && return | |
76 | strstr "$_allow" "$_dev" && return | |
77 | _allow="$_allow --allow $_dev" | |
78 | } | |
79 | } | |
80 | ||
af119460 | 81 | inst_multiple -o \ |
8a240aca HH |
82 | dmsetup \ |
83 | kpartx \ | |
8a240aca HH |
84 | mpath_wait \ |
85 | multipath \ | |
86 | multipathd \ | |
1b0a362d | 87 | mpathpersist \ |
8a240aca HH |
88 | xdrgetuid \ |
89 | xdrgetprio \ | |
95d2dabc HH |
90 | /etc/xdrdevices.conf \ |
91 | /etc/multipath.conf \ | |
d000b9a2 DM |
92 | /etc/multipath/* \ |
93 | /etc/multipath/conf.d/* | |
95d2dabc | 94 | |
35e86ac1 KS |
95 | [[ $hostonly ]] && [[ $hostonly_mode = "strict" ]] && { |
96 | for_each_host_dev_and_slaves_all add_hostonly_mpath_conf | |
97 | [ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf | |
98 | } | |
99 | ||
24a38bc1 HH |
100 | inst $(command -v partx) /sbin/partx |
101 | ||
53fe81e7 | 102 | inst_libdir_file "libmultipath*" "multipath/*" |
cf864c1b | 103 | inst_libdir_file 'libgcc_s.so*' |
c9143a63 | 104 | |
856f8265 HR |
105 | if [[ $hostonly_cmdline ]] ; then |
106 | local _conf=$(cmdline) | |
107 | [[ $_conf ]] && echo "$_conf" >> "${initdir}/etc/cmdline.d/90multipath.conf" | |
108 | fi | |
109 | ||
1b0a362d | 110 | if dracut_module_included "systemd"; then |
78a78e42 HR |
111 | inst_simple "${moddir}/multipathd.service" "${systemdsystemunitdir}/multipathd.service" |
112 | mkdir -p "${initdir}${systemdsystemunitdir}/sysinit.target.wants" | |
113 | ln -rfs "${initdir}${systemdsystemunitdir}/multipathd.service" "${initdir}${systemdsystemunitdir}/sysinit.target.wants/multipathd.service" | |
1b0a362d HH |
114 | else |
115 | inst_hook pre-trigger 02 "$moddir/multipathd.sh" | |
116 | inst_hook cleanup 02 "$moddir/multipathd-stop.sh" | |
117 | fi | |
e84d115b HH |
118 | |
119 | inst_hook cleanup 80 "$moddir/multipathd-needshutdown.sh" | |
239e8ba2 | 120 | inst_hook shutdown 20 "$moddir/multipath-shutdown.sh" |
e84d115b | 121 | |
8f4ee8c7 HR |
122 | inst_rules 40-multipath.rules 56-multipath.rules \ |
123 | 62-multipath.rules 65-multipath.rules \ | |
124 | 66-kpartx.rules 67-kpartx-compat.rules \ | |
125 | 11-dm-mpath.rules | |
95d2dabc HH |
126 | } |
127 |