This is an old revision of the document!
Shutdown the GUI, if there is one:
init 3
Clean out the junk:
yum clean all logrotate -f /etc/logrotate.conf rm -f /var/log/*-???????? /var/log/*.gz cat /dev/null > /var/log/audit/audit.log cat /dev/null > /var/log/wtmp rm -f /etc/udev/rules.d/70* sed -i ‘/^\(HWADDR\|UUID|BOOTPROTO\)=/d’ /etc/sysconfig/network-scripts/ifcfg-eth[012] echo "BOOTPROTO=dhcp" > /etc/sysconfig/network-scripts/ifcfg-eth0 rm -rf /tmp/* rm -rf /var/tmp/* rm -rf /etc/ssh/*key* rm -rf ~root/.bash_history unset HISTFILE
This is an optional script for RHEL systems to zero out the filesystem.
Don't do this on thinly provisioned VMs.
UNTESTED
#!/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