Skip to content

Instantly share code, notes, and snippets.

@WesleyGoncalves
Last active September 7, 2024 22:29
Show Gist options
  • Save WesleyGoncalves/d7791094f139433c130cb6eb530511a1 to your computer and use it in GitHub Desktop.
Save WesleyGoncalves/d7791094f139433c130cb6eb530511a1 to your computer and use it in GitHub Desktop.
How to change Ollama models location

Ollama Models location

By default the model files are stored:

  • Windows: C:\Users%username%.ollama\models
  • Linux: /usr/share/ollama/.ollama/models
  • macOS: ~/.ollama/models

Move Ollama models on Linux

How to change Ollama models location

  1. Create a symlink in /usr/share/ollama/.ollama/ to point to the folder in the mounted device:

    ln -s /usr/share/ollama/.ollama/models /mnt/<device-hash>/<folder-to-models>/`
  2. Change the ownership of the symlink to the ollama user

    sudo chown -h ollama:ollama /usr/share/ollama/.ollama/models
  3. Create the new directory for the Ollama models

    Create a new directory where you want the Ollama models to be saved. For example, if you want them to be in another device, you can run the command below replacing the <device-name> with the Device name and the <folder-to-models> with a name of the directory.

    cd /mnt/<device-name>
    mkdir <folder-to-models>

    For example,

    cd /mnt/41125476-5abe-4ve3-462f-50avf735h73d/	
    mkdir ollamamodels
  4. Change the ownership of the ollama models directory to your user

    sudo chown $USER:$USER /mnt/<device-hash>/<folder-to-models>/
  5. Change the user in ollama config

    sudo systemctl edit ollama.service

    Edit the file content:

    [Service]
    User=<your-user>
    Group=<your-user>
    Environment="OLLAMA_MODELS=/mnt/<device-hash>/<folder-to-models>/"
    
  6. Restart the service

    sudo systemctl daemon-reload
    sudo systemctl restart ollama
    sudo systemctl status ollama
    
    # on error, run
    sudo journalctl -u ollama.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment