ollama - ✅(Solved) Fix Install script fails on Ubuntu 24.04 : permission denied on /usr/share/ollama [1 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#15940Fetched 2026-05-04 04:58:33
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
commented ×1cross-referenced ×1referenced ×1

The official install script (curl -fsSL https://ollama.com/install.sh | sh) exits successfully but the Ollama service fails to start on Ubuntu 24.04.

Error Message

Actual Result

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

Expected Result

Service running, API responding on :11434

Root Cause

useradd -m -d /usr/share/ollama creates the home directory but permissions aren't explicitly set. On Ubuntu 24.04/Debian, the ollama user can't write to it during service startup.

Proposed Fix

Add after user creation in configure_systemd():

Root Cause

useradd -m -d /usr/share/ollama creates the home directory but permissions aren't explicitly set. On Ubuntu 24.04/Debian, the ollama user can't write to it during service startup.

Fix Action

Workaround

sudo mkdir -p /usr/share/ollama
sudo chown ollama:ollama /usr/share/ollama
sudo systemctl restart ollama

PR fix notes

PR #15941: fix(install.sh): always ensure ollama home directory ownership

Description (problem / solution / changelog)

Closes #15940

What

When the install script runs useradd -r -s /bin/false -U -m -d /usr/share/ollama ollama, the -m flag only creates /usr/share/ollama (and gives it the right ownership) if it does not already exist. On Ubuntu 24.04 / Debian trixie systems where /usr/share/ollama may be pre-created with root ownership (or when the script is re-run with the user already existing — the entire useradd call is skipped by the surrounding if ! id ollama guard), the directory is left owned by root:root with 0755. The systemd service then fails at startup:

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

Fix

After the user-creation block, run

$SUDO install -d -o ollama -g ollama -m 0755 /usr/share/ollama

unconditionally. install -d is idempotent — it creates the directory if missing and applies the requested ownership/mode either way — so this is safe on every code path (fresh install, re-run with existing user, dir pre-created by something else).

Why this approach over the alternatives

  • mkdir -p + chown -R would also work but chown -R could touch large existing model trees the user has placed under /usr/share/ollama, which is undesirable. install -d only acts on the directory itself.
  • Adding Environment="HOME=/usr/share/ollama" to the service unit is unnecessary: systemd already derives HOME from /etc/passwd for User=ollama, so the env var is correct — the only failure is the ownership of the directory itself.
  • Verification via systemctl is-active belongs in a separate change; this PR keeps the scope to the root cause reported in the issue.

Test plan

  • Fresh Ubuntu 24.04 box, /usr/share/ollama does not exist → behavior unchanged from before (useradd creates it; install -d is a no-op for ownership).
  • Box where /usr/share/ollama already exists owned by root:root (the bug repro) → after this patch, ownership flips to ollama:ollama and the service starts cleanly.
  • Re-running the installer (id ollama succeeds, useradd is skipped) → install -d still re-asserts ownership, so a manual chown performed earlier as a workaround keeps working.

🤖 Generated with Claude Code

Changed files

  • scripts/install.sh (modified, +6/-0)

Code Example

## Description
The official install script (`curl -fsSL https://ollama.com/install.sh | sh`) exits successfully but the Ollama service fails to start on Ubuntu 24.04.

## Steps to Reproduce

---

## Actual Result
Service dead with: `Error: could not create directory mkdir /usr/share/ollama: permission denied`

## Expected Result
Service running, API responding on :11434

## Root Cause
`useradd -m -d /usr/share/ollama` creates the home directory but permissions aren't explicitly set. On Ubuntu 24.04/Debian, the ollama user can't write to it during service startup.

## Proposed Fix
Add after user creation in `configure_systemd()`:

---

Add to service file: `Environment="HOME=/usr/share/ollama"`

And verify service started:

---

## Environment
- OS: Ubuntu 24.04.4 LTS / Debian trixie/sid
- Kernel: 6.8.0
- Arch: amd64
- Systemd: 255
- Ollama: 0.22.1

## Workaround

---
RAW_BUFFERClick to expand / collapse
## Description
The official install script (`curl -fsSL https://ollama.com/install.sh | sh`) exits successfully but the Ollama service fails to start on Ubuntu 24.04.

## Steps to Reproduce
```bash
curl -fsSL https://ollama.com/install.sh | sh
systemctl status ollama
```

## Actual Result
Service dead with: `Error: could not create directory mkdir /usr/share/ollama: permission denied`

## Expected Result
Service running, API responding on :11434

## Root Cause
`useradd -m -d /usr/share/ollama` creates the home directory but permissions aren't explicitly set. On Ubuntu 24.04/Debian, the ollama user can't write to it during service startup.

## Proposed Fix
Add after user creation in `configure_systemd()`:
```bash
OLLAMA_HOME="/usr/share/ollama"
$SUDO mkdir -p "$OLLAMA_HOME"
$SUDO chown -R ollama:ollama "$OLLAMA_HOME"
$SUDO chmod 755 "$OLLAMA_HOME"
$SUDO mkdir -p "$OLLAMA_HOME/.ollama"
$SUDO chown ollama:ollama "$OLLAMA_HOME/.ollama"
```

Add to service file: `Environment="HOME=/usr/share/ollama"`

And verify service started:
```bash
sleep 2
systemctl is-active --quiet ollama || error "Service failed"
```

## Environment
- OS: Ubuntu 24.04.4 LTS / Debian trixie/sid
- Kernel: 6.8.0
- Arch: amd64
- Systemd: 255
- Ollama: 0.22.1

## Workaround
```bash
sudo mkdir -p /usr/share/ollama
sudo chown ollama:ollama /usr/share/ollama
sudo systemctl restart ollama
```

extent analysis

TL;DR

Apply the proposed fix by modifying the configure_systemd() function to set proper permissions for the Ollama home directory.

Guidance

  • Verify that the ollama user has the correct permissions by checking the output of ls -l /usr/share/ollama after running the proposed fix.
  • Ensure the Environment="HOME=/usr/share/ollama" line is added to the service file to set the correct home directory for the Ollama service.
  • If the issue persists, try the provided workaround to manually set permissions and restart the service.
  • Check the systemd version and Ollama version for any known issues or incompatibilities.

Example

The proposed fix includes the following code snippet to set permissions:

$SUDO mkdir -p "$OLLAMA_HOME"
$SUDO chown -R ollama:ollama "$OLLAMA_HOME"
$SUDO chmod 755 "$OLLAMA_HOME"

This sets the correct permissions for the Ollama home directory.

Notes

The proposed fix assumes that the issue is specific to Ubuntu 24.04 and Debian, and may not apply to other operating systems or versions.

Recommendation

Apply the workaround by running the provided commands:

sudo mkdir -p /usr/share/ollama
sudo chown ollama:ollama /usr/share/ollama
sudo systemctl restart ollama

This is a safer approach until the proposed fix is fully tested and verified.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - ✅(Solved) Fix Install script fails on Ubuntu 24.04 : permission denied on /usr/share/ollama [1 pull requests, 1 comments, 1 participants]