[GH-ISSUE #9597] OLLAMA_HOME Not Respected After Moving .ollama Folder to Another Drive (checked for Windows) #6260

Closed
opened 2026-04-12 17:41:22 -05:00 by GiteaMirror · 9 comments
Owner

Originally created by @PrabhatDongare on GitHub (Mar 8, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9597

I attempted to move the .ollama models folder to a different drive to save space on C: and updated the OLLAMA_HOME environment variable accordingly. However, Ollama does not detect the models in the new location and instead tries to re-download them at the original location,
Additionally, manually moving .ollama back to its original location (C:\Users\YourUsername.ollama) makes Ollama detect models again, indicating that it is not properly using the OLLAMA_HOME path.

Expected Behavior:

  • Ollama should use the models from the directory specified in OLLAMA_HOME.
  • No re-downloading should be necessary if the models already exist in the new location.

Actual Behavior:

  • Even after setting OLLAMA_HOME, Ollama does not detect the moved models and tries to re-download them.
  • Moving the .ollama folder back to its original place makes Ollama work again.
Originally created by @PrabhatDongare on GitHub (Mar 8, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9597 I attempted to move the .ollama models folder to a different drive to save space on C: and updated the OLLAMA_HOME environment variable accordingly. However, Ollama does not detect the models in the new location and instead tries to re-download them at the original location, Additionally, manually moving .ollama back to its original location (C:\Users\YourUsername\.ollama) makes Ollama detect models again, indicating that it is not properly using the OLLAMA_HOME path. Expected Behavior: - Ollama should use the models from the directory specified in OLLAMA_HOME. - No re-downloading should be necessary if the models already exist in the new location. Actual Behavior: - Even after setting OLLAMA_HOME, Ollama does not detect the moved models and tries to re-download them. - Moving the .ollama folder back to its original place makes Ollama work again.
Author
Owner

@rick-github commented on GitHub (Mar 8, 2025):

OLLAMA_HOME is not an ollama configuration variable. The model location can be specified with OLLAMA_MODELS.

<!-- gh-comment-id:2708351300 --> @rick-github commented on GitHub (Mar 8, 2025): OLLAMA_HOME is not an ollama configuration variable. The model location can be specified with [`OLLAMA_MODELS`](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-set-them-to-a-different-location).
Author
Owner

@brccabral commented on GitHub (Mar 11, 2025):

OLLAMA_MODELS also has problems...

I have mounted my external SSD at /media/brccabral/BrunoT7ext4.
I have created a directory /media/brccabral/BrunoT7ext4/ollama and given permission chown ollama:ollama.
I have edited the service with sudo systemctl edit ollama, but it failed to start.
journalctl shows this error message Error: mkdir /media/brccabral/BrunoT7ext4: permission denied.
I tried to run manually and same error Error: mkdir /media/brccabral/BrunoT7ext4: permission denied.

Why is it trying to create the upper directory? Should it be mkdir -p $OLLAMA_MODELS instead?

sudo -u ollama OLLAMA_MODELS=/media/brccabral/BrunoT7ext4/ollama/models ollama serve
2025/03/11 00:44:12 routes.go:1215: INFO server config env="map[CUDA_VISIBLE_DEVICES: GPU_DEVICE_ORDINAL: HIP_VISIBLE_DEVICES: HSA_OVERRIDE_GFX_VERSION: HTTPS_PROXY: HTTP_PROXY: NO_PROXY: OLLAMA_CONTEXT_LENGTH:2048 OLLAMA_DEBUG:false OLLAMA_FLASH_ATTENTION:false OLLAMA_GPU_OVERHEAD:0 OLLAMA_HOST:http://127.0.0.1:11434 OLLAMA_INTEL_GPU:false OLLAMA_KEEP_ALIVE:5m0s OLLAMA_KV_CACHE_TYPE: OLLAMA_LLM_LIBRARY: OLLAMA_LOAD_TIMEOUT:5m0s OLLAMA_MAX_LOADED_MODELS:0 OLLAMA_MAX_QUEUE:512 OLLAMA_MODELS:/media/brccabral/BrunoT7ext4/ollama/models OLLAMA_MULTIUSER_CACHE:false OLLAMA_NEW_ENGINE:false OLLAMA_NOHISTORY:false OLLAMA_NOPRUNE:false OLLAMA_NUM_PARALLEL:0 OLLAMA_ORIGINS:[http://localhost https://localhost http://localhost:* https://localhost:* http://127.0.0.1 https://127.0.0.1 http://127.0.0.1:* https://127.0.0.1:* http://0.0.0.0 https://0.0.0.0 http://0.0.0.0:* https://0.0.0.0:* app://* file://* tauri://* vscode-webview://* vscode-file://*] OLLAMA_SCHED_SPREAD:false ROCR_VISIBLE_DEVICES: http_proxy: https_proxy: no_proxy:]"
Error: mkdir /media/brccabral/BrunoT7ext4: permission denied
<!-- gh-comment-id:2713058115 --> @brccabral commented on GitHub (Mar 11, 2025): `OLLAMA_MODELS` also has problems... I have mounted my external SSD at `/media/brccabral/BrunoT7ext4`. I have created a directory `/media/brccabral/BrunoT7ext4/ollama` and given permission `chown ollama:ollama`. I have edited the service with `sudo systemctl edit ollama`, but it failed to start. `journalctl` shows this error message `Error: mkdir /media/brccabral/BrunoT7ext4: permission denied`. I tried to run manually and same error `Error: mkdir /media/brccabral/BrunoT7ext4: permission denied`. Why is it trying to create the upper directory? Should it be `mkdir -p $OLLAMA_MODELS` instead? ```sh sudo -u ollama OLLAMA_MODELS=/media/brccabral/BrunoT7ext4/ollama/models ollama serve ``` ``` 2025/03/11 00:44:12 routes.go:1215: INFO server config env="map[CUDA_VISIBLE_DEVICES: GPU_DEVICE_ORDINAL: HIP_VISIBLE_DEVICES: HSA_OVERRIDE_GFX_VERSION: HTTPS_PROXY: HTTP_PROXY: NO_PROXY: OLLAMA_CONTEXT_LENGTH:2048 OLLAMA_DEBUG:false OLLAMA_FLASH_ATTENTION:false OLLAMA_GPU_OVERHEAD:0 OLLAMA_HOST:http://127.0.0.1:11434 OLLAMA_INTEL_GPU:false OLLAMA_KEEP_ALIVE:5m0s OLLAMA_KV_CACHE_TYPE: OLLAMA_LLM_LIBRARY: OLLAMA_LOAD_TIMEOUT:5m0s OLLAMA_MAX_LOADED_MODELS:0 OLLAMA_MAX_QUEUE:512 OLLAMA_MODELS:/media/brccabral/BrunoT7ext4/ollama/models OLLAMA_MULTIUSER_CACHE:false OLLAMA_NEW_ENGINE:false OLLAMA_NOHISTORY:false OLLAMA_NOPRUNE:false OLLAMA_NUM_PARALLEL:0 OLLAMA_ORIGINS:[http://localhost https://localhost http://localhost:* https://localhost:* http://127.0.0.1 https://127.0.0.1 http://127.0.0.1:* https://127.0.0.1:* http://0.0.0.0 https://0.0.0.0 http://0.0.0.0:* https://0.0.0.0:* app://* file://* tauri://* vscode-webview://* vscode-file://*] OLLAMA_SCHED_SPREAD:false ROCR_VISIBLE_DEVICES: http_proxy: https_proxy: no_proxy:]" Error: mkdir /media/brccabral/BrunoT7ext4: permission denied ```
Author
Owner

@rick-github commented on GitHub (Mar 11, 2025):

chmod o+x /media/brccabral
<!-- gh-comment-id:2713066826 --> @rick-github commented on GitHub (Mar 11, 2025): ``` chmod o+x /media/brccabral ```
Author
Owner

@brccabral commented on GitHub (Mar 11, 2025):

chmod o+x /media/brccabral

It already has permission it needs, no need to have permission on parent folder

<!-- gh-comment-id:2715119658 --> @brccabral commented on GitHub (Mar 11, 2025): > ``` > chmod o+x /media/brccabral > ``` It already has permission it needs, no need to have permission on parent folder
Author
Owner

@rick-github commented on GitHub (Mar 11, 2025):

ollama runs as user ollama. You have specified OLLAMA_MODELS=/media/brccabral/BrunoT7ext4/ollama/models in the config file. The ollama user needs to have at least directory access permission in order to traverse the path to reach the models directory. If you don't want to grant ollama permission to read directories, you can mount the model directory in /usr/share/ollama/.ollama/models using BindPath.

<!-- gh-comment-id:2715197042 --> @rick-github commented on GitHub (Mar 11, 2025): ollama runs as user ollama. You have specified `OLLAMA_MODELS=/media/brccabral/BrunoT7ext4/ollama/models` in the config file. The ollama user needs to have at least directory access permission in order to traverse the path to reach the models directory. If you don't want to grant ollama permission to read directories, you can mount the model directory in `/usr/share/ollama/.ollama/models` using [`BindPath`](https://github.com/ollama/ollama/issues/8512#issuecomment-2605177997).
Author
Owner

@brccabral commented on GitHub (Mar 11, 2025):

It needs to traverse the path because it is using MkdirAll all the time, even if the folder already exists. If the folder already exists, the code should not call MkdirAll. I have sent PR #9645

<!-- gh-comment-id:2715269605 --> @brccabral commented on GitHub (Mar 11, 2025): It needs to traverse the path because it is using `MkdirAll` all the time, even if the folder already exists. If the folder already exists, the code should not call `MkdirAll`. I have sent PR [#9645](https://github.com/ollama/ollama/pull/9645)
Author
Owner

@rick-github commented on GitHub (Mar 11, 2025):

It can't tell if the path exists because it can't access the directory due to lack of permissions.

<!-- gh-comment-id:2715279447 --> @rick-github commented on GitHub (Mar 11, 2025): It can't tell if the path exists because it can't access the directory due to lack of permissions.
Author
Owner

@brccabral commented on GitHub (Mar 11, 2025):

OK, I didn't know about x permission. Sorry.
I ended up creating a new group.

<!-- gh-comment-id:2715446575 --> @brccabral commented on GitHub (Mar 11, 2025): OK, I didn't know about `x` permission. Sorry. I ended up creating a new group.
Author
Owner

@pdevine commented on GitHub (Mar 12, 2025):

I'll go ahead and close the issue as answered (thanks @rick-github !)

<!-- gh-comment-id:2716156327 --> @pdevine commented on GitHub (Mar 12, 2025): I'll go ahead and close the issue as answered (thanks @rick-github !)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#6260