RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Ollama — Installation to Mastery
  6. /Ch. 12
Ollama — Installation to Mastery

12. Ollama as Systemd Service

Chapter 12 of 20 · 20 min
KEY INSIGHT

Systemd manages the lifecycle of the Ollama process. Use override files to change environment variables without modifying the installed service file-updates to Ollama will overwrite the original.

Running Ollama as a systemd service ensures it starts on boot, restarts after failures, and runs under a dedicated user account. This is the recommended approach for server deployments.

Default Service File

On Linux, the install script creates /etc/systemd/system/ollama.service:

[Unit]
Description=Ollama Service
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment=OLLAMA_HOST=127.0.0.1:11434

[Install]
WantedBy=default.target

The service runs as the ollama user, limiting damage if the process is compromised.

Managing the Service

# Start the service
sudo systemctl start ollama

# Stop the service
sudo systemctl stop ollama

# Restart (reload after config changes)
sudo systemctl restart ollama

# Check status
sudo systemctl status ollama

# Enable on boot
sudo systemctl enable ollama

Customizing with Environment Variables

Create an override file to customize the service:

sudo systemctl edit ollama.service

Add custom environment variables:

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_MODELS=/data/ollama/models"
Environment="OLLAMA_NUM_PARALLEL=4"

After editing, reload and restart:

sudo systemctl daemon-reload
sudo systemctl restart ollama

Changing the Model Directory

By default, models are stored in ~/.ollama/models. To use a different location:

sudo systemctl edit ollama.service
[Service]
Environment="OLLAMA_MODELS=/mnt/storage/ollama-models"

Create the directory and set permissions:

sudo mkdir -p /mnt/storage/ollama-models
sudo chown ollama:ollama /mnt/storage/ollama-models
sudo systemctl restart ollama

Viewing Logs

# Recent logs
sudo journalctl -u ollama -n 50

# Follow logs in real-time
sudo journalctl -u ollama -f

# Logs since last boot
sudo journalctl -u ollama -b

Logs show startup messages, request logs, and errors. If the service fails to start, logs usually indicate the cause.

Failure Modes

Common systemd issues:

  • Service starts but fails health check - Check journalctl -u ollama for errors. Often caused by missing GPU drivers.
  • Port already in use - Another process (like a manual ollama serve) is using port 11434. Find and stop it with lsof -i :11434.
  • Permission denied on model directory - The ollama user cannot read the models directory. Check ownership with ls -la.
EXERCISE

Check the current systemd service configuration with systemctl cat ollama, then create an override that changes OLLAMA_HOST to bind on all interfaces.

← Chapter 11
Model Management Automation
Chapter 13 →
Docker Deployment