Shredding Files | Disk In Linux

Sometimes it comes as a requirement to shred and delete a file contains sensitive data to minimize the capability to restore this file back from the hard disk after it's deletion.


# shred -fuzv -n 30  /home/oracle/aa.txt


-f ........Change permissions to allow writing.
-u ........remove the file after shredding.
-z ........final overwrite with zeros to hide shredding.
-v ........verbose mode.
-n 30 ...Shred file aa.txt 30 time (default is 25 time).

Note: Shredding will be effective-less if the Filesystem is (RIESER, EXT3/4, RAID system and Compressed filesystems) because of journaling option check /etc/fstab for "data=" options, if "data=journal" which journals file data in addition to metadata then the shredding effeciveness is low, if "data=ordered" which is the default or "data=writeback" then shredding will work fine with you.

Last but not least, shredding your data in this way file by file is not a guaranteed way,
the guaranteed way I think is to shred the whole disk or at least the whole partition.

e.g. Shredding /dev/sda3 partition
# shred -fzv -n 30  /dev/sda3

In case you will shred the whole disk replace /dev/sda3 with /dev/sda and so on.

As an extra layer of wiping the hard disk/partition you can use dd command :
dd command will help wiping your disk by overwrite the whole disk with zeros, it will perform faster than shred command:

# dd  if=/dev/zero  of=/dev/sda  bs=1048576

In case you want to wipe a partition or file, replace /dev/sda with the partition you want to wipe e.g. /dev/sda3 or with the file you want to wipe e.g. /home/oracle/aa.txt

Use the above commands with caution.


No comments:

Post a Comment