Mac Erase Free Space

Here's the video tutorial that explains how to securely wipe the free space on your Mac using Disk Drill.Download for free: https://www.cleverfiles.com/disk.

MacMac Erase Free SpaceSpace
  1. Add, delete or erase APFS volumes in Disk Utility on Mac. Apple File System (APFS) allocates disk space on demand. When a single APFS container (partition) has multiple volumes, the container’s free space is shared and can be allocated to any of the individual volumes as needed.
  2. Specifically, Disk Drill offers these free tools that can help clean your Mac: Duplicate finder to identify unnecessary files; Clean up which creates a data map so you can analyze your disk usage; Erase free space and data shredder to securely delete extra data.
  3. 'When you delete files by emptying the Trash, Mac OS X deletes the information used to access the files but doesn’t actually delete the files. Although the disk space used by deleted files is marked as free space, deleted files remain intact until new data is written over them. As a result, deleted files can be recovered. You can use Disk.
  4. If you're selling an old Mac, a spare hard drive, or you're just quite paranoid about your deleted data, you're either familiar with—or should be familiar with—the Erase Free Space button on the Erase tab in Disk Utility (found in your Applications - Utilities folder). When you click this button, you're presented with three options.

The Optimized Storage features of your Mac help you save storage space by storing your content in iCloud and making it available on demand:

  • When storage space is needed, files, photos, movies, email attachments, and other files that you seldom use are stored in iCloud automatically.
  • Each file stays right where you last saved it, and downloads when you open it.
  • Files that you’ve used recently remain on your Mac, along with optimized versions of your photos.

If you haven't yet upgraded to macOS Sierra or later, learn about other ways to free up storage space.

Find out how much storage is available on your Mac

Choose Apple menu  > About This Mac, then click Storage. Each segment of the bar is an estimate of the storage space used by a category of files. Move your pointer over each segment for more detail.

Click the Manage button to open the Storage Management window, pictured below.

Manage storage on your Mac

The Storage Management window offers recommendations for optimizing your storage. If some recommendations are already turned on, you will see fewer recommendations.

Store in iCloud

Mac Erase Free Space

Click the Store in iCloud button, then choose from these options:

  • Desktop and Documents. Store all files from these two locations in iCloud Drive. When storage space is needed, only the files you recently opened are kept on your Mac, so that you can easily work offline. Files stored only in iCloud show a download icon , which you can double-click to download the original file. Learn more about this feature.
  • Photos. Store all original, full-resolution photos and videos in iCloud Photos. When storage space is needed, only space-saving (optimized) versions of photos are kept on your Mac. To download the original photo or video, just open it.
  • Messages. Store all messages and attachments in iCloud. When storage space is needed, only the messages and attachments you recently opened are kept on your Mac. Learn more about Messages in iCloud.

Storing files in iCloud uses the storage space in your iCloud storage plan. If you reach or exceed your iCloud storage limit, you can either buy more iCloud storage or make more iCloud storage available. iCloud storage starts at 50GB for $0.99 (USD) a month, and you can purchase additional storage directly from your Apple device. Learn more about prices in your region.

Optimize Storage

Click the Optimize button to save space by automatically removing watched movies and TV shows. When storage space is needed, movies or TV shows that you purchased from Apple and already watched are removed from your Mac. Click the download icon next to a movie or TV show to download it again.

Your Mac will also save space by keeping only recent email attachments on this Mac when storage space is needed. You can manually download any attachments at any time by opening the email or attachment, or saving the attachment to your Mac.

Optimizing storage for movies, TV shows, and email attachments doesn't require iCloud storage space.

Empty Trash Automatically

Empty Trash Automatically permanently deletes files that have been in the Trash for more than 30 days.

Reduce Clutter

Reduce Clutter helps you identify large files and files you might no longer need. Click the Review Files button, then choose any of the file categories in the sidebar, such as Applications, Documents, Music Creation, or Trash.

