How to wipe a SD card in Ubuntu

Note: Unlike hard disks, SD cards cannot actually be securely wiped such that data is fully unrecoverable. The only way to do that would be using an erase functionality of its firmware, if it has one. Else physical destruction of the SD card!🙂

SD cards are commonly used in cameras and smartphones to store photos and other personal content. Even after these files are deleted they can be easily recovered from the SD card. So, it may be essential to completely erase the SD card such that data recovery is very difficult (but not impossible).

  • Find out the partition the SD card is mounted as. For example, a SD card I use in my camera is formatted as a FAT32 partition. I plug it into my Ubuntu computer and it is mounted automatically. I can find out its partition by either of these commands:
$ sudo fdisk -l
$ sudo blkid
  • Unmount the SD card. (Note: Do not eject it.) If you do not unmount it you might get this error while wiping it: failed to open for writing: Read-only file system

  • Use the shred program to erase the SD card partition. For example, I find that the FAT32 partition on my SD card is at /dev/sdb1. I wipe the SD card partition using:

$ sudo shred -v /dev/sdb1

By default, shred will overwrite the entire partition 3 times, making it really difficult to recover any old content from it.

Tried with: CoreUtils 8.23 and Ubuntu 15.10

3 thoughts on “How to wipe a SD card in Ubuntu”

  1. Overwriting data (as you decribe) on an SD card 3 times (eg. using Shred) will NOT securely erase the data. The technique you describe is useful ONLY for magnetic media.


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