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:
DISKS=`prtconf|grep sd,|grep -v "driver not attached"|wc -l`
while [ $DISKS -ge 0 ]
format -f /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.