I have a second drive mounted at /mnt/data that survives system rebuilds. Ollama models are large — pulling everything again from scratch after a reinstall is painful — so I wanted to move the model storage there. Ollama respects the OLLAMA_MODELS environment variable, and since it runs as a systemd service, the cleanest way to set that is with a drop-in override.
Creating the Drop-in
systemd drop-ins let you override parts of a unit file without touching the original. The convention is a directory named <unit>.d/ under /etc/systemd/system/:
sudo mkdir -p /etc/systemd/system/ollama.service.d
sudo nvim /etc/systemd/system/ollama.service.d/models_location_override.conf
Contents of models_location_override.conf:
[Service]
Environment="OLLAMA_MODELS=/mnt/data/ollama/models"
Make sure the path matches your actual mount point. I initially wrote /data/ollama/models (missing the /mnt prefix) and got this on the first restart:
Error: mkdir /data: permission denied: ensure path elements are traversable
Reloading and Restarting
Whenever a unit file or drop-in changes on disk, systemd needs to be told:
sudo systemctl daemon-reload
sudo systemctl restart ollama.service
The service came up fine after fixing the path, but running ollama list still failed:
Error: mkdir /mnt/data/ollama/models/manifests: permission denied
Fixing Permissions
Ollama runs as the ollama user, so the target directory needs to be owned by that user. I had created /mnt/data/ollama as my own user earlier:
sudo chown -Rv ollama:ollama /mnt/data/ollama
Then a final restart:
sudo systemctl restart ollama.service
Verifying
sudo systemctl status ollama.service
The drop-in shows up in the status output confirming it’s active:
Drop-In: /etc/systemd/system/ollama.service.d
└─models_location_override.conf
Active: active (running)
Pulling a model confirms writes are going to the new location:
ollama pull gemma4
Summary
Three steps:
- Create
/etc/systemd/system/ollama.service.d/models_location_override.confwithEnvironment="OLLAMA_MODELS=<your path>" sudo chown -R ollama:ollama <your path>— the ollama service user needs write accesssudo systemctl daemon-reload && sudo systemctl restart ollama.service
