Linux Free Space Wiping: 4 Steps to Overwrite Deleted Data

Quick Linux Tip #104:

Question: I deleted sensitive files but worry forensics could recover them. How do I wipe free space?

Try: sudo dd if=/dev/zero of=/wipe-file bs=1M status=progress; sudo rm /wipe-file

Info: dd fills remaining disk free space with zeros, overwriting blocks of previously deleted files before rm releases the space. "No space left" is the expected, successful completion indicator.

Examples:

  • $ sudo dd if=/dev/urandom of=/wipe-file bs=1M status=progress  # Overwrite with random data (stronger)
  • $ sudo cat /dev/zero > /wipe-file  # Simpler alternative stream method
  • $ sudo sfill -f /mountpoint  # Dedicated secure free-space wiper utility

Note: SSDs use wear-leveling and TRIM, making dd ineffective; use blkdiscard or ATA Secure Erase instead. Ext4 journals may also retain file fragments.




LinuxTeck.com
linuxteck:~$ sudo dd if=/dev/zero of=/wipe-file bs=1M status=progress; sudo rm /wipe-file
dd: writing to '/wipe-file': No space left on device
345678901234 bytes (346 GB, 322 GiB) copied, 1234 s, 280 MB/s
329567+0 records in
329566+1 records out
345678901234 bytes (346 GB, 322 GiB) copied, 1234.56 s, 280 MB/s

linuxteck:~$ df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       500G  499G  1.0G 100% /

linuxteck:~$ sudo rm /wipe-file

linuxteck:~$ df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       500G  154G  346G  31% /
linuxteck:~$

PREVIOUS ARTICLE Quick Linux Tip #103: Linux CPU Usage Monitoring: Find High CPU Processes Fast NEXT ARTICLE Quick Linux Tip #105: Bash History Monitoring: 5 Ways to Audit Linux Commands
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.