Created
September 5, 2017 18:29
-
-
Save giovannicandido/80554218b04545ca7a3a07aa2aaf2a0a to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
# Determine the version of RHEL | |
COND=`grep -i Taroon /etc/redhat-release` | |
if [ "$COND" = "" ]; then | |
export PREFIX="/usr/sbin" | |
else | |
export PREFIX="/sbin" | |
fi | |
FileSystem=`grep ext /etc/mtab| awk -F" " '{ print $2 }'` | |
for i in $FileSystem | |
do | |
echo $i | |
number=`df -B 512 $i | awk -F" " '{print $3}' | grep -v Used` | |
echo $number | |
percent=$(echo "scale=0; $number * 98 / 100" | bc ) | |
echo $percent | |
dd count=`echo $percent` if=/dev/zero of=`echo $i`/zf | |
/bin/sync | |
sleep 15 | |
rm -f $i/zf | |
done | |
VolumeGroup=`$PREFIX/vgdisplay | grep Name | awk -F" " '{ print $3 }'` | |
for j in $VolumeGroup | |
do | |
echo $j | |
$PREFIX/lvcreate -l `$PREFIX/vgdisplay $j | grep Free | awk -F" " '{ print $5 }'` -n zero $j | |
if [ -a /dev/$j/zero ]; then | |
cat /dev/zero > /dev/$j/zero | |
/bin/sync | |
sleep 15 | |
$PREFIX/lvremove -f /dev/$j/zero | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment