So, you want those embarrassing photos and videos of you while you were drunk to never see the light of day? Deleting them from your trash bin isn’t good enough.
When you delete a file on macOS (or any OS), the data isn’t really erased – only the index or pointer to that file is removed. The actual data remains on the disk until it’s overwritten by something else.
So tools like photo recovery apps, forensic tools, or law enforcement utilities can scan unallocated space and rebuild deleted files – unless that space has been overwritten.
Here’s how to wipe your free space, for good.
Command 1 – Create a large junk file to take up free space (Note: Leave enough space for MacOS to function properly. If you have 210gb free in your storage – create a 195gb file)
dd if=/dev/urandom of="$HOME/largejunkfile" bs=1m count=195000 // creates 195gb junk file
Command 2 – Wipe file
rm "$HOME/largejunkfile" // erases that same junk file
If you’d like to automate this process, you can simply save the code below as wipefreespace.sh on your mac, open terminal (or iterm2) and run chmod +x wipefreespace.sh to make it executable, and then while in terminal run ./wipefreespace.sh
#!/bin/bash
count=1
echo “Script started at: $(date ‘+%Y-%m-%d %H:%M:%S’)”
while true; do
echo “=== Run #$count ===”
echo “Creating file (120gb)…”
dd if=/dev/urandom of=”$HOME/largejunkfile” bs=1m count=120000
echo “Junk file created”
sleep 10
echo “Deleting file…”
rm -f “$HOME/largejunkfile”
echo “Cycle #$count complete.”
((count++))
done
This will result in the following output:

Even though SSDs do wear leveling (randomizing physical writes to prolong lifespan), every time you do a pass with dd:
- You’re more likely to hit different sectors with each write.
- Over multiple passes, you touch a very high percentage of unallocated space.
- TRIM (enabled on macOS) also helps by marking deleted blocks as ready to be cleaned.
Together, these factors make data recovery from deleted files virtually impossible.
Leave a comment