Mac Os X Erase Free Space

If you use a traditional hard drive with OS X 10.11, and are comfortable with the command line, you can use the Mac's srm command to overwrite the file. Fuller instructions (in English) are available here. Srm was removed in OS X 10.12, but it is still possible to install. In the latest versions of macOS, you can use rm -P to overwrite the file. Fr merely having a Google Drive, users get 15GB free storage space. However, for additional space, you’ll have to incur monthly subscription fees. This Apple cloud-based storage software works best with Apple’s latest gear on the macOS Big Sur. When you use it on any macOS device or an iDevice, you get an extra 5GB of free space. So, check the trash folder and delete all unwanted pictures and videos. Besides these basic methods to clear up the more space on OS X, there are also some third-party apps which help to delete the remnants of the deleted apps. You can find such apps in the Mac App Store. If you do any other method to free up the space, please share with us.


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. :-)

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 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.

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.

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.

A full startup disk is something that every Mac user will experience. This problem used to be known as “Startup disk full” notification. However, on newer macOS versions this message has been changed to “Your disk is almost full.”

But luckily, it’s a problem that has many solutions. And in this article, we’ll go over:

  • What is startup disk full?
  • What's causing 'Your disk is almost full' alert?
  • How to fix startup disk full?
  • How to prevent 'Your disk is almost full' problem?

However, we also understand that some people are short on time and just want to fix startup disk full. So, if you’re not really interested in what it is and why it happens, just skip the next two sections and head to “How to Clean Your Startup Disk”.

Or, even better, if you’re looking how to clear space on Mac, we’d highly recommend a utility called CleanMyMac X. It'll help you clean up gigabytes of disk space in just minutes (you can download it here).

Note: if you’re running a newer version of macOS, it has a built-in option of Optimized Storage that is supposed to solve the problem of the full hard drive by moving files into the cloud.

By clicking 'Manage' you can open the menu and see what Optimized storage offers. However, it moves junk and useless files to the cloud together with your files, and eventually, you end up paying for iCloud storage to store junk. So we still recommend getting CleanMyMac and actually dealing with extra files rather than simply moving them.

Now, with all that said, let’s get into what exactly “Your disk is almost full” means.

Understanding What “Your Disk is Almost Full” Means

What is a startup disk?

A startup disk, as taken from Apple Support article, is a volume or partition of a drive that contains a usable operating system. Still confused? Let’s break it down for you.

Your Mac hard drive consists of disks (or partitions). Each disk (or partition) has your Mac data on it, which consists of your operating system, applications, etc. Most Mac users have just one disk but power users may have two or more.

Let’s look at an example of a Mac with only one hard disk:

  • Your Mac's hard drive is 500GB.
  • It has one 'disk' on it, so all 500GB of storage is on that disk.
  • The disk has an operating system (macOS Big Sur), and user data (apps, etc).
  • And since you only have one disk, this is your startup disk: all 500GB.

A Mac with two disks will have the storage divided between them. The Mac drive with the OS on it is the startup disk while the other drive is just used for storage of files. It’s possible to have multiple startup disks, but most Macs will only have one. And for proper disk cleanup on Mac, all drives are just as important.

Why your disk is almost full?

Space

This is easy. It’s a lot like why is your fridge full? There is no more space! Your disk is almost full and this is very bad news for any drive. A hard disk should never get beyond 85% capacity (especially a startup disk) as you will experience slowness and errors the further you get above that mark.

If your startup disk is full and you get a message of warning from your Mac, this is a serious indication that you need to clear up storage immediately.

What to do when your disk is almost full?

So how do you fix your almost full startup disk? The same way you solve the problem of a packed fridge - you need to clear up storage, of course. To make more space on your startup disk you will need to:

  1. Delete files from your Mac.
  2. Move files to an external hard drive or cloud storage.
  3. Or install a second internal hard drive on your Mac.

So, now that we know what a startup disk is, we need to talk about how to fix it. Let’s take a closer look at your disk space to see exactly what is causing your disk to be almost full.

What’s Causing 'Your Disk Is Almost Full' Alert?

Short version: Take a look under-the-hood of your Mac.

Before we can see what is taking up space on your startup disk, first we have to find it:

