Scrubbing disks with a Solaris CD on a Sun server
Any time you’re re-purposing one of your servers, whether it be internally or as a salvage sale, etc., it’s always a good idea to scrub the drives so that your data is at least reasonably safe from being accessed by inappropriately inquisitive folks.
With Sun servers, the company provides a handy command-line utility called ‘format‘ that allows you to easily wipe a drive. According to the recommended Sun solution, you should use the ‘purge‘ command within the format menu to wipe each disk. Purge writes 4 different patterns to the disk, while analyzing whether or not you have bad sectors on the drive. If the first 4 passes are successful, purge writes another bit pattern to the drive and reports on its condition.
Of course, this process can take a day or more per drive, and so it’s nice to be able to automate the procedure so that the computer iterates through all the disks and wipes them. The previously mentioned Sun doc does cover a method of iterating through drives, but it requires you to first create a drive list and then run format with that list as an option. The following script simply searches for all the disks on the server, then iterates down through them, purging each one:
touch /tmp/wipescript
DISKS=`prtconf|grep sd,|grep -v "driver not attached"|wc -l`
DISKS=$(($DISKS-2))
#echo $DISKS
while [ $DISKS -ge 0 ]
do
echo disk>>/tmp/wipescript
echo $DISKS>>/tmp/wipescript
echo defect>>/tmp/wipescript
echo primary>>/tmp/wipescript
echo quit>>/tmp/wipescript
echo analyze>>/tmp/wipescript
echo purge>>/tmp/wipescript
echo quit>>/tmp/wipescript
echo defect>>/tmp/wipescript
echo both>>/tmp/wipescript
echo quit>>/tmp/wipescript
echo analyze>>/tmp/wipescript
echo purge>>/tmp/wipescript
echo quit>>/tmp/wipescript
echo disk>>/tmp/wipescript
DISKS=$(($DISKS-1))
done
format -f /tmp/wipescript
rm /tmp/wipescript
Note that the script is written for ksh, meaning you should type ‘ksh’ into the command prompt before running the script. To use the script, simply boot off a Solaris CD using the command ‘boot cdrom’. Then run vi and paste in the above script. Save, add execute permissions to your script, enter ksh, and fire off the script. If you want to be able to see the disklist and commands created by the script, simply remove the last line ‘rm /tmp/wipescript’ and the script won’t delete itself when it’s done running.






Comments
Tyler (Dec 21, 2011)
This is a life saver. Thank you!
bodhi (Nov 06, 2012)
good procedure!!
I test it on solaris 10
Chris (Feb 11, 2013)
Would this work on disks that are attached to the server in an array? or only for the drives located within the server?
and also… would this script work on Solaris 10 x86 running on HP, DELL or IBM’s servers?
: )