#!/bin/ksh
#
# This script performs a basic cleanup of a volume group in
# order to provide a somewhat secure remove of data. This is
# obviously not DOD or financial system grade data erasure,
# but may be sufficient for many enviroments when turning
# systems over to a recycling company or at the end of an
# offsite disaster recovery test.
#
# The script does the following actions:
# For each volume in the indicated volume group:
# - kill any processes using file systems in the volume group
# - recursively remove all files in the volume
# - remove the file system with rmfs
# - once all the volumes are removed, remove the volume group
# via reducevg.
#
# For best results,
# follow up the deletion of the volume group with a creation
# of a new volume group re-using the PVs.
#
# Andy Welter
# January 2005
#
VG=$1
TESTRUN=$2
if [ "$VG" = "" ]; then
print "ERROR: must specify a volume group"
exit 1
fi
print "!!!!!!!! WARNING !!!!!!!"
print "!!! This script will !!!"
print "!!! delete all data !!!"
print "!!! on the following !!!"
print "!!! volume group: !!!"
print
lsvg -l $VG
print "Whack $VG ?\n\n"
read ANS
case $ANS in
y|Y) print "Ok, here we go"
sleep 2
;;
*) print "Quitting."
exit 1
;;
esac
lsvg -l $VG | sort -b +6r| egrep "jfs |jfs2 " | grep -v "^LV NAME" | \
while read LVNAME TYPE LP PP PV STATE MOUNT; do
print "removing $MOUNT..." >&2
if [ "$TESTRUN" = "" ]; then
fuser -ck $MOUNT
find $MOUNT -xdev -depth -exec rm {} \;
ls -alR $MOUNT
umount $MOUNT
rmfs $MOUNT
else
print "test: $MOUNT"
fi
done
lspv | while read PVNAME VOLID CURVG STATUS; do
case $CURVG in
$VG) print "remove $PVNAME from $VG"
if [ "$TESTRUN" = "" ]; then
reducevg -df $VG $PVNAME
fi
;;
*) print "ignore $PVNAME... belongs to $CURVG"
;;
esac
done