2

I have macOS High Sierra - 10.13.6 Security Update 2020-006 (17G14042) and my system is not behaving well due to the disk being full of data.

I try to keep a few GB free on my Mac's HD but occasionally it suddenly gets full for reasons beyond my control (some swap file randomly gets larger perhaps?). Then the system deadlocks - files cannot be saved, the Finder becomes unresponsive (even when force-relaunched), some other applications become unresponsive, and some of the ones that do respond are unable to quit cleanly (presumably because that would involve writing to files). I'd like to save my unsaved work by first clearing disk space without having to hold down the power key.

The first thing I do is force-quit browsers but that alone doesn't solve it. I typically still have Terminal open and am able to switch to it. There, using df and du I can see that maybe 1-2G could be freed from ~/Library/Cache or ~/Downloads. However, when I try to remove files using rm, e.g.:

rm -rf ~/Library/Cache/Google

or:

rm -f ~/Downloads/biggest_single_file.blob

...then the rm utility itself refuses, with the message "No space left on device". To me this is surprising - why would a utility whose sole purpose in life is to remove files need to consume disk space? It's like saying "You're too thirsty to drink," or "Let's not turn on the heater, it's too cold," - in other words, ridiculous.

I'm guessing the explanation must be that rm, even though I've been thinking of it as a low-level utility, is really doing something more complicated involving versioning or backups or journaling or something that requires a file to be created. If so: is there an even-lower-level command for truly just deleting files?

Update: I guess whatever over-clever thing is consuming disk space must actually be a property of the filesystem rather than necessarily the rm utility. I got the same error message if I tried

echo "" > ~/Downloads/biggest_single_file.blob

or

python -c "open('$HOME/Downloads/biggest_single_file.blob','wt')"
9
  • What version of macOS are you running and where exactly (full path - there are multiple libraries ) are you trying to delete. It’s either SIP or snapshots or something broken and we need more details to diagnose this properly.
    – bmike
    Commented Dec 13, 2022 at 16:53
  • 1
    If you can boot into recovery and do a diskutil list might also help. The things you move off a 2 TB disk are different than 128 GB in practice
    – bmike
    Commented Dec 13, 2022 at 16:55
  • @bmike As the tag says, it's High Sierra (the hardware doesn't allow me to upgrade beyond that). I've edited the question with example rm commands. Sure I expect even an ordinary restart would clear the problem, but in these situations I'd like to salvage an unsaved file first.
    – jez
    Commented Dec 13, 2022 at 16:59
  • Try deleting these files using the Finder and then emptying the Trash
    – lhf
    Commented Dec 13, 2022 at 17:45
  • 1
    @nohillside rm is hashed (/bin/rm)
    – jez
    Commented Dec 13, 2022 at 18:23

1 Answer 1

1

A couple things - there is no more low level item, and being on High Sierra you could have APFS and you could have HFS+ filesystem. Both will behave poorly when there is no room for more file data since both systems use data space to contain large directory and metadata. Regardless of which of the two you have, I would recommend these tasks:

  1. Get an external drive and install a bootable OS onto it so you can make major changes / nurse the internal drive back to health.
  2. Look at backups - if you have a backup that you trust you could delete the entire user folder - make a new admin user - then fix the filesystem or know you just need to erase / reinstall / move less data back.
  3. Keeping "a few GB free" isn't a good plan on macOS - you want 10 or more free ideally. Use an external drive to home the user profile or move large items like music / photos / videos or large applications to the external drive so the boot drive can have plenty of free space.
  4. Get a tool like Daisy Disk to help you with disk space discovery if the native tools don't help.

Only if you have APFS - look at snapshots, but I believe that came in a newer OS than yours, but disk utility should show you if there are any snapshots as can command line items. You have a system that's not working (you know this) if a rm (or sudo rm) in the user home folder doesn't clear space. Try to boot to another OS that's healthy and then repeat your cleaning - your system might not be healthy enough to fix itself. Be sure to run fsck or Disk Utility to repair the drive once you clean space (or once before you clean, then clean, then once again to be sure it's ready to try to run - perhaps after re-applying the last combo updater to be sure the key parts of the system are still correct).

1
  • Thanks for the details. In fact a plain old restart (well, hold down the power button until it stops struggling, then restart) usually fixes the problem in the short term. The system comes back with several gigs freed and then I can delete caches and downloads to get more. I now have 14 free, of which I think maybe half was due to manual deletion. I can see that the problem transcends even rm - guess there really is no solution for saving one's work-in-progress when it happens.
    – jez
    Commented Dec 13, 2022 at 22:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .