-   Linux - Hardware (
-   -   Really erase USB drive (

allelopath 06-25-2007 09:16 AM

Really erase USB drive
I have borrowed (and am about to return) a 512mb Cigar Pro USB drive. I had deleted all the files. Now, how do I really clean the drive (e.g. leave no possibility of recovering files)?

It is formatted in vfat. I can use Linux or, if i must, Windows.

macemoneta 06-25-2007 10:03 AM

Just write zeros to fill the drive. For example:

dd if=/dev/zero of=/dev/sda

allelopath 06-25-2007 10:10 AM

# dd if=/dev/zero of=/media:sda1
dd: writing to `/media:sda1': No space left on device
8047361+0 records in
8047360+0 records out
4120248320 bytes (4.1 GB) copied, 123.362 s, 33.4 MB/s

Did this work?

macemoneta 06-25-2007 10:24 AM

You wrote a lot of zeros (4.1GB), but to the wrong place (a file called "media:sda1" in your root directory).

Erase the file you created, and use:

umount /dev/sda1
dd if=/dev/zero of=/dev/sda1

You can also use:

umount /dev/sda1
dd if=/dev/zero of=/dev/sda

The second case will wipe the boot sectors and partition table as well.

tredegar 06-25-2007 10:47 AM

I just tried it, it didn't work for me (the files are still there).
So I tried this:

# dd if=/dev/zero of=/dev/sda1
dd: writing to `/dev/sda1': No space left on device
517048+0 records in
517047+0 records out
264728064 bytes (265 MB) copied, 26.0638 seconds, 10.2 MB/s
But note that it took longer than 26 seconds for the memory stick light to stop flashing.
Then I unplugged it, and plugged it back in again.
It didn't auto mount.
So I tried this:

# fdisk /dev/sda

Command (m for help): p

Disk /dev/sda: 264 MB, 264896512 bytes
9 heads, 57 sectors/track, 1008 cylinders
Units = cylinders of 513 * 512 = 262656 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              1        1008      258523+  83  Linux

It appears to have one linux partition but no filesystem.
So I tried this:

# dd if=/dev/zero of=/dev/sda
The light on the stick flashed for 5mins, but never finished. It's only 256MB. As I couldn't <CTRL><C> the dd command, I just unplugged it and plugged it in again.
Better this time:

# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

This looks like it is really zeroed out.
Time to fdisk it, and create a new filesystem on it.
Thanks, that was fun.

Edit macemoneta beat me to it!

allelopath 06-26-2007 11:27 AM

thanks to both of you for the help

All times are GMT -5. The time now is 10:35 AM.