[GH-ISSUE #7284] Is default install location configurable #4628

Closed
opened 2026-04-12 15:32:19 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @wgong on GitHub (Oct 21, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7284

I run Ollama on Ubuntu, where its default home is /usr/share/ollama.
Recently, I ran out of space on that partition after experimenting with quite a few models.
I then modified the install.sh script to install Ollama to /opt/ollama.
This worked when starting Ollama on the terminal by running ollama serve; however, when I tried running it as a systemctl service,
it failed. Checking the log via sudo journalctl -u ollama -n 50 --no-pager
showed an error message like "no permission to write id file in /usr/share folder".
I'm curious if /usr/share is hard-coded somewhere.

After creating a symlink for /usr/share/ollama to /opt/ollama and revising /etc/systemd/system/ollama.service to run as root, I was finally able to start the systemctl service.
Although it worked for me, I suspect it's a hack. Could you please advise on the correct way to install Ollama to a custom location and run it as a service (not as root)?

Claude Pro helped me with the above troubleshooting and workaround.
It mentioned that the following environment variables are customizable. Is this correct?

OLLAMA_HOST: Specifies the host and port Ollama listens on (default: 127.0.0.1:11434).
OLLAMA_MODELS: We've discussed this; it sets the directory for model storage.
OLLAMA_HOME: Sets the home directory for Ollama (default: ~/.ollama).
OLLAMA_KEEP_ALIVE: Sets the duration to keep models loaded in memory (default: 5m).
OLLAMA_TIMEOUT: Sets the timeout for loading models (default: 5m).
OLLAMA_ORIGINS: Comma-separated list of allowed origins for CORS.
OLLAMA_NOPRUNE: If set, prevents automatic removal of unused layers.
OLLAMA_DEBUGLOG: Enables debug logging when set to 'on'.
OLLAMA_VERBOSE: Enables verbose logging when set to 'on'.
OLLAMA_GPU_LAYERS: Number of layers to offload to GPU (depends on available VRAM).
OLLAMA_THREADS: Sets the number of threads to use (default is number of physical CPU cores).
OLLAMA_SKIP_UPDATE_CHECK: Skips the update check on startup if set.
OLLAMA_INSECURE: Allows insecure connections when pulling models if set.
OLLAMA_LOCKFILE: Specifies a custom path for the lockfile.
OLLAMA_LOGFILE: Specifies a custom path for the logfile.

Thanks

Originally created by @wgong on GitHub (Oct 21, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7284 I run Ollama on Ubuntu, where its default home is `/usr/share/ollama`. Recently, I ran out of space on that partition after experimenting with quite a few models. I then modified the `install.sh` script to install Ollama to `/opt/ollama`. This worked when starting Ollama on the terminal by running `ollama serve`; however, when I tried running it as a systemctl service, it failed. Checking the log via `sudo journalctl -u ollama -n 50 --no-pager` showed an error message like "no permission to write id file in /usr/share folder". I'm curious if `/usr/share` is hard-coded somewhere. After creating a symlink for `/usr/share/ollama` to `/opt/ollama` and revising `/etc/systemd/system/ollama.service` to run as root, I was finally able to start the systemctl service. Although it worked for me, I suspect it's a hack. Could you please advise on the correct way to install Ollama to a custom location and run it as a service (not as root)? Claude Pro helped me with the above troubleshooting and workaround. It mentioned that the following environment variables are customizable. Is this correct? ``` OLLAMA_HOST: Specifies the host and port Ollama listens on (default: 127.0.0.1:11434). OLLAMA_MODELS: We've discussed this; it sets the directory for model storage. OLLAMA_HOME: Sets the home directory for Ollama (default: ~/.ollama). OLLAMA_KEEP_ALIVE: Sets the duration to keep models loaded in memory (default: 5m). OLLAMA_TIMEOUT: Sets the timeout for loading models (default: 5m). OLLAMA_ORIGINS: Comma-separated list of allowed origins for CORS. OLLAMA_NOPRUNE: If set, prevents automatic removal of unused layers. OLLAMA_DEBUGLOG: Enables debug logging when set to 'on'. OLLAMA_VERBOSE: Enables verbose logging when set to 'on'. OLLAMA_GPU_LAYERS: Number of layers to offload to GPU (depends on available VRAM). OLLAMA_THREADS: Sets the number of threads to use (default is number of physical CPU cores). OLLAMA_SKIP_UPDATE_CHECK: Skips the update check on startup if set. OLLAMA_INSECURE: Allows insecure connections when pulling models if set. OLLAMA_LOCKFILE: Specifies a custom path for the lockfile. OLLAMA_LOGFILE: Specifies a custom path for the logfile. ``` Thanks
GiteaMirror added the question label 2026-04-12 15:32:19 -05:00
Author
Owner

@rick-github commented on GitHub (Oct 21, 2024):

Set OLLAMA_MODELS=/path/to/a/partition/with/space in the service override config. chown ollama /path/to/a/partition/with/space. ollama will use /usr/share/ollama to store key and history, all of the space consuming model files will be in /path/to/a/partition/with/space.

<!-- gh-comment-id:2427382121 --> @rick-github commented on GitHub (Oct 21, 2024): Set `OLLAMA_MODELS=/path/to/a/partition/with/space` in the service override config. `chown ollama /path/to/a/partition/with/space`. ollama will use `/usr/share/ollama` to store key and history, all of the space consuming model files will be in `/path/to/a/partition/with/space`.
Author
Owner

@wgong commented on GitHub (Oct 22, 2024):

Set OLLAMA_MODELS=/path/to/a/partition/with/space in the service override config. chown ollama /path/to/a/partition/with/space. ollama will use /usr/share/ollama to store key and history, all of the space consuming model files will be in /path/to/a/partition/with/space.

Thank you, will try it out

<!-- gh-comment-id:2428043677 --> @wgong commented on GitHub (Oct 22, 2024): > Set `OLLAMA_MODELS=/path/to/a/partition/with/space` in the service override config. `chown ollama /path/to/a/partition/with/space`. ollama will use `/usr/share/ollama` to store key and history, all of the space consuming model files will be in `/path/to/a/partition/with/space`. Thank you, will try it out
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#4628