[GH-ISSUE #8709] Provide a working directory path for all Ollama operations (to avoid permissions issues) #5645

Closed
opened 2026-04-12 16:56:07 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @sikhness on GitHub (Jan 30, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/8709

It would be amazing to be able to have an environment variable where you can set the working directory for all Ollama operations.

Currently, I'm trying to implement Ollama into a system that's designed to have the /usr directory as read-only, but it does have access to some directories such as /tmp. When I extract and run Ollama on the /tmp directory, it fails with a Error: could not create directory mkdir /usr/src/app/.ollama: read-only file system error.

It would be nice to be able to set the /tmp directory as the working directory so Ollama only does write operations from that specified directory as it's root.

Originally created by @sikhness on GitHub (Jan 30, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/8709 It would be amazing to be able to have an environment variable where you can set the working directory for all Ollama operations. Currently, I'm trying to implement Ollama into a system that's designed to have the /usr directory as read-only, but it does have access to some directories such as /tmp. When I extract and run Ollama on the /tmp directory, it fails with a `Error: could not create directory mkdir /usr/src/app/.ollama: read-only file system` error. It would be nice to be able to set the /tmp directory as the working directory so Ollama only does write operations from that specified directory as it's root.
GiteaMirror added the feature request label 2026-04-12 16:56:07 -05:00
Author
Owner

@rick-github commented on GitHub (Jan 30, 2025):

sudo usermod -d /tmp ollama

If you want just a temporary change:

HOME=/tmp ollama serve
<!-- gh-comment-id:2625613128 --> @rick-github commented on GitHub (Jan 30, 2025): ``` sudo usermod -d /tmp ollama ``` If you want just a temporary change: ``` HOME=/tmp ollama serve ```
Author
Owner

@sikhness commented on GitHub (Feb 2, 2025):

@rick-github
Thank you so much, that worked! Since I'm not running it as a service, I used the 2nd command and it worked like a charm.
Is this documented in the documentation? I wasn't able to find that specific environment variable when I was searching.

<!-- gh-comment-id:2629503374 --> @sikhness commented on GitHub (Feb 2, 2025): @rick-github Thank you so much, that worked! Since I'm not running it as a service, I used the 2nd command and it worked like a charm. Is this documented in the documentation? I wasn't able to find that specific environment variable when I was searching.
Author
Owner

@rick-github commented on GitHub (Feb 2, 2025):

HOME is a standard Unix (Linux) environment variable, see man environ. Windows has an analog with %USERPROFILE%. ollama uses the home directory of the user it is running as to figure out where to store data, overriding it allows for redirection.

Note that /tmp is not intended for long term storage, most systems will clean /tmp when a system boots, so if you store models there they will get lost when the system restarts. You might be better off using something like HOME=/var/ollama.

<!-- gh-comment-id:2629562900 --> @rick-github commented on GitHub (Feb 2, 2025): `HOME` is a standard Unix (Linux) environment variable, see `man environ`. Windows has an analog with %USERPROFILE%. ollama uses the home directory of the user it is running as to figure out where to store data, overriding it allows for redirection. Note that `/tmp` is not intended for long term storage, most systems will clean `/tmp` when a system boots, so if you store models there they will get lost when the system restarts. You might be better off using something like `HOME=/var/ollama`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5645