You can delete the files in some categories directly from this window. Other categories show the total storage space used by the files in each app. You can then open the app and decide whether to delete files from within it.

Learn how to redownload apps, music, movies, TV shows, and books.


Where to find the settings for each feature

The button for each recommendation in the Storage Management window affects one or more settings in other apps. You can also control those settings directly within each app.

  • If you're using macOS Catalina or later, choose Apple menu  > System Preferences, click Apple ID, then select iCloud in the sidebar: Store in iCloud turns on the Optimize Mac Storage setting on the right. To turn off iCloud Drive entirely, deselect iCloud Drive.
  • If you're using macOS Mojave or earlier, choose Apple menu > System Preferences, click iCloud, then click Options next to iCloud Drive. Store in iCloud turns on the Desktop & Documents Folders and Optimize Mac Storage settings.
  • In Photos, choose Photos > Preferences, then click iCloud. Store in iCloud selects iCloud Photos and Optimize Mac Storage.
  • In Messages, choose Messages > Preferences, then click iMessage. Store in iCloud selects Enable Messages in iCloud.
  • If you're using macOS Catalina or later, open the Apple TV app, choose TV > Preferences from the menu bar, then click Files. Optimize Storage selects “Automatically delete watched movies and TV shows.”
  • In you're using macOS Mojave or earlier, open iTunes, choose iTunes > Preferences from the menu bar, then click Advanced. Optimize Storage selects “Automatically delete watched movies and TV shows.”
  • In Mail, choose Mail > Preferences from the menu bar, then click Accounts. In the Account Information section on the right, Optimize Storage sets the Download Attachments menu to either Recent or None.

Erase Free Space On Mac

Empty Trash Automatically: From the Finder, choose Finder > Preferences, then click Advanced. Empty Trash Automatically selects “Remove items from the Trash after 30 days.”

Other ways that macOS helps automatically save space

With macOS Sierra or later, your Mac automatically takes these additional steps to save storage space:

  • Detects duplicate downloads in Safari, keeping only the most recent version of the download
  • Reminds you to delete used app installers
  • Removes old fonts, languages, and dictionaries that aren't being used
  • Clears caches, logs, and other unnecessary data when storage space is needed

How to free up storage space manually

Even without using the Optimized Storage features described in this article, you can take other steps to make more storage space available:

  • Music, movies, and other media can use a lot of storage space. Learn how to delete music, movies, and TV shows from your device.
  • Delete other files that you no longer need by moving them to the Trash, then emptying the Trash. The Downloads folder is good place to look for files that you might no longer need.
  • Move files to an external storage device.
  • Compress files.
  • Delete unneeded email: In the Mail app, choose Mailbox > Erase Junk Mail. If you no longer need the email in your Trash mailbox, choose Mailbox > Erase Deleted Items.

Learn more

  • The Storage pane of About This Mac is the best way to determine the amount of storage space available on your Mac. Disk Utility and other apps might show storage categories such as Not Mounted, VM, Recovery, Other Volumes, Other, Free, or Purgeable. Don't rely on these categories to understand how to free up storage space or how much storage space is available for your data.
  • When you duplicate a file on an APFS-formatted volume, that file doesn't use additional storage space on the volume. Deleting a duplicate file frees up only the space required by any data you might have added to the duplicate. If you no longer need any copies of the file, you can recover all of the storage space by deleting both the duplicate and the original file.
  • If you're using a pro app and Optimize Mac Storage, learn how to make sure that your projects are always on your Mac and able to access their files.

Erase free disk space from the command line | 18 comments | Create New Account
Click here to return to the 'Erase free disk space from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.

Wouldn't you be much better off using /dev/random instead?

