tl;dr; To solve Spotlight using hundreds of Gbs, boot in recovery mode and delete its folder: rm -rf /System/Volumes/Data/.Spotlight-V100
.
Then configure Spotlight to ignore folders containing millions of non-search-relevant files.
A few days ago my computer started to act VERY weirdly. I have an Apple M3 Pro running macOS Sequoia. Everything started to slow down and I could not figure out why.
Looking at the Activity Monitor I saw of course mentions of mds
and mds_stores
. I immediately blamed Spotlight which has been a big CPU consumer since it was ever created.
But the issue was not the CPU usage, my computer was actually having a hard time writing to disk.
Looking at tools like DaisyDisk I discovered that:
- My disk was almost full (1TB!)
- Most of the used space (500GB) was in the "hidden space"
DaisyDisk help page says "Large amounts of hidden disk space may also indicate to file system errors. Follow our troubleshooting guide for details."
And it turns out, my Storage settings in macOS was also saying I had huge amounts of "System data" being used:
After multiple hours of searching around how to solve this, including commands like sudo mdutil -E
, sudo mdutil -X
, and disk repair attempts ... I finally found the exact issue.
Before trying out any other solution, if you have huge amounts of system data showing up as used in your storage system settings then follow these steps:
- Boot in recovery mode
- Open the terminal
- Remove the Spotlight folder
rm -rf /System/Volumes/Data/.Spotlight-V100
- Boot in normal mode
- See that you recovered your space!
- Now make sure to ignore any folder containing a lot of non-relevant files. For example avoid
Dev/
style folders withnode_modules
in them, or any temp/ logs/ folders that have millions of files in them - Activate Spotlight indexing:
sudo mdutil -E /
(it should already be on but whatever)
Bonus tip: how to show folder sizes in finder
Before I understood this was a Spotlight issue (always bet on Spotlight for cpu or space issues first), I was trying to find what are the biggest folders on my computer.
To solve this, there's a very nice way to always display the total sizes of folders on screen in finder.
In any finder window, use ⌘ + J then check "Calculate all sizes" and click on "Use as Defaults". That's it, now you can easily navigate and spot the biggest space consumers.
If this has been useful, drop me a comment. See ya!
Top comments (1)
Was debugging what this setting changes and came up with a CLI approach: