Securely erasing files, by filling your disk
Posted by Steve on Sat 2 Jan 2010 at 14:34
With modern filesystems securely deleting files isn't always easy, but one approach which stands a good chance of working is to write random patterns over all unused areas of a disk - thus erasing the contents of files you've previously deleted.
The Debian secure-delete package contains a number of tools, but the one that I get the most use out of and the one which I'm most confident of is sfill.
The sfill command allows you to write data to all unused areas of a mounted partition. This should ensure that the contents of any deleted files have been overwritten, thereby giving you confidence that their contents are well and truely gone.
To get started install the package:
gold:~# aptitude update gold:~# aptitude install secure-delete
Once installed you can overwrite the unused content of any mounted partition like so:
gold:~# sfill /home
Note: This assumed /home is mounted as a partition. In my case it is, as we can see from this output:
gold:~# mount | grep /dev /dev/mapper/gold--vol-root on / type ext3 (rw,noatime,nodiratime,errors=remount-ro) udev on /dev type tmpfs (rw,mode=0755) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620) /dev/md1 on /boot type ext3 (rw) /dev/mapper/gold--vol-home on /home type ext3 (rw) /dev/mapper/gold--vol-music on /home/music type ext3 (ro) /dev/mapper/gold--vol-kvm on /kvm type ext3 (rw)
When you run sfill the program eats up all free space by creating a huge file. Then the contents of this file are written in a number of steps - ensuring that all areas of the disk which were previously free have had their contents erased. Once completed the huge file is removed, meaning you have free disk space again.
For more details please consult the files installed beneath /usr/share/doc/secure-delete, or read the manpage via "man sfill".