Skip to content

Instantly share code, notes, and snippets.

@rezamt
Created January 28, 2019 00:42
Show Gist options
  • Save rezamt/e862efe8a3cac5478c7232e72588c9eb to your computer and use it in GitHub Desktop.
Save rezamt/e862efe8a3cac5478c7232e72588c9eb to your computer and use it in GitHub Desktop.
umount and clean file system
#!/bin/bash
cp /etc/fstab /etc/fstb.original
FDISKLIST=`fdisk -l|grep "Disk /dev/xvd"|awk '{print $2}'|awk -F: '{print $1}'|grep -v /dev/xvda`
for DISK in `echo $FDISKLIST`
do
DISKNAME=`echo $DISK|awk -F/ '{print $3}'`
umount -f $DISK1 || /bin/true
rm -rf /disk/$DISKNAME || /bin/true
wipefs -f -a $DISK || /bin/true
sed -i "/$DISKNAME/d" /etc/fstab
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment