Google Drive and OneDrive keep more on your disk than they show

Both Google Drive and OneDrive now run on macOS’s File Provider framework. That’s why their folders moved out of your home directory and into ~/Library/CloudStorage, where Dropbox and Box also appear. It’s also why their caches and databases now live somewhere else again, in ~/Library, where making files online-only doesn’t reach them.

Two columns, Google Drive and OneDrive. The top layer is the folder the Finder shows in ~/Library/CloudStorage, which shrinks when files are made online-only. The layer below lists the stores kept elsewhere in ~/Library, the DriveFS content cache and metadata database for Google, and the group container, container and cache folders for OneDrive, which do not shrink
The folder you see is only the top layer. The stores underneath don’t shrink when you free up space.

Measuring both

# Google Drive
ls ~/Library/CloudStorage/
du -sh ~/Library/Application\ Support/Google/DriveFS 2>/dev/null

# OneDrive
du -sh ~/Library/Group\ Containers/*OneDrive* 2>/dev/null
du -sh ~/Library/Containers/com.microsoft.OneDrive* 2>/dev/null

The folders in ~/Library/CloudStorage hold the file contents you can see. The rest is Library.

DriveFS is the one that surprises people. It holds Google Drive’s content cache and a metadata database for each account, and on an account with hundreds of thousands of files the database alone can run to several gigabytes. It’s not file content, so evicting files doesn’t touch it. Disconnecting an account can also leave its directory behind, so look inside DriveFS for folders named with an account ID you no longer use.

Google Drive: stream or mirror

Google Drive asks you to pick a mode for My Drive in its preferences:

  • Stream files. Nothing is local until you open it, and recently used files stay in a cache.
  • Mirror files. Everything is local, always. This is the mode that fills a laptop.

In either mode, right-click a file or folder and choose “Available offline” to pin it. Pinned items are never evicted, and a folder pinned by accident is a common reason a streaming setup still uses 200 GB. On the File Provider version macOS manages the cache, so the older setting that moved the local cache directory to another drive isn’t available.

OneDrive: Files On-Demand

On a Mac, OneDrive’s Files On-Demand is on. Right-click gives “Free up space” to evict and “Always keep on this device” to pin. To drop whole branches from this Mac, go to OneDrive’s settings, Account, then Choose folders.

On both clients, check for pinned folders before deciding online-only isn’t working. One pinned parent pins everything beneath it.

Clearing the caches

Quit the app first, in both cases, and only once Google Drive shows nothing left to upload: files waiting to upload sit in its content cache, and deleting it then loses them for good.

# Google Drive content cache
rm -rf ~/Library/Application\ Support/Google/DriveFS/*/content_cache

# OneDrive cache
rm -rf ~/Library/Caches/com.microsoft.OneDrive*

Both are rebuilt. The first few files you open afterwards will be slower, and Google Drive spends a while re-reading metadata on its next launch.

Don’t delete the whole DriveFS directory to save time. It contains the account database, and removing it forces a full re-scan of the account, which on a large Drive takes hours and on a slow connection can take days.

Uninstalling either app leaves the sync folder behind. Remove the account inside the app first, then uninstall.

Why the folder never matches the account

Usually all of these at once:

  1. Shared drives and “Shared with me” content can be mounted locally but counted differently by the web interface.
  2. Google Docs, Sheets and Slides aren’t files you can download as-is. On disk each one is a small link file that opens the document in a browser, while in the account it counts toward your storage quota. A Drive that’s mostly documents is almost nothing locally.
  3. Online-only content has a size in the Finder and no blocks on disk, so du and ls -l disagree. That disagreement is also how you find it, as telling online-only from local files shows.

What’s online-only isn’t backed up

This applies to every sync client equally. Time Machine copies what’s on the disk, and an online-only file has no blocks to copy. If the account is deleted, or an administrator removes your access to a work OneDrive, your local backup won’t have those files.

That’s no reason to avoid online-only. It’s a reason to know which of your files exist in exactly one place, which what to back up before any cleanup walks through. Dropbox has its own version of the cache problem, and Optimise Mac Storage is Apple’s take on the same trade.

Keep reading