WARNING
I was shocked by how many files photorec could retrieve from my disk, even after wiping.
Whether there is more security in filling the "free space" only 1 time with 0x00 or 38 times with different cabalistic standards is more of an academic discussion. The author of the seminal 1996 paper on shredding wrote himself an epilogue saying that this is obsolete and unecessary for modern hardware. There is no documented case of data being physically replaced zeroes and recovered afterwards.
The true fragile link in this procedure is the filesystem. Some filesystems reserve space for special use, and it is not made available as "free space". But your data may be there. That includes photos, personal plain-text emails, whatever. I have just googled reserved+space+ext4 and learned that 5% of my home
partition was reserved. I guess this is where photorec
found so much of my stuff. Conclusion: the shredding method is not the most important, even the multi-pass method still leaves data in place.
You can try # tune2fs -m 0 /dev/sdn0
before mounting it. (If this will be the root partition after rebooting, make sure run -m 5
or -m 1
after unmounting it).
But still, one way or another, there may be some space left.
The only truly safe way is to wipe the whole partition, create a filesystem again, and then restore your files from a backup.
Fast way (recommended)
Run from a directory on the filesystem you want to wipe:
dd if=/dev/zero of=zero.small.file bs=1024 count=102400
dd if=/dev/zero of=zero.file bs=1024
sync ; sleep 60 ; sync
rm zero.small.file
rm zero.file
Notes: the purpose of the small file is to reduce the time when free space is completely zero; the purpose of sync is to make sure the data is actually written.
This should be good enough for most people.
Slow way (paranoid)
There is no documented case of data being recovered after the above cleaning.
It would be expensive and resource demanding, if possible at all.
Yet, if you have a reason to think that secret agencies would spend a lot of resources to recover your files, this should be enough:
dd if=/dev/urandom of=random.small.file bs=1024 count=102400
dd if=/dev/urandom of=random.file bs=1024
sync ; sleep 60 ; sync
rm random.small.file
rm random.file
It takes much longer time.
Warning. If you have chosen the paranoid way, after this you would still want to do the fast wipe, and that's not paranoia. The presence of purely random data is easy and cheap to detect, and raises the suspicion that it is actually encrypted data. You may die under torture for not revealing the decryption key.
Very slow way (crazy paranoid)
Even the author of the seminal 1996 paper on shredding wrote an epilogue saying that this is obsolete and unecessary for modern hardware.
But if yet you have a lot of free time and you don't mind wasting your disk with a lot of overwritting, there it goes:
dd if=/dev/zero of=zero.small.file bs=1024 count=102400
sync ; sleep 60 ; sync
shred -z zero.small.file
dd if=/dev/zero of=zero.file bs=1024
sync ; sleep 60 ; sync
rm zero.small.file
shred -z zero.file
sync ; sleep 60 ; sync
rm zero.file
Note: this is essentially equivalent to using the secure-delete tool.
Before the edit, this post was a rewrite of David Spillett's. The "cat" command produces an error message, but I can't write comments on other people's posts.
The only safe solution may be to save your files elsewhere, wipe the whole partition, recreate the filesystem, and then restore your files. I've run photorec and was shocked by how much stuff could be retrieved even after 'wiping' free space. A compromise solution is to move the left boundary of your partition by 6% of its size after having wiped the apparently free space.
– user39559 – 2010-09-07T12:12:26.933