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.
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.
To resolve this issue, follow these steps:
-
Create the Necessary Directory:
Ensure that the directory exists by creating it manually:
sudo mkdir -p /usr/share/ollama/.ollama
-
Set Appropriate Ownership:
Assign ownership of the directory to the
ollama
user and group:sudo chown -R ollama:ollama /usr/share/ollama/.ollama
-
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
-
Restart the Ollama Service:
Reload the systemd configuration and restart the service:
sudo systemctl daemon-reload sudo systemctl restart ollama.service
-
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.
For more information and community discussions on this issue, refer to the following resources:
- Permission denied when setting OLLAMA_MODELS in service file
- Error: mkdir permission denied
- I am trying to Create Model File But I am getting permission Denied
By following these steps, you should be able to resolve the "permission denied" error and successfully start the Ollama service.