You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
619 B

5 years ago
#!/usr/bin/env bash
help() {
echo "USAGE: makeraid [level] [device] [device] ... [ [--spares] [device] ... ]"
}
[[ :0:1:4:5:6:10: == *:${1}:* ]] && RL=${1} || { help; exit 1; }
shift
until [ "${1}" = "--spares" ]; do
[ -b "${1}" ] && RD+=("${1}") || { help; exit 2; }
shift
[ ${#} = 0 ] && break
done
if [ "${1}" == "--spares" ]; then
shift
for DV in ${@}; do
SD+=("${DV}")
done
fi
[ "${#SD[@]}" -gt "0" ] && SO=( "-x" "${#SD[@]}" )
for MD in {0..127}; do
[ ! -b "/dev/md${MD}" ] && ND=${MD} && break
done
mdadm -Cve 1.2 /dev/md${ND} -l "${RL}" -c 32 -n ${#RD[@]} ${RD[@]} ${SO[@]} ${SD[@]}