til

Moving Ollama Models to a Different Disk

I’m running Ollama on a Macbook so shifting the default location that Ollama downloads massive models to is a necessity. It’s just one environment setting away.

By default, Ollama stores its models in ~/.ollama/models on macOS. If you need to store models on a different disk or location (for example, on an external drive with more space), you can configure this using the OLLAMA_MODELS environment variable.

Because even the small models get big, fast:

1
2
3
% ollama list
NAME           ID              SIZE      MODIFIED
llama3.2:3b    a80c4f17acd5    2.0 GB    20 minutes ago

Temporary Configuration (Current Session Only)

To set the location for your current terminal session:

1
export OLLAMA_MODELS=/path/to/your/models

This will only last until you close the terminal window.

Permanent Configuration

To make the change permanent, add the environment variable to your shell profile:

For Zsh (default on macOS Catalina and later):

1
2
echo 'export OLLAMA_MODELS=/path/to/your/models' >> ~/.zshrc
source ~/.zshrc

Replace /path/to/your/models with your desired location, such as /Volumes/ExternalDrive/ollama/models. On my machine it’s /Volumes/Fast/ollama/models because my external disk is also, you know, fast!!!

Restarting Ollama

After setting the environment variable, restart Ollama for the changes to take effect:

1
2
3
4
5
# Stop any running Ollama processes
pkill ollama

# Start Ollama again
ollama serve

Ollama startup showing the new location

Moving Existing Models

If you’ve already downloaded models and want to move them to the new location:

  1. Stop Ollama:

    1
    
    pkill ollama
    
  2. Copy your existing models:

    1
    
    cp -r ~/.ollama/models /path/to/your/models
    
  3. Set the environment variable (as described above)

  4. Restart Ollama:

    1
    
    ollama serve
    
  5. Verify the models are accessible:

    1
    
    ollama list
    

Verifying Your Configuration

To confirm that Ollama is using your custom location:

1
echo $OLLAMA_MODELS

This should display your configured path. You can also check that models are being stored in the new location by running a model and then checking the directory contents.

Troubleshooting

Models not appearing after restart:

  • Ensure the OLLAMA_MODELS path exists and has proper read/write permissions
  • Check that the environment variable is set: echo $OLLAMA_MODELS
  • Make sure you’ve sourced your shell profile or opened a new terminal window
    • This is so obvious it’s not worth mentioning…except that I forgot this and finally realized why things weren’t working :-\

Permission denied errors:

  • Ensure your user has read/write permissions to the target directory:
    1
    
    chmod -R 755 /path/to/your/models
    

Additional Resources


See Also

View page source