'Wouldn't you be much better off using /dev/random instead?'
No, that would actually be terrible. First of all, you shouldn't fill the boot disk of a running machine because it will cause problems, so the hint is a bad idea anyway. However, if you are anxious to do bad stuff like fill your root drive, then you definitely shouldn't do it from /dev/random, because /dev/random requires vastly more CPU power to generate data for than /dev/zero does. If would take few hours to fill a drive from /dev/zero, but it could take a few weeks to fill it from /dev/random.
Also, I don't know if Mac OS X does this, but Linux will sometimes block on reads from /dev/random while it waits for more genuinely random input from the outside world (say mouse movements, or network traffic rates or some such). (This used to cause 'depleted entropy pool' problems for ssl and ssh on linux. Sorry for the 'in my day' storry, but I remember when I used to use linux to generate SSH keys and I would have to wiggle my mouse around a lot in order to generate ssh keys in a reasonable amount of time. :-)

Secure Erase Free Space

Yes, I remember when I setup a FreeBSD server ~5 years ago, I got the standard generating key message you would normally get, then something odd telling me to 'wiggle my mouse or hit keys on the keyboard'. You feel like an idiot standing at a console in the server room, 'wiggling the mouse', and banging on the keyboard, with other admins* walking around asking you if you have gone insane.
Its funny now, not so much back then.
* They were Windows admins, I was the *nix admin at that time.

