Shredding devices (erasing data) using dd command (Ubuntu Linux)

Instead of using the shred command that comes with Ubuntu Linux, I decided to simply use the dd command and shove the output of /dev/zero into the device that I want to shred /dev/zero will basically just keep supplying zero’s untill they are not requested anymore. This procedure will fill the device with zeros or null characters.

Please be carefull using this command as it could completely erase important files (pay attention and double check device names etc)


sudo dd if=/dev/zero of=/dev/the_device_to_be_nuked bs=4k conv=notrunc


22964740+0 records in
22964740+0 records out
94063575040 bytes (94 GB) copied, 2771.83 s, 33.9 MB/s

PLEASE NOTE: If the size of GB copied does not equal the size of the device (as I experienced running the above command) then the zeroing has not been successful. You should get the following message “No space left on device” if the zeroing has been successful. This means that it has filled the entire device. I had to run the command again.

Once finished I want to see if there is any data that has not been zeroed out. This command basically reads the entire device in a linear fashion converting characters to Hex and reports on any characters that are not (^) zero’s 0. By the way this command takes quite a long time, nearly as long as the command above however it is worth doing in order to make sure that the device is really zeroed out.


dd if=/dev/the_device_to_nuke | hexdump -C | grep [^00]

Update: 2011-06-19

The output from the dd command that checks for anything that is not 00 was ” |…………….| * eeffa000″ so I am guessing that everything was not zeroed out. I may be way off the mark here but I wrote a script to replace everything that is not a zero with a zero. The script is as follows (warning this is just an experiment and I am learning, please do not take this as gospel… if it does not work for you I would be glad to hear any suggestions)

data=`dd if=/dev/drive_to_be_nuked | hexdump -C | grep [^00]`
echo "********"
echo $data
echo "********"
echo "foonum is $foonum"
for ((i=0;i<$foonum;i++)); do
    `dd if=/dev/drive_to_be_nuked | sed 's/$content/00/g' | dd of=/dev/drive_to_be_nuked`

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s