How to erase / delete / blank or wipe a disk
I’m sure there are other methods, but the one I prefer to use is the one that uses dd
to copy zeros, or random data in the file system I want to wipe.
So, run this command if you want to erase your… let’s say microSD card.
Suppose it is mounted on /dev/sdd1
:
dd if=/dev/urandom of=/dev/sdd1
If you do not want to wait too much, you can fill the partition with zeros instead of random data:
dd if=/dev/zero of=/dev/sdd1
Both are secure, but IMHO the first one may be better, but of course I can be wrong.
Once again, be sure to double check, or better triple check on which partition you are going to apply this, you will not be warned by Linux, and the result can not be undone.
A good practice could be to first make an image of the disk and then wipe it. If you want to proceed that way, do this.
dd if=/dev/[partition-to-wipe] of=/tmp/backup.img
Then wipe it
dd if=/dev/urandom of=/dev/[partition-to-wipe]
You can then recover the data by doing
dd if=/tmp/backup.img of=/dev/[partition-to-wipe]
Info taken from this site.