script to wipe drives (2 pass)

I need a script I can run from a linux livecd which will perform the following on all drives:


1st pass:  dd if=/dev/urandom of=/dev/sda, sdb, sdc
2nd pass:  dd if=/dev/zero of=/dev/sda, sdb, sdc

dd if=/dev/sda | hexdump -C | grep [^00] (For each drive after both passes have completed for each drive.)

I would also like to output the info to a file so that I can keep a record.

As an extra if I could output in addition....the drive info..ie serial number etc to the file would be even better!
LVL 1
kaparaAsked:
Who is Participating?
 
wesly_chenCommented:
yes. or
chmod +x <full path to myscript.sh>
Then execute with
<full path to myscript.sh>
or
cd <directory of myscript.sh>
./myscript.sh
0
 
wesly_chenCommented:
fdisk -l /dev/sda  > <path-to-log-file>
dd if=/dev/sda | hexdump -C | grep [^00]  | tee -a <path-to-logfile>
0
 
kaparaAuthor Commented:
ok.  but I would like all of this in a single script format for all the drives...etc

Thanks
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
kaparaAuthor Commented:
It looks like this is available....

hdparm -I /dev/sda and I would like it output also.  do I add the & to the end of each command?  Is that before the output or after...?
0
 
wesly_chenCommented:
#!/bin/sh

LOG_DIR=/path-to-log-dir

for DISK in sda sdb sdc
do
    fdisk -lu $DISK > $LOG_DIR/$DISK.log     # Get the drive info
    dd if=/dev/urandom of=/dev/$DISK | tee -a $LOG_DIR/$DISK.log 2>&1  # log a file & STDOUT
    dd if=/dev/zero of=/dev/$DISK | tee -a $LOG_DIR/$DISK.log 2>&1
    dd if=/dev/$DISK | hexdump -C | grep [^00]  | tee -a $LOG_DIR/$DISK.log 2>&1
done
--------------
It will have 3 log files.
0
 
wesly_chenCommented:
ok
-----------
#!/bin/sh

LOG_DIR=/path-to-log-dir

for DISK in sda sdb sdc
do
    hdparm -I /dev/$DISK > $LOG_DIR/$DISK.log     # Get the drive info
    fdisk -lu /dev/$DISK >> $LOG_DIR/$DISK.log
    dd if=/dev/urandom of=/dev/$DISK | tee -a $LOG_DIR/$DISK.log 2>&1  # log a file & STDOUT
    dd if=/dev/zero of=/dev/$DISK | tee -a $LOG_DIR/$DISK.log 2>&1
    dd if=/dev/$DISK | hexdump -C | grep [^00]  | tee -a $LOG_DIR/$DISK.log 2>&1
done

0
 
kaparaAuthor Commented:
thanks.  So just to clarify...

I need to alter the path for LOG_DIR=/ to a folder of my choice like a usb drive..etc?

If I have more than 3 drives I just need to add sdd, sde..etc to the for DISK in and the script will take care of the rest?

Thanks
0
 
wesly_chenCommented:
yes. you'r right.
0
 
kaparaAuthor Commented:
ok.  now for the last stupid question..what file extension do I use for the file?  I use windows so I am unfamiliar with file extensions for scripts in linux?

thanks.
0
 
wesly_chenCommented:
.txt or .log
0
 
kaparaAuthor Commented:
no.  I mean the script so that I can just doubleclick on the file to execute the script...
0
 
wesly_chenCommented:
.sh (it's a shell script)
Also do
chmod +x <script>

0
 
kaparaAuthor Commented:
so from shell I need to browse to the location of the file and type chmod +x myscript.sh?
0
 
haroldpgaCommented:
File name or file extension has no special meaning in Linux.  It just has to be executable (chmod +x).  then either click on it from the GUI, or type it's name at the command line.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.