Ubuntu – Format a USB stick completely

formatpartitioningusbusb-drive

How can I delete all data that is on stick?

For example I have this problem:

My stick has two partitions A (3.7 GB) and B (330 MB). How can I merge the two partitions in one and to delete all data that they contain?

I guess they have read-only properties… How can I force deleting them?

I see this in GParted:

Best Answer

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.

Related Question