Remove large file on Mountain Lion when disk is full
I ran a process that was writing stderr log messages to a file and didn't realize how fast the log file would grow. The result is that the log file filled up the entire rest of my hard drive and now when I try to remove the file using rm
, the computer freezes. I'm running OS X Mountain Lion and my primary hard drive is 2TB. The log file is consuming over 1TB of disk space.
Do I need to just let rm
run for a long time to remove a 1TB file? Should I just restore from a time machine backup?
You want to zero the log file from the command line.
Something like : > /path/to/file.log
See: Is there a way to delete 100GB file on Linux without thrashing IO / load?
Do I need to just let rm run for a long time to remove a 1TB file?
Yes. It's very likely that a file which filled up the disk is spread into fragments everywhere and the filesystem needs to adjust the free list entries for every single fragment. This takes a while.
Should I just restore from a time machine backup?
This is an option. It's debatable whether it would take longer. If you think you might lose anything, just wait for rm
.