Erase Free Space Windows

  1. Hover on the Dock at the bottom of your screen and open Finder.
  2. Click on “Finder” in the menu bar at the top of your screen.
  3. Then select “Preferences…”
  4. In the window that opens, checkmark the “Hard disks” checkbox.
Mac Os X Erase Free Space

After selecting this box, your desktop should now show the hard disks on your Mac, in the form of icon(s), like this:

These are disks on your Mac that you can “startup”, this is because they have operating systems on them. If there is more than one of these hard disk icons that show up on your desktop, it means you’ve got multiple hard disks on your Mac. If you only have one, skip the down to “What is taking up all of my startup disk space?” section.

If you have more than one, continue with the next step:

Click on the Apple icon at the top left of your screen System Preferences > Startup Disk.
Here, again, you’ll find your hard disk(s); they’re probably named something like MainSSD or MainHD. It will also display “OS” and the version number of that OS. If you have more than one OS drive, your startup disk should be the one with the latest version of macOS running on it, but we’re going to make sure of that in the next step.

I only have one and it looks like this:

To make 100% sure that you know what drive is your startup disk, follow these steps:

  1. Click on the Apple Icon in the menu at the top-left of your screen.
  2. Select “About This Mac.”
  3. Under macOS, you’ll find a version number. Mine is 11.01.1, like so:

See how my version number in the “About This Mac” window matches the number in my Startup Disk section? Yep — That’s my startup disk. Found yours? Good.

What is taking up all of my startup disk space?

Now that we’ve identified our startup disk, let’s take a closer look at how to clear up space on Mac:

  1. Click the Apple Icon in the menu at the top-left corner of your screen.
  2. Choose “About This Mac.”
  3. Click Storage.
    Note: If you are running an older version of OS X you may have to first click “More Info…” and then “Storage”.

Take a look at my hard drive disk:

I’ve got 500GB of storage, and about 275GB of it is free.

So, how big is your hard disk? How much free space do you have (if any — *gulp*)? And what’s taking up the most space? It is important to consider drive capacity and data storage needs for future storage plans — we’re not just here to fix the problem, for now, we’re going to make sure you never have this problem in the future as well.

Now that we have the knowledge, it’s time to take action and fix your Mac’s “Startup Disk Full” problem.

How to clear disk space on Mac

Let’s go over 11 things you can do to help fix 'your disk is almost full.' These should also give you other ideas as to how else to fix it — You know your Mac better than we do!

1. Clear system storage on Mac


System storage cleanup sounds like a serious undertaking. But, technically, it boils down to just one thing: having the courage to scrap the old files.

  1. Search for large ZIP/RAR archives in Downloads.
  2. Open your Desktop (Command + F3) and delete screenshots.
  3. In Applications, sort your apps by size. Delete the largest ones.
  4. Restart your Mac to free up RAM.
  5. Get rid of system junk files with a free version of CleanMyMac X.

This app gives you lots of possibilities to free up space, especially when it comes to system junk. CleanMyMac X has been notarized by Apple, which basically means it's safe to use. And if you got 5 minutes, try this tool as it shows you where exactly your junk hides.

2. Clean up cache files on your Mac


Cache files are files that help your Mac run programs a bit more smoothly. Think of them like blueprints for a house: your Mac has the blueprints for how a program is supposed to load/run/look, so it loads it faster; without them, it’d be like building it from scratch. However, over time, these caches can start to take up some serious space. Periodically, removing them can help clear storage. And don’t worry, your Mac will create fresh, new ones after you restart your Mac. To remove caches:

  1. Open a Finder window and select Go in the menu bar.
  2. Click on “Go to Folder…”
  3. Type in ~/Library/Caches
    Delete the files/folders that are taking up the most space.
  4. Now click on “Go to Folder…”
  5. Type in /Library/Caches (simply lose the ~ symbol)
    And, again, delete the folders that take up the most space.

Secure Erase Free Space Mac

Deleting cache files is generally safe for your Mac. And once you delete them, the applications and processes you run on your Mac will generate fresh, new ones. But, when deleting, worry more about removing them based on size rather than just removing all of them.

Also, you can check the /System/Library/Caches folder as well, but it might be better not to touch this folder without knowing what the items are. A utility that correctly cleans up these files (and pretty much everything else on this list) is, you guessed it, CleanMyMac X. It cleans up even your system caches with just a few clicks.

Oh, and once you’re done with this list, restart your Mac so it can create these new cache files.

Read more: How to Clear Cache on a Mac?

3. Get rid of localization files


Localization files are also known as “language packs.” Lots of apps come with other languages that you probably don’t need. To clear up space on your Mac, delete the ones you don’t need:

  1. Open a Finder window.
  2. Go to Applications.
  3. Ctrl+click on an application.
  4. Select “Show Package Contents.”

From here, go to Contents > Resources and look for files ending in .lproj. These are the languages your app has just in case you want to use it in another language, like Spanish (es.lproj). Drag the ones you’ll never use to the Trash.

Again, a safer alternative to this would be to use CleanMyMac X. It gets rid of all of them with a click. No digging through application folders, just a cleaner Mac.

Read more: How to Delete Language Files from macOS?

Erase

4. Delete duplicate files


Even if you have the most organized Mac on a planet, duplicates happen one way or another. It can be a file you’ve mistakenly downloaded twice or a mail attachment you’ve opened several times. Regardless of how they appeared, those files sit on your Mac and gobble up storage.

But finding and deleting them is a time-consuming process if you do it one by one. So here’s what you can do for a simple Mac disk cleanup:

  1. Open the Finder app on your Mac
  2. Move cursor over File and click New Smart Folder
  3. Click the “+” button in the upper right corner and choose the type of files you want to see
  4. Now sort them by name to quickly spot duplicates.

Remember to pay attention to the date of creation to make sure you keep the true original, not the copy.

While this is the best way to remove duplicates manually, it takes lots of your time and dedication. It’d be much easier to leave this to Gemini 2: The Duplicate Finder.

This app quickly scans your Mac for duplicate and similar files and allows you to delete them within minutes. It keeps your originals safe and helps you easily retrieve files deleted by accident.

5. Remove old iOS backups


Backups can tend to take up a lot of space. You can find and remove them by:

  1. Launching a Finder window.
  2. Clicking “Go” in the menu bar.
  3. Selecting “Go to Folder…”
  4. Then, type in ~/Library/Application Support/MobileSync/Backup/

How To Erase Free Space On Mac

Get rid of all the old, outdated backups your Mac has been storing for a bit more extra space.

6. Remove large and old files


Keeping many large files on your Desktop and in Documents slows down the system. And if you delete only a couple of these enormously large files, you can get half of your storage back.

Let’s open the familiar About this Mac pane once again. If you click Manage, you’ll see this window for sorting files.

While this instrument is good for finding large files, it misses a lot of things. See that “Other” category that takes up 38.GB?

To deepen your search for massive files, use this tool from CleanMyMac X. It’s called Large & Old files finder.

It’s much more helpful as it shows you lots of other categories of files, like Archives. The app breaks your files by Size and Last Used.
To see this instrument in action, download the free edition of CleanMyMac X. And click the Large & Old files at the bottom of the sidebar.

7. Remove unnecessary applications


This isn’t often overlooked, but definitely under-appreciated. Removing old, unused applications is a great way to get some extra space on your startup disk. Go through your applications folder and get rid of all the apps you rarely use. But make sure you remove them correctly, don’t just drag them to the Trash. If you do, you’ll leave behind tons of leftover parts and pieces, and we’re trying to get back startup disk space — It’ll kinda defeat the purpose, no?

This is another place we’d suggest using CleanMyMac X. To completely remove any application, just launch CleanMyMac X, click Uninstaller, select your application, and then click Uninstall. You won’t have to search all over for development junk that’s left behind when Trash’ing an application. It’s incredibly easy and saves you tons of time.

8. Move your Photos and Docs to the cloud


When your local storage is full to the brim, your Mac will start uploading this data to iCloud. But only if you have this setting enabled. Is your Photos app synced with iCloud already? Let’s check.

What Does Erase Free Space On Mac Mean

  • Open Applications and find the Photos icon.
  • Launch Photos and click on Preferences in the top menu.

Ticking the box iCloud Photos will connect your Photos library to iCloud. And what’s more important, if you select Optimise Storage, some part of your Photo library will be moved to iCloud. This way you macOS saves precious space. The free iCloud plan allows you to free up at least 5 GB worth of storage.

