Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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.) – CijcoSistems Aug 15 '14 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) – CijcoSistems Aug 15 '14 at 1:25
[Securely wipe disk -] "Wiping a disk is done by writing new data over every single bit." – Aurigae Mar 21 '15 at 6:00

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.

share|improve this answer
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 – CijcoSistems Aug 15 '14 at 1:17
@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 '15 at 5:54
@david6 Could you explain why writing data many times through overwrite may not work? – Qwertylicious Dec 26 '15 at 5:11
Modern non-volatile solid-state memory uses wear leveling to stop repeated read/writes overusing any particular section of the memory. (See: 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 '15 at 5:51

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.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.