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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Server Hardware

From novice to tech pro — start learning today.