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?
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 ofzero
:$ 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 likecfdisk
,parted
(my recommendation) orgparted
.And one more thing: be extremely careful when calling
dd
command. A typo inof=
argument value can cause disaster.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').
OR
(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
ordd
would indeed overwrite the partition table and/or filesystem.You can shred the files before removing them:
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