Change Ollama Model Storage Location with OLLAMA_MODELS
Move Ollama models by setting OLLAMA_MODELS on the server process. Give the folder to the ollama user, copy the models, then check the log and ollama list.
When models fill the root disk, move the store to another disk. These are the default locations from the official FAQ:
| OS | Default location |
|---|---|
| Linux (install script) | /usr/share/ollama/.ollama/models |
| macOS | ~/.ollama/models |
| Windows | C:\Users\%username%\.ollama\models |
One environment variable, OLLAMA_MODELS, changes it. But the server (ollama serve, the service) is what reads it. Running export OLLAMA_MODELS=… in a terminal and then ollama list changes nothing while the server keeps its old setting. Giving only the CLI a different value still listed the server's store:
$ docker exec -e OLLAMA_MODELS=/tmp/nowhere ollama ollama listNAME ID SIZE MODIFIED Qwen2.5:0.5b a8b0c5157701 397 MB 7 minutes ago [1] Create the new folder and give it to the user that runs the server. The Linux install runs as the ollama user, and the FAQ says that user needs read and write access:
$ sudo mkdir -p /data/ollama-models$ sudo chown -R ollama:ollama /data/ollama-modelsThe parent folders must be traversable too. Under a home directory that other users can't enter (ls -ld /home/<user> shows drwxr-x--- or similar), the ollama user can't get in and you get the error in [5]. On a separate disk, a folder right under the mount point is a safe choice.
[2] Stop the server and copy the existing models to the new location. Doing it while nothing is downloading keeps half-pulled files out.
$ sudo systemctl stop ollama$ sudo cp -a /usr/share/ollama/.ollama/models/. /data/ollama-models/The models folder holds blobs (the model files) and manifests (the names); on 0.40.11 there were also manifests-v2 and metadata. You copy the whole folder, so there's nothing to pick. Within one disk mv works too, but copying keeps the original until you've checked the result, which makes rolling back easy.
[3] Give the server OLLAMA_MODELS. For the Linux service, add this with sudo systemctl edit ollama.service (FAQ format):
[Service]Environment="OLLAMA_MODELS=/data/ollama-models"$ sudo systemctl daemon-reload$ sudo systemctl start ollamaFor the macOS app, run launchctl setenv OLLAMA_MODELS /data/ollama-models and restart the app; on Windows, add it to your user environment variables, then quit and restart Ollama (FAQ). In Docker, instead of the variable, it's simpler to mount the new disk at the container's default location, as in -v /data/ollama-models:/root/.ollama/models.
[4] Confirm in the startup log that the server picked up the new value. The server config line prints every value the server read. If you changed the Linux service in [3], read the service log:
$ journalctl -u ollama --no-pager | grep -o 'OLLAMA_MODELS:[^ ]*'The same line, tested with a Docker container (containers log to docker logs):
$ docker logs ollama 2>&1 | grep -o 'OLLAMA_MODELS:[^ ]*'OLLAMA_MODELS:/data/ollama-modelsThen check that ollama list shows your models. Below are the list with the server started on the still-empty new folder, and the list after copying. The first is what usually gets reported as "all my models disappeared":
NAME ID SIZE MODIFIED NAME ID SIZE MODIFIED Qwen2.5:0.5b a8b0c5157701 397 MB 7 minutes ago If the list is empty, don't delete anything; check that the copy in [2] landed in the new location (ls /data/ollama-models should show blobs and manifests). After the copy, the model appeared without restarting the server, and ollama run qwen2.5:0.5b answered from the files in the new location.
[5] If the server exits right away, it's permissions. With an unwritable folder as OLLAMA_MODELS, the server logged this line at startup and quit:
Error: mkdir /data/ollama-models/blobs: permission denied: ensure path elements are traversable$ docker ps -a --filter name=ollama-perm --format '{{.Status}}'Exited (1) 5 seconds agoThe server creates blobs inside the folder when it starts, so missing write permission or an untraversable parent folder ends like this. After changing the folder's owner to the server's user (UID 1000 for the container user in the test), the same setup came up to Listening on [::]:11434. On the Linux service, the chown from [1] is missing; under a home directory, check the parents' permissions with namei -l /data/ollama-models. Read the service log with journalctl -u ollama --no-pager.
[6] Delete the old folder after using the new location for a few days.
If the disk is full because of logs or other files rather than models, see Find what's filling the disk.
Check it with the chmod · umask calculator tool ↗ — calculated in your browser.