Created
February 27, 2017 15:26
-
-
Save agarstang/ad1a9ad296f6a533db1c3cd22559dd81 to your computer and use it in GitHub Desktop.
Bash UserData format additional disks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for device in $(lsblk -ln -o NAME | grep -Ev '^xvda\d*') | |
do | |
blkdevice="/dev/$device" | |
echo "Removing any pre-existing mount points for $blkdevice" | |
umount -f $blkdevice | |
sed -i "/^\/dev\/$device/d" /etc/fstab | |
echo "Checking if $blkdevice is formatted.." | |
/sbin/blkid -t TYPE=ext4 $blkdevice || (echo "Formatting $blkdevice" && /sbin/mkfs.ext4 $blkdevice) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment