Operating System - HP-UX
1752794 Members
6271 Online
108789 Solutions
New Discussion юеВ

Re: using dd command to zero out disks

 
SOLVED
Go to solution
Mark Harshman_1
Regular Advisor

using dd command to zero out disks

i want to zero out a number of disks on a device i am de-commissioning. FOr audit reasons..we are suppose to "zero" out the data. I was thinking of using the "dd" command...but am not sure of the a good syntax? i could use some assistance here...thanks in advance.
Never underestimate the power of stupid people in large groups
6 REPLIES 6
Donny Jekels
Respected Contributor
Solution

Re: using dd command to zero out disks

dd if=/dev/null of=/dev/dsk/c0t0d0
"Vision, is the art of seeing the invisible"
Hein van den Heuvel
Honored Contributor

Re: using dd command to zero out disks


/dev/null will not do.
It returns 'eof' rightaway and your disk blocks will nto be overwritten.

Use

if=/dev/zero bs=1024k


[use search in the forum for more detailed discussion on device scrubbing, /dev/random, torches (the only real way to destroy data :-) and so on.]

hth,
Hein.

Mark Harshman_1
Regular Advisor

Re: using dd command to zero out disks

thanks for the answers. is there a way to sting several disks all togther? can i create an input file as my of=? i have over 100 disks i need to wipe.....

thanks
Never underestimate the power of stupid people in large groups
Michael Schulte zur Sur
Honored Contributor

Re: using dd command to zero out disks

Hi,

you can write the disk devices in a file and let a loop run over it.

dskfile:
/dev/dsk/c0t0d0
/dev/dsk/c0t1d0
...

while read DISK
do
dd if=/dev/zero of=${DISK}
done < dskfile

Michael
Hein van den Heuvel
Honored Contributor

Re: using dd command to zero out disks

With a hunderd disk, you want to write more than one at a time. Say 10 or so. So just toss the commands in script with & at the end of the line and/or grouped
(dd... ; dd... ;dd...)&
Or just paste a bunch in a window.

I'll include and attach here a perl script that is pretty close to your needs and which can run a selectable number of streams in parallel taking note of the stat time and results. For now it READS, to allow testing.
Once satisfied replace if with of and null with zero. No I did not write this just for you :-). I had something very similar handy.
Input param is a list of (raw) device names

hth,
Hein.


#!/bin/perl
$file = shift (@ARGV);
$max_streams = shift (@ARGV);

die "Must provide file" unless $file;
$max = ($max_streams)? int ($max_streams) : 10;

open (FILE, $file) || die "Error open $file";
while () {
if ($par++ >= $max) {
$pid = wait();
$par--;
$s = 1;
$s++ while (($stream[$s] != $pid) && ($s <= $max) );
die "Lost child process ?" if ($s > $max);
} else {
$s = $par;
}
$pid = fork();
if ($pid) {
$stream[$s] = $pid;
} else {
($sec,$min,$hour) = localtime(time);
$date = sprintf("%02d:%02d:%02d ",$hour,$min,$sec);
open (LOG, ">>${file}_${s}.log" );
print LOG $date, $_;
close(LOG);
chop ($_);
exec ("dd of=/dev/null bs=128k count=100 if=$_ 2>> ${file}_${s}.log ")
}
}
close (FILE);

wait() while (--$par > 0);



RolandH
Honored Contributor

Re: using dd command to zero out disks

Have you ever heard about the command "mediainit". This is the best way to erase data on you disk.

Regards
Roland
Sometimes you lose and sometimes the others win