Skip to content

Instantly share code, notes, and snippets.

@albertywu
Last active March 17, 2021 00:19
Show Gist options
  • Select an option

  • Save albertywu/f231b62589563ae22b5fb3e5c33f1ca1 to your computer and use it in GitHub Desktop.

Select an option

Save albertywu/f231b62589563ae22b5fb3e5c33f1ca1 to your computer and use it in GitHub Desktop.
raid0 setup
# note: run as root
devicemount=/mnt
logicalname=/dev/md0
# get instance storage block devices
devices=( $(lsblk -o name,type,size,model,mountpoint | grep -i "NVMe Instance Storage" | awk '{print "/dev/"$1}') )
if [[ "${#devices[@]}" -gt 0 ]] ; then
mkdir -p "$devicemount"
fi
if [[ "${#devices[@]}" -eq 1 ]] ; then
mkfs -t xfs "${devices[0]}" > /dev/null
mount -t xfs "${devices[0]}" "$devicemount"
elif [[ "${#devices[@]}" -gt 1 ]] ; then
mdadm \
--create "$logicalname" \
--level=0 \
--raid-devices="${#devices[@]}" "${devices[@]}"
echo "DEVICE ${devices[*]}" > /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf
mkfs -t xfs "$logicalname" > /dev/null
mount "$logicalname" "$devicemount"
fi
chmod -R 777 "$devicemount"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment