I just got a micro sd card that I plan on using with the Raspberry Pi.

I used the KDE partition manager to delete the original partition on the card and to write a new 12GiB ext4 partition. After doing this, the card still says that 6% of it, 30.02 MiB, is being used.

Basically, I want to completely wipe of the card of all contents so as to prepare it for a new OS. Would a command like shred or dd do the trick or would that destroy the partition as well?

  • I am biased, but if you want full control of partitions, don't use graphical partitioning, use the good old fdisk. (Unless you can't because of GPT or other technical restrictions.) Aug 15, 2014 at 1:20
  • By the way... does RaspberryPi support loading the kernel from ext4 directly? I remember using FAT for the early boot process (kernel, cmdline, SoC configuration and memory split), and then having the root filesystem on another partition (or NFS if you like) Aug 15, 2014 at 1:25
  • 1
    [Securely wipe disk - archlinux.org] "Wiping a disk is done by writing new data over every single bit." wiki.archlinux.org/index.php/Securely_wipe_disk
    – user115639
    Mar 21, 2015 at 6:00
  • You can check here how to clear data from sd card easeus.com/partition-master/clear-sd-card-usb-flash-drive.html Feb 16 at 7:44

4 Answers 4


Your guessing about dd is right. You can wipe the SD card out by the following command (let's assume, that your SD card is /dev/sdd):

Do not interrupt this command or it could possibly brick the SD card.

$ sudo dd if=/dev/zero of=/dev/sdd bs=8192

Note: If this command does not complete successfully and you have to abort it, then most likely it is recoverable with disk partition recovery programs covered in other posts.

It can take some time depending on size and speed of SD card. If you are convinced, that CIA would like to recover your files, then overwrite the SD card with urandom instead of zero:

$ sudo dd if=/dev/urandom of=/dev/sdd bs=8192

dd command from above examples will erase whole SD card, leaving it without any partitions, even with no partition table. So you will need to recreate partition on SD card. You can do this by any partitioning tool like cfdisk, parted (my recommendation) or gparted.

And one more thing: be extremely careful when calling dd command. A typo in of= argument value can cause disaster.

  • 4
    If you are worried about CIA, you should use /dev/random and do it like 5 to 10 times... not to mention that you should also burn it in the oven, catch on fire and bury it deep in the ocean :P Aug 15, 2014 at 1:17
  • 3
    @CijcoSistems: The suggestion to burn, ignite or bury may work. However, the writing random data (5 to 10 times) method will NOT.
    – david6
    Mar 21, 2015 at 5:54
  • 1
    @david6 Could you explain why writing data many times through overwrite may not work?
    – Denis
    Dec 26, 2015 at 5:11
  • 10
    Modern non-volatile solid-state memory uses wear leveling to stop repeated read/writes overusing any particular section of the memory. (See: searchsolidstatestorage.techtarget.com/definition/wear-leveling) This means that data writes intending to 'overwrite' may actually be saved elsewhere. It also means that the true memory capacity is several 100 times more than stated, to allow for on-going reallocation. As noted in my answer, you must invoke the manufacturer's secure-erase function, to bypass any 'wear leveling' effects.
    – david6
    Dec 26, 2015 at 5:51
  • 2
    Indeed, filling the device (what dd does) puts wear leveling out of the question. Besides, wear leveling would tend to (not guarantee to!) make a file of 1/10 the capacity written 10 times still erase the entire device, instead of the other way around, because it would try to make sure it is not written to the same cells 10 times. And finally, forget about random and urandom and multiple passes. This is not magnetic media where the mechanical aspect can cause the edges of a track not to be fully erased by overwriting it, a single pass of zeroes is enough.
    – Luc VdV
    Apr 12, 2018 at 8:07

What are you trying to achieve?

(A.) Remove all current partitions, to re-use the card:

To erase partitions and/or re-format a (micro) SD card, just use gnome-disk-utility (aka 'Disks').


(B.) Erase any current (or previous) content on the card, so it can NOT be recovered:

To securely erase the card, you need to EITHER physically destroy the card (render into sub-2mm² particles) OR use a utility (from the vendor) to trigger the secure-erase function.

Multiple writes (of random data), or reformatting will NOT necessarily remove the data.


If you just made a new partition, there shouldn't be any actual files on it. That 30MB is probably just the filesystem itself. The partition needs a few different tables and whatnot to actually keep track of files.

You can double check that there really isn't anything on it by looking for hidden files with ls -alph from the command line or be enabling hidden files in the "View" menu of Nautilus.

Depending on exactly how you invoke the commands, it is likely that using shred or dd would indeed overwrite the partition table and/or filesystem.


You can shred the files before removing them:

find /media/user/SD32/ -type f -exec shred -v -f -n0 -z -u   {} \;

shred params mean: Verbose, force deletion of non-writable files, don't write random bytes (speeds up), write zeroes (much faster), truncate and delete the file after writing zeros.

This will get rid of data in a way that they wouldn't be recovered by apps like photorec.

See https://unix.stackexchange.com/questions/27027/how-do-i-recursively-shred-an-entire-directory-tree

  • 1
    Unfortunately this will not work on SD cards. If you overwrite file on them, you are writing to other sectors of the SD. So, to be effective, you should write on entire SD card, as in the answer.
    – luca76
    Mar 4, 2019 at 10:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .