Saturday, January 3, 2015

How to wipe out disk on Solaris OE?

How to wipe out Solaris disks?
#!/usr/bin/ksh
 # wipeall.sh
 ## The purpose of this script is for mass disk erasing.
 # It is designed to wipe ALL disks attached to the server, except for
 # the boot disks (/dev/rdsk/c0*). If you are booting from a different
 # controller, be sure to set the BOOT variable below!
 #
 # wipeall.sh uses dd to copy /dev/zero to the entire raw disk device.
 # ################################################################################
 BOOT=c0
 LOG="tee -a wipelog.txt"
 if [ -e wipelog.txt ]; then
 echo Found old wipelog.txt, clearing log. | $LOG
 rm -f wipelog.txt
 touch wipelog.txt
 fi
 echo -n Standby while cleaning up device links... |$LOG
 #/usr/sbin/devfsadm -C -v | $LOG
 echo OK |tee -a wipelog.txt
 DISKS=`find /dev/rdsk -name \*d0s2 -exec basename {} \; |grep -v $BOOT`
 # Did we actually find any disks? If not lets stop now.
 if [ -z "$DISKS" ]; then
 echo "Whoops! NO Disks Found (besides the boot disks)!" |$LOG
 echo "Aborting." | $LOG
 exit 1;
 fi
 echo "Found the following disks (minus boot array disks):" |$LOG
 echo "$DISKS" | $LOG
 echo -n "Do you wish to proceed with erasing these disks? (Y/N) " |$LOG
 read continue
 if ( [ "$continue" == "Y" ] || [ "$continue" == "y" ] ); then
 echo "" | $LOG
 echo `date` Proceeding to wipe all disks. | $LOG
 for DISK in $DISKS
 do
 echo "-----------------------------------------------------------" | $LOG
 echo Starting wipe of /dev/rdsk/$DISK at: `date` | $LOG
 dd bs=128k if=/dev/zero of=/dev/rdsk/$DISK 2>&1 |$LOG
 echo Completed wipe at: `date` | $LOG
 done
 echo "============================================================" | $LOG
 echo `date` All disks wiped. | $LOG
 /usr/bin/mailx -s "Disk Wipe Report" sysadmin@yourdomain.com
 else
 echo “User aborted.” | $LOG
 exit
 fi

source: unknown

No comments:

Post a Comment