core/mdadm/mdadm_hook

50 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

#!/usr/bin/ash
run_hook() {
local i= mdconfig=/etc/mdadm.conf
2010-03-13 23:25:19 +08:00
# for partitionable raid, we need to load md_mod first!
modprobe md_mod 2>/dev/null
if [ -n "$md" ]; then
echo 'DEVICE partitions' >"$mdconfig"
for i in $(cat /proc/cmdline); do
2010-03-13 23:25:19 +08:00
case $i in
# raid
2010-03-13 23:25:19 +08:00
md=[0-9]*,/*)
device=${i%%,*}
device=${device/=/}
array=${i#*,}
echo "ARRAY /dev/$device devices=$array"
2010-03-13 23:25:19 +08:00
;;
# partitionable raid
md=d[0-9]*,/*)
device=${i%%,*}
device=${device/=/_}
array=${i#*,}
echo "ARRAY /dev/$device devices=$array"
2010-03-13 23:25:19 +08:00
;;
# raid UUID
md=[0-9]*,[0-9,a-fA-F]*)
device=${i%%,*}
device=${device/=/}
array=${i#*,}
echo "ARRAY /dev/$device UUID=$array"
2010-03-13 23:25:19 +08:00
;;
# partitionable raid UUID
md=d[0-9]*,[0-9,a-fA-F]*)
device=${i%%,*}
device=${device/=/_}
array=${i#*,}
echo "ARRAY /dev/$device UUID=$array"
2010-03-13 23:25:19 +08:00
;;
esac
done >>"$mdconfig"
2010-03-13 23:25:19 +08:00
fi
2010-03-13 23:25:19 +08:00
# assemble everything
2014-11-14 02:21:22 +08:00
[ -s "$mdconfig" ] && /usr/sbin/mdassemble
}
2014-09-27 12:12:32 +08:00
# vim: set ft=sh ts=4 sw=4 et: