mirror of
https://gitdl.cn/https://github.com/chakralinux/core.git
synced 2025-01-24 02:22:15 +08:00
48 lines
1.4 KiB
Bash
Executable File
48 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/ash
|
|
|
|
run_hook() {
|
|
local i= mdconfig=/etc/mdadm.conf
|
|
|
|
# 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
|
|
case $i in
|
|
# raid
|
|
md=[0-9]*,/*)
|
|
device=${i%%,*}
|
|
device=${device/=/}
|
|
array=${i#*,}
|
|
echo "ARRAY /dev/$device devices=$array"
|
|
;;
|
|
# partitionable raid
|
|
md=d[0-9]*,/*)
|
|
device=${i%%,*}
|
|
device=${device/=/_}
|
|
array=${i#*,}
|
|
echo "ARRAY /dev/$device devices=$array"
|
|
;;
|
|
# raid UUID
|
|
md=[0-9]*,[0-9,a-fA-F]*)
|
|
device=${i%%,*}
|
|
device=${device/=/}
|
|
array=${i#*,}
|
|
echo "ARRAY /dev/$device UUID=$array"
|
|
;;
|
|
# partitionable raid UUID
|
|
md=d[0-9]*,[0-9,a-fA-F]*)
|
|
device=${i%%,*}
|
|
device=${device/=/_}
|
|
array=${i#*,}
|
|
echo "ARRAY /dev/$device UUID=$array"
|
|
;;
|
|
esac
|
|
done >>"$mdconfig"
|
|
fi
|
|
|
|
# assemble everything
|
|
[ -s "$mdconfig" ] && /sbin/mdassemble
|
|
}
|