Re: DD vs normal writing question



gordon@xxxxxxxxxx (Gordon Henderson) writes:

In article <jg34i4-ti9.ln1@xxxxxxxxxxxxxxxxxx>,
Martin Gregorie <martin@xxxxxxxxxxxxxxxxxxx> wrote:
I recently found a couple of scripts that wipe free space on partitions
and swap space. The guts of both is the line:

dd if=/dev/urandom of=_freespace_

which runs until the partition fills up. Then the script executes fsync
twice and deletes _freespace_. The swap space wiper disables swapping,
wipes the partition and then turns swapping back on.

Only problem is that its pretty slow, so I wrote a bit of C that does
the same thing, but with the loop:

errno=0;
while (errno == 0)
{
rnd = rand();
fwrite(&rnd, 1, sizeof(rnd), w);
}

This runs about 8x faster with its output redirected to disk. I've tried
it as a single line replacement for dd in an otherwise unchanged copy of
the free space wiping script with apparently good results.

The question is what, if anything, does dd do that my code doesn't?
Should my code clear the swap partition or is there something in swap
partition format that means only dd can write to it?

dd is reading from /dev/urandom - that's pretty random, not quite as random
as /dev/random, but that will be slower still.

That would be completely and utterly silly. /dev/random blocks. It would
take you maybe a year, maybe 100 years to wipe your disk if you used
/dev/random.
(Unless dd bails out on block and simply uses zeros to pad the block)


As there are those who say that data can be recovered, even after
several passes with this, if all you're doing is something "quick
and dirty" just use /dev/zero rather than /dev/random.

Not sure who says that anymore.



And have a look at the manual page for "shred" ..

Gordon
.



Relevant Pages

  • Re: DD vs normal writing question
    ... Then the script executes fsync ... The swap space wiper disables swapping, ... wipes the partition and then turns swapping back on. ... This runs about 8x faster with its output redirected to disk. ...
    (uk.comp.os.linux)
  • Re: Newbie partitioning question
    ... >10.2gb drive for use as an NFS server. ... Swap space on Linux depends on how much Virtual Memory you ... minus how much RAM you actually have. ... Your /boot partition is twice as big as you'll likely need too, ...
    (comp.os.linux.misc)
  • Re: FreeBSD 4.x EoL
    ... upgrade ad lib; just reboot when done. ... you don't need *a* partitions to boot such as ad0s1a. ... You simply need to spare a FreeBSD partition. ... If you have lots of physical memory and swap space, ...
    (freebsd-stable)
  • Re: Disklabe oddity
    ... > partition was created by FreeBSD on its own. ... > back on the disk. ... It's not a good idea to add swap space to a file system. ... and changing the length and offset of partition c (offset ...
    (freebsd-questions)
  • Re: Swap space
    ... >>The general rule is to have at least twice your RAM as swap space. ... It is easy to change the swap partition size, ... For some reason, the RedHat installer has ... or whole disks, into a "virtual disk"; ...
    (comp.os.linux.setup)