Skip to content

Instantly share code, notes, and snippets.

@duonghuuphuc
Created January 27, 2025 04:13
Show Gist options
  • Select an option

  • Save duonghuuphuc/8339df20b2efcb55bb41941b896a5d8d to your computer and use it in GitHub Desktop.

Select an option

Save duonghuuphuc/8339df20b2efcb55bb41941b896a5d8d to your computer and use it in GitHub Desktop.
Change Ollama Model Directory

[macOS] Change Ollama Model Directory

By default, all models pulled from Ollama are stored in the /Users/username/.ollama directory on macOS, where username is your system's current user. If you want to change the model directory to another location, such as an external storage device, you can follow one of the methods below.


Method 1: Temporarily Change the Model Directory

If you only want to change the model directory temporarily, execute the following command in Terminal and restart the Ollama app:

launchctl setenv OLLAMA_MODELS /path/to/new/location

For example, to change the model directory to an external storage device located at /Volumes/PSSD/Ollama-Models, run:

launchctl setenv OLLAMA_MODELS /Volumes/PSSD/Ollama-Models

Method 2: Permanently Change the Model Directory

Starting from macOS 15 and later, adding the OLLAMA_MODELS variable to the system environment (such as .zshrc, .zshenv, or .zprofile) no longer works. To achieve a permanent solution, you can use the symbolic link (symlink) technique. Symbolic links act as advanced aliases (shortcuts) that redirect access to your original files, allowing you to store large files on an external drive without breaking application support.

Steps to Create a Symbolic Link

The general syntax for creating a symbolic link is:

ln -s /path/to/new /path/to/original

In our case, you need to run the following two commands to map the manifests and blobs directories:

ln -s /Volumes/PSSD/Ollama-Models/blobs /Users/username/.ollama/models/blobs
ln -s /Volumes/PSSD/Ollama-Models/manifests /Users/username/.ollama/models/manifests

Important Notes:

  • Before running these commands, ensure that any existing directories in /Users/username/.ollama/ are removed to avoid conflicts.
  • After executing the commands, two new alias directories will appear in /Users/username/.ollama/, identified by an icon with a small arrow in the bottom-left corner.

Following these methods, you can efficiently relocate your Ollama models to free up disk space or better organize your storage.

@marcusthomas19
Copy link

For the symbolic links, the last argument should be the models folder itself rather than the blobs and manifests folders.

ln -s /Volumes/PSSD/Ollama-Models/blobs /Users/username/.ollama/models
ln -s /Volumes/PSSD/Ollama-Models/manifests /Users/username/.ollama/models

Since we're advised to delete all the directories in .ollama, the suggested targets in the example do not exist.
In my case, targeting the models folder directly was what allowed it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment