From 2a0b63e8a1d2b831f7b0611a8cecb978cba40cef Mon Sep 17 00:00:00 2001 From: BrainwreckedTech <3752022+BrainwreckedTech@users.noreply.github.com> Date: Mon, 20 Dec 2021 01:15:40 -0500 Subject: [PATCH] Updated `makeraid` script --- makeraid | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/makeraid b/makeraid index 2d9f261..bcf4860 100755 --- a/makeraid +++ b/makeraid @@ -1,29 +1,28 @@ #!/usr/bin/env bash help() { - echo "USAGE: makeraid [level] [device] [device] ... [ [--spares] [device] ... ]" + echo "USAGE: makeraid [name] [md-name] [level] [device] [device] ... [ [--spares] [device] ... ]" } -[[ :0:1:4:5:6:10: == *:${1}:* ]] && RL=${1} || { help; exit 1; } +NAME="${1}"; shift +MDNM="${1}"; shift + +[[ :0:1:4:5:6:10: == *:${1}:* ]] && RDDVLV=${1} || { help; exit 1; } shift until [ "${1}" = "--spares" ]; do - [ -b "${1}" ] && RD+=("${1}") || { help; exit 2; } + [ -b "${1}" ] && RDDV+=("${1}") || { help; exit 2; } shift - [ ${#} = 0 ] && break + [ ${#} = 0 ] && break done if [ "${1}" == "--spares" ]; then shift for DV in ${@}; do - SD+=("${DV}") + SPDV+=("${DV}") done fi -[ "${#SD[@]}" -gt "0" ] && SO=( "-x" "${#SD[@]}" ) - -for MD in {0..127}; do - [ ! -b "/dev/md${MD}" ] && ND=${MD} && break -done +[ "${#SPDV[@]}" -gt "0" ] && SPOP=( "-x" "${#SPDV[@]}" ) -mdadm -Cve 1.2 /dev/md${ND} -l "${RL}" -c 32 -n ${#RD[@]} ${RD[@]} ${SO[@]} ${SD[@]} +mdadm -ve 1.2 -C "/dev/md/${MDNM}" -N "any:${NAME}" -l "${RDDVLV}" -c 32 -n ${#RDDV[@]} ${RDDV[@]} ${SPOP[@]} ${SPDV[@]}