How to Shred a Partition in Fedora 21?

I recently had an interesting experience with one of my partitions that had an ‘Ext4’ file system on it which used to contain (installed) data of a certain GNU/Linux distribution. I later reformatted it using ‘Ext4’ and re-installed the GRUB boot-loader with Fedora 21‘s configuration (it’s my main OS these days).

After re-formatting it, I mounted it on Fedora 21 and gave an ‘ACL’ permission (ACL’s are a special kind of permissions) so I could have read & write access to it. Then I noticed that, as soon as I entered into the mounted partition through the File Manager, even though I had the read/write access to it, I could not create any file or folder on it. Interestingly though, I could create any file or a folder, through the command-line!.

And, if I had mounted this partition onto a different location where there were no ACL permissions, then as soon as it gets mounted, it applies the previous ACL permissions to this new directory automatically!. This is the first time something like this has happened to me, but then again, who knows how the mind of a computer works 😉 . So after contemplating a little, I decided to see if shredding, or securely wiping the problematic partition, would fix it. And unsurprisingly, it did the trick.

'shred' running on Fedora 21

So if you too ever get to witness such an anomalistic behavior from a newly formatted ‘Ext4’ partition that used to had data on it (I don’t actually think it’ll happen to you though, I just, even back as far as when I was a kid, had this bad habit of bumping onto weird things 😉 ), then try shredding it first.

You do not have to install one manually to do that because almost all GNU/Linux distributions include a tool called ‘shred’, which can be used to wipe partitions (and files) securely, and it is very easy to use. For example, If I wanted to shred the partition ‘/dev/sda3‘, then I will simply use it with the below format:

sudo shred -v /dev/sda3

The ‘sudo’ part is there because it requires administrative privileges, the ‘-v’ argument is for showing a progress (very useful) and depending on your partition layout, the only thing you are going to need to change is the ‘/sda3‘. Assuming that you know how to get a list of currently recognized partitions, please make sure to enter the correct one, otherwise, unlike with a normal ‘format’ procedure, you will end up losing your data, with an extremely narrow chance of ever recovering them!.

By default, ‘shred’ wipes the partition three times and in each instance, it consumes a reasonable amount of time as well. It took about 3-4 minutes to wipe my almost 9 GB ‘Ext4’ partition. So if you have a much bigger one, then it will take a long time to finish. Luckily however, you can manually define how many times ‘shred’ should wipe, which can be set with the ‘-n’ argument.

For instance, if I wanted to wipe the above mentioned /dev/sda3 only once, then I can use it in the below format:

sudo shred -v -n 1 /dev/sda3

(again, make sure to replace /sda3 accordingly).

And lastly, as soon as you shred a partition, the file system also gets deleted, thus you have to re-format it before you can use it. To re-format the ‘/sda3‘ partition (here too remember to replace ‘/sda3‘ accordingly) into ‘Ext4’, I will use the below command:

sudo mkfs -t ext4 /dev/sd3

Once finished creating the file system, you can mount and start using it.

Well, that is pretty much it. You can read its manual if you want to get more information using the below command:

man shred

Good luck and be careful with it!.

2 thoughts on “How to Shred a Partition in Fedora 21?”

  1. You could also dd 1MByte block of zeros over the partition and then do a sync at the end to have a similar (and faster) result!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: