[GH-ISSUE #7821] Unable to save models to custom path #67060

Closed
opened 2026-05-04 09:23:59 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @rattle99 on GitHub (Nov 24, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7821

What is the issue?

I update my ollama.service file at /etc/systemd/system/ollama.service as below by adding the environment variable OLLAMA_MODELS so that I can have ollama download and save the models in a different location. By default it saves models in /usr/share/ollama/.ollama/models.

[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
Environment="OLLAMA_MODELS=/home/rattle/Downloads/LLMs/OllamaModels"

[Install]
WantedBy=default.target

I then changes the directory ownership by sudo chown -R ollama:ollama <directory> as can be seen below

rattle@loq:~/Downloads/LLMs/OllamaModels$ ls -lah
total 8.0K
drwxrwxr-x 2 ollama ollama 4.0K Nov 24 01:43 .
drwxrwxr-x 3 ollama ollama 4.0K Nov 24 01:43 ..

then a standard systemctl daemon-reload followed by systemctl restart ollama.
But upon checking the service I get the error below

sudo systemctl status ollama
● ollama.service - Ollama Service
     Loaded: loaded (/etc/systemd/system/ollama.service; enabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Mon 2024-11-25 01>
    Process: 61176 ExecStart=/usr/local/bin/ollama serve (code=exited, status=1/FA>
   Main PID: 61176 (code=exited, status=1/FAILURE)
        CPU: 21ms

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.4.4

Originally created by @rattle99 on GitHub (Nov 24, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7821 ### What is the issue? I update my ollama.service file at `/etc/systemd/system/ollama.service` as below by adding the environment variable `OLLAMA_MODELS` so that I can have ollama download and save the models in a different location. By default it saves models in `/usr/share/ollama/.ollama/models`. ```service [Unit] Description=Ollama Service After=network-online.target [Service] ExecStart=/usr/local/bin/ollama serve User=ollama Group=ollama Restart=always RestartSec=3 Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" Environment="OLLAMA_MODELS=/home/rattle/Downloads/LLMs/OllamaModels" [Install] WantedBy=default.target ``` I then changes the directory ownership by `sudo chown -R ollama:ollama <directory>` as can be seen below ```bash rattle@loq:~/Downloads/LLMs/OllamaModels$ ls -lah total 8.0K drwxrwxr-x 2 ollama ollama 4.0K Nov 24 01:43 . drwxrwxr-x 3 ollama ollama 4.0K Nov 24 01:43 .. ``` then a standard `systemctl daemon-reload` followed by `systemctl restart ollama`. But upon checking the service I get the error below ```bash sudo systemctl status ollama ● ollama.service - Ollama Service Loaded: loaded (/etc/systemd/system/ollama.service; enabled; preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Mon 2024-11-25 01> Process: 61176 ExecStart=/usr/local/bin/ollama serve (code=exited, status=1/FA> Main PID: 61176 (code=exited, status=1/FAILURE) CPU: 21ms ``` ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.4.4
GiteaMirror added the bug label 2026-05-04 09:23:59 -05:00
Author
Owner

@rattle99 commented on GitHub (Nov 24, 2024):

Small update:

Works when I run with OLLAMA_MODELS=/home/rattle/Downloads/LLMs/OllamaModels ollama serve, it downloads to the correct directory, but it's not running as a service this way. The service file should work, what's causing the error?

<!-- gh-comment-id:2496218158 --> @rattle99 commented on GitHub (Nov 24, 2024): Small update: Works when I run with `OLLAMA_MODELS=/home/rattle/Downloads/LLMs/OllamaModels ollama serve`, it downloads to the correct directory, but it's not running as a service this way. The service file should work, what's causing the error?
Author
Owner

@rick-github commented on GitHub (Nov 25, 2024):

The server ollama runs as user ollama, and doesn't have access to your Downloads directory because the permissions of /home/rattle prevent it. You can either loosen the permissions (chmod a+x ~) or add ollama to your group: sudo usermod -a -G $(id -ng) ollama.

<!-- gh-comment-id:2496454140 --> @rick-github commented on GitHub (Nov 25, 2024): The server ollama runs as user ollama, and doesn't have access to your Downloads directory because the permissions of `/home/rattle` prevent it. You can either loosen the permissions (`chmod a+x ~`) or add ollama to your group: `sudo usermod -a -G $(id -ng) ollama`.
Author
Owner

@rattle99 commented on GitHub (Nov 25, 2024):

The server ollama runs as user ollama, and doesn't have access to your Downloads directory because the permissions of /home/rattle prevent it. You can either loosen the permissions (chmod a+x ~) or add ollama to your group: sudo usermod -a -G $(id -ng) ollama.

Thanks, didn't notice the linux permission issue!

Fixed it by changing ownership of the .ollama folder instead with sudo chown -R ollama:ollama ~/.ollama and adding Environment="OLLAMA_MODELS=/home/rattle/.ollama/models" to the service file.

<!-- gh-comment-id:2498315161 --> @rattle99 commented on GitHub (Nov 25, 2024): > The server ollama runs as user ollama, and doesn't have access to your Downloads directory because the permissions of `/home/rattle` prevent it. You can either loosen the permissions (`chmod a+x ~`) or add ollama to your group: `sudo usermod -a -G $(id -ng) ollama`. Thanks, didn't notice the linux permission issue! Fixed it by changing ownership of the .ollama folder instead with `sudo chown -R ollama:ollama ~/.ollama` and adding `Environment="OLLAMA_MODELS=/home/rattle/.ollama/models"` to the service file.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#67060