Category filter
Script to erase free space on Mac
Secure Erase Free Space in Disk Utility was an important feature on Mac. It added a layer of security and privacy with respect to file deletion. However, to prevent the users from recovering the deleted files, they could overwrite the free space on the drive. This feature is no longer available on modern versions of macOS.
However, there is a suitable alternative. By executing custom scripts on Hexnode, users can erase free space on their Mac drives.
Script to erase free space on Mac using diskutil
1 |
diskutil secureErase freespace 4 /Volumes/Macintosh\ HD |
- The command freespace indicates that only free space on the drive is being erased. Failure to include this keyword will lead to the entire drive being erased.
- The number “4” indicates the wipe level performed on the drive’s free space. Wipe levels range from 0-4, and the above command can contain any of the options from the following list:
- 0 – Single-pass zero-fill erase.
- 1 – Single-pass random-fill erase.
- 2 – US DoD 7-pass secure erase.
- 3 – Gutmann algorithm 35-pass secure erase.
- 4 – US DoE algorithm 3-pass secure erase.
- The process takes longer as the number of passes increase.
- Make sure to replace the term “Macintosh\ HD” with the volume name you want to wipe the free space on.
- If the volume name contains a space, type a backslash in front of the space, just like the term “Macintosh\ HD” in the command above. Ensure to include the term “/Volumes/” before the name of the volume.
Need more help?