The similar logic applies to your Documents and other files. To set up the cloud backup with iCloud drive, go to System Preferences > Apple ID > iCloud.

9. Clean up your Downloads, Movies, and Music folders


Have a closer look at these three folders. You’d be surprised at how many downloads can accumulate when you aren’t paying attention. Clean out anything you don’t need (or don’t know) and organize the rest. It’ll take a load off your mind to know that there’s nothing excess there.

The Movies folder can be a pain, not because you’re searching through tons of files, but it can be difficult to choose what to delete. Personally, I never want to get rid of Top Gun. It’s amazing. I watched it 3 times in a row last weekend. But alas, sometimes you need to make sacrifices for the health of your Mac. Though, what you can do with movies you want to keep is to archive them. So, archive what you wish to keep and remove the rest.

How to archive/compress a file

Archiving a file doesn’t mean to store deeper into the abyss of your Mac — but to turn the file into something smaller, into a compressed file (like .zip or .tar). By archiving a file, you shave off some memory. Archiving is essential for things you want to keep on your Mac, but don’t often use, and helps you clear up some space. And that’s what this is all about right? We’re essentially doing the hokey-pokey on your Mac. To archive a file, just:

  1. Ctrl+click the file you want to compress (recommended for movie files).
  2. Select, “Compress .”

The last place to sweep through is the Music folder. Find and remove duplicate music files first, and then clean up all the songs you downloaded on a weird Sunday afternoon cleaning the house.

10. Clean your Desktop


“Clean my desktop… but why?” Because some people’s desktops are hard to look at, that’s why. Organize your desktop and get rid of the stuff you just don’t need on there. It looks better and helps your Mac act a bit faster (I don’t know the rocket science behind this one, but it feels too good to be false). Your Mac doesn’t waste time loading all those icons and junk, just… Just clean it, please.

11. Empty out the Trash (No, we’re not joking…)


Seriously: It may sound incredibly basic, but it could clear a surprising amount of storage. I forget to do it all the time. The thing is, that when you delete something, your Mac doesn’t remove it — it just moves it to the Trash. Plus, you’ve probably deleted way more than you realize, and all that could be sitting in the Trash, wasting space. So get rid of all that junk by emptying the Trash:

  1. Ctrl+click your Trash in the Dock.
  2. Select “Empty Trash.”
  3. And click “Empty Trash.”

And, the easiest step is done.

A few more tips to clear storage on Mac

1. Manage your Optimized Storage

This option comes with your operating system starting macOS Sierra. Go to the Apple menu > About this Mac > Storage

Now, click on Manage to reveal the space-saving options:

Macos Erase Free Space

2. Erase your Junk Mail

Open your Mail app, and click Mailbox in the upper menu. Here you can erase spam and already deleted items.

Full Startup Disk Prevention

We’ve cleaned up a few things on your Mac, and hopefully, it’s given you more ideas as to what else you can clean. But, let’s take a look at how much space you saved from cleaning the list above. Remember how we checked your Mac’s free space? Open that window again and see how much space you’ve cleared up:

  1. Click the Apple Icon in the menu at the top-left corner of your screen.
  2. Choose “About This Mac.”
  3. Click Storage.
    Note - If you are running an older version of macOS you may have to first click “More Info…” and then “Storage”.

You’ve probably got a bit more space, and you’ll want to keep it that way. The only way to prevent a “your disk is almost full” is by keeping your Mac clean. We’d recommend a complete cleaning every 2–3 weeks.

Mac Os X Erase Free Space Windows 10

Say goodbye to the 'Your startup disk is almost full” message.

Macos Catalina Erase Free Space

We've told you how to delete storage on Mac in multiple ways. Hopefully, this has helped you fix that full startup disk problem. Your startup disk should now be quite a bit lighter (we hope). Oh, and if you liked this article, get social with it to help others in need. And if you really liked this article, subscribe to our email list — we’ve got more guides on the way. And we’ve also got a utility that’ll help you out a ton in the long run: CleanMyMac X. It helps you clean your entire Mac with just the click of a button. It’s incredibly easy to use and works like a charm.