Firstly one does not run this as root. run this as a normal user. The system reserves some space for the root user, and this way you will not run out of disk space for critical system. (At least I know this to be true for reiser, ext3 and ext2 filesystems on Linux.
Secondly, anyone paranoid enough to want to do it should never use /dev/zero (Not even when doing it multiple times) since you can still get the data using forensic techniques. Even if you do this multiple times... some drives with advances caching may not even do the successive writes on a very low level (even with only a small sized disk-cache).
Lastly, yes, /dev/random is more cpu intensive... as for a lot more? No it does not:
I did:
(cat /dev/zero > zero &) ; (cat /dev/random > random &) ; sleep 20 ; killall cat ; ls -l zero random
And it showed:
joseki:~ marius$ ls -la random zero
-rw-r--r-- 1 marius staff 222302208 Apr 24 12:27 random
-rw-r--r-- 1 marius staff 666898432 Apr 24 12:27 zero
So, yes, I would suggest using random... a good system-wide anti-entropic engine should be pretty efficient.

I would think that this could be equally useful using /dev/random or /dev/zero. ramdom would help obscure old data from disk searches. zero would allow for the raw partition to be more easily compressed.

As UNIX SysAdmin, I don't think this makes any sense at all.
First, filling up your drive is a very bad idea, as Rob points out. Many services will stop functioning or exhibit odd behavior.
Secondly, I'm not quite sure what you're trying to do here? Make sure any unused sectors are zero'd out? I'm guessing you're using secure delete already anyways. This just doesn't make any sense. Do you work for the NSA? Didn't think so. You don't need to 'zero' your unused disk space.
P.S. - This '35 pass delete' stuff is B.S. The only way to recover data from a HD after 3 passes is with a team of people and highly specialized hardware. Sorry everybody, but my guess is that your data is not that important. Save your hard drive life and stop using 35-pass deletes. If you have sensitive data, encrypt it using a strong passphrase and you'll be much better off.
---
Nem W. Schlecht
http://geekmuse.net/

Not only is this not a good idea, it doesn't entirely work as advertised. Realize that changes to files are often not written to disk immediately. Instead, they are held in memory (cached) and queued for writing to disk. So, when your cat command dies due to insufficient space, it's likely that some of the writes have not completed. When the file is removed, those writes can be deleted from the queue of pending writes. Consequently, some of the disk blocks will never be overwritten.
Also, many filesystems limit the amount of disk that a regular user (i.e. not root) can write to. For instance, UFS reserves 10% of a filesystem (by default, can be set with tunefs minfree option) for root. This would mean that the above command would fail after writing to 90% of the disk, not 100% (leaving 10% unwritten). Unfortunately, I'm not familiar with the implementation of HFS+, so I can't comment on whether it has similar behavior.

'Do you work for the NSA? Didn't think so. You don't need to 'zero' your unused disk space.'
I'm guessing you know the things I'm about to say already and just didn't think about them when you wrote this, but using secure erase means that Finder is configured to do secure erase when it empties the trash. It has no impact on, say Quicken's temporary files in /tmp . File in /tmp are also outside of the user's FileVault (assuming this person is using FileVault). There have also been multiple cases where people have suffered identity theft after their financial information was lifted from old drives despite the fact that it had already been (insecurely) deleted on the old drive.
With that said, FileVault, secure erase, and encrypted VM will cover the vast majority of people's needs. In fact, simple lack of familiarity with HFS+ on the part of thieves will cover a lot. Nonetheless, there are legitimate cases for a non-FBI-employee to want to erase the blank space on a root drive.

some of us do. given, this isn't the best way to go about it, it would help prevent some data recovery.
if you want to use this method, i would recommend booting into single use mode first. (cmd-opt-s)
diskutil is the correct way to do this.
------
Disk Utility Tool
Usage: diskutil secureErase [freespace] level
MountPoint|DiskIdentifier|DeviceNode
Securely erases a disk or its freespace.
Level should be one of the following:
1 - Single-pass randomly erase the disk.
2 - US DoD 7-pass secure erase.
3 - Gutmann algorithm 35-pass secure erase.
Ownership of the affected disk is required.
Example: diskutil secureErase 2 /dev/disk2
Note: Level 2 or level 3 secure erases can take an extremely long time.

er,
diskutil secureErase freespace 1 /dev/xxx

So, if you change the hint to: then the file will magically disappear as soon as the drive fills up. This is slightly safer since it does not fail if RAM fills up to. For example, there are reasons why a rm

Secure Erase Free Space Mac

call might not complete. In a ram-tight situation (if, say, the filesystem cache were to get rather large), then a fork might fail if there's no room on the swap device for more vm. JP

---
Pell

As robdew pointed out, you can do this with diskutil. A good rule of thumb is that if Disk Utility can do it, diskutil can do it.
In fact, Apple is great at letting you do anything (and more!) from the command line - for example, the 'softwareupdate' command for auto-updates.

The right method to perform this very action is part of diskutil:
diskutil secureErase freespace 1|2|3 /dev/disk#s#
(See the man page on diskutil)
Band-aids never work right. They always peal off!

But that won't work unless you have root access, right?

Not sure if this applies on MacOSxtended, but ext2/3 reserved 5% of space for the root user. If so the rm method would leave 5% untouched if run without privileges.

Mac Secure Erase Free Space

This command does exactly what Disk Utility does. If your computer crashes during a wipe of the free space, you will find that your hard disk space is reduced. Removing the zeroed file from /tmp (if I remember correctly) will restore the disk space. Try doing it in Disk Utility and watch your disk space shrink.
As others have pointed out, some disk space is reserved for root, and therefore the chance of a crash is minute.
Thanks, robdew, for pointing out the secureErase option of diskutil. Some how I missed that. It does exactly the same thing.

...if you're concerned about running the aforementioned 'erase free space' operation on a 'live' filesystem, you may want to shut down your system and reboot with your OSX install disc and run Disk Utility from there instead.
Or, (in keeping with the spirit of the original hint of using the cmd-line) reboot with your OSX install disc into Single User mode (documented elsewhere) then use the diskutil tip mentioned earlier.

Mac Disk Utility Erase Free Space

Just use the diskutil. Open terminal, type df and hit enter.
Get the name of your disk (probably /dev/disk0s2) and type the diskutil command to erase free space which is:
diskutil secureErase freespace 1 /dev/disk0s2
That will erase your free space with random numbers. See the list of options below:
Level should be one of the following: 0 - Single-pass zeros.
1 - Single-pass random numbers.
2 - US DoD 7-pass secure erase.
3 - Gutmann algorithm 35-pass secure erase.
4 - US DoE 3-pass secure erase.