By default the model files are stored:
- Windows:
C:\Users%username%.ollama\models
- Linux:
/usr/share/ollama/.ollama/models
- macOS:
~/.ollama/models
How to change Ollama models location
-
Create a symlink in
/usr/share/ollama/.ollama/
to point to the folder in the mounted device:ln -s /usr/share/ollama/.ollama/models /mnt/<device-hash>/<folder-to-models>/`
-
Change the ownership of the symlink to the ollama user
sudo chown -h ollama:ollama /usr/share/ollama/.ollama/models
-
Create the new directory for the Ollama models
Create a new directory where you want the Ollama models to be saved. For example, if you want them to be in another device, you can run the command below replacing the
<device-name>
with the Device name and the<folder-to-models>
with a name of the directory.cd /mnt/<device-name> mkdir <folder-to-models>
For example,
cd /mnt/41125476-5abe-4ve3-462f-50avf735h73d/ mkdir ollamamodels
-
Change the ownership of the ollama models directory to your user
sudo chown $USER:$USER /mnt/<device-hash>/<folder-to-models>/
-
Change the user in ollama config
sudo systemctl edit ollama.service
Edit the file content:
[Service] User=<your-user> Group=<your-user> Environment="OLLAMA_MODELS=/mnt/<device-hash>/<folder-to-models>/"
-
Restart the service
sudo systemctl daemon-reload sudo systemctl restart ollama sudo systemctl status ollama # on error, run sudo journalctl -u ollama.service