Skip to content

How-ToSSD

How to Move the Hugging Face Cache to Another Drive

Python AI tools that download models through Hugging Face store them in a hidden cache on your system drive. Here's how to move it to a bigger SSD with HF_HOME or HF_HUB_CACHE, plus the Windows symlink catch, from Hugging Face's own docs.

By , Systems & Technical Editor

3 min read

How to Move the Hugging Face Cache to Another Drive

If you use Python AI tools, many of them download models through Hugging Face's huggingface_hub library, and those files pile up in a hidden cache folder on your system drive. A few large models can eat a big chunk of an SSD. The fix is an environment variable that moves the cache to another drive. This guide follows Hugging Face's own documentation, read on 28 November 2026.

Where the cache lives now

Hugging Face's documentation says HF_HOME sets where huggingface_hub stores its local data, and that "your token and the cache will be stored in this folder". It defaults to ~/.cache/huggingface, which on Windows means a .cache\huggingface folder inside your user folder. Models, datasets and Spaces you download go into a hub subfolder: HF_HUB_CACHE defaults to $HF_HOME/hub.

Option 1: move everything with HF_HOME

Setting HF_HOME is the simplest option because it moves the hub cache, Hugging Face's Xet cache (HF_XET_CACHE defaults to $HF_HOME/xet) and your saved token (HF_TOKEN_PATH defaults to $HF_HOME/token) together.

  1. Close any apps or Python scripts that use Hugging Face.

  2. Create a folder on the new drive, for example D:\huggingface.

  3. Move the contents of your old .cache\huggingface folder into it if you want to keep what you've already downloaded.

  4. Set a user environment variable called HF_HOME with the value D:\huggingface. On Windows, search for "environment variables" in Start, open Edit environment variables for your account and add it there. Our guide to setting Ollama environment variables on Windows walks through the same Windows dialog.

  5. Open a new terminal (existing ones won't see the change) and run your app again.

On Linux, add export HF_HOME=/mnt/data/huggingface (or your own path) to your shell profile.

Option 2: move only the model downloads with HF_HUB_CACHE

If you only want the big files elsewhere, set HF_HUB_CACHE instead. Hugging Face says it configures "where repositories from the Hub will be cached locally (models, datasets and spaces)". Your token and other settings then stay in the default HF_HOME folder.

Pick a fast drive

Model files are big, so give the cache a roomy SSD rather than squeezing it onto a nearly full system drive. Drives in our database that suit a model library include the Samsung 990 PRO 4TB and the WD_BLACK SN850X 4TB with heatsink. See how much storage you need for local AI for sizing.

Hugging Face's cache uses symlinks to avoid storing the same file twice. Its documentation says symlinks are "a known limitation especially on Windows". Without them the library stores files directly in the snapshots folder, which works but can mean a file is downloaded several times if you fetch multiple revisions of the same repo. Hugging Face says that to use the symlink-based cache on Windows you need to activate Developer Mode or run Python as an administrator.

If your new cache is on a shared network drive such as a NAS used by Windows and Linux machines, Hugging Face suggests setting HF_HUB_DISABLE_SYMLINKS=1, because "symlinks created on Linux are not always traversable on Windows". The trade-off is that large files may be duplicated.

Tidy up the cache

Once it's moved, the hf command-line tool can manage it. Hugging Face's cache guide covers hf cache ls to see what's cached, hf cache rm to delete repos and hf cache prune to remove shared files that no cached repo uses any more.

Other model folders

Not every local AI app uses this cache. Ollama, LM Studio and ComfyUI keep their own model folders, and we have separate guides to moving Ollama models to another drive, changing the LM Studio models folder and moving ComfyUI models to another drive. For grabbing individual files, see how to download models from Hugging Face.

The bottom line

Set HF_HOME to a folder on a bigger drive to move the whole Hugging Face cache, including your token, or set HF_HUB_CACHE to move only model and dataset downloads. Open a new terminal afterwards, and on Windows turn on Developer Mode if you want the space-saving symlink cache to work.

In this article

Sources

  1. 01Hugging Face, huggingface_hub environment variables
  2. 02Hugging Face, Understand caching (huggingface_hub)

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

How to Use Ollama Launch to Start Coding Agents with Local Models

How-To

How to Use Ollama Launch to Start Coding Agents with Local Models

Ollama's launch command sets up and starts coding agents such as Claude Code, OpenCode and Codex with local models, without editing config files. Here's how to use it, which apps it supports and why you need a 64K context window first.

Marcus Thorne3 min