Skip to content

Instantly share code, notes, and snippets.

@donbr
Created November 25, 2024 22:04
Show Gist options
  • Save donbr/701a70b0ae04607eb36e566ae527712b to your computer and use it in GitHub Desktop.
Save donbr/701a70b0ae04607eb36e566ae527712b to your computer and use it in GitHub Desktop.
Resolving Ollama Service "Permission Denied" Error

FAQ: Resolving Ollama Service "Permission Denied" Error

Issue

When starting the Ollama service, it fails with the following error message:

Error: could not create directory mkdir /usr/share/ollama: permission denied

This indicates that the service lacks the necessary permissions to create or access the required directories.

Cause

The Ollama service runs under the ollama user account. If the directories it needs to access or create (e.g., /usr/share/ollama/.ollama) do not exist or have incorrect permissions, the service will fail to start.

Solution

To resolve this issue, follow these steps:

  1. Create the Necessary Directory:

    Ensure that the directory exists by creating it manually:

    sudo mkdir -p /usr/share/ollama/.ollama
  2. Set Appropriate Ownership:

    Assign ownership of the directory to the ollama user and group:

    sudo chown -R ollama:ollama /usr/share/ollama/.ollama
  3. Verify Permissions:

    Check that the ollama user has the necessary permissions:

    ls -ld /usr/share/ollama/.ollama

    The output should resemble:

    drwxr-xr-x 2 ollama ollama 4096 [date] /usr/share/ollama/.ollama
    
  4. Restart the Ollama Service:

    Reload the systemd configuration and restart the service:

    sudo systemctl daemon-reload
    sudo systemctl restart ollama.service
  5. Check Service Status:

    Confirm that the service is now active:

    systemctl status ollama.service

    The output should indicate that the service is running without errors.

Additional Resources

For more information and community discussions on this issue, refer to the following resources:


By following these steps, you should be able to resolve the "permission denied" error and successfully start the Ollama service.

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