Skip to content

Running OpenClaw on a Raspberry Pi

Install OpenClaw on a Pi 4 or Pi 5 — 64-bit Raspberry Pi OS Lite, Node 24 ARM64, USB-SSD root, 2 GB swap with low swappiness, why local LLMs are not realistic on a Pi, and the systemd unit that survives a power cycle.

You have a Raspberry Pi 4 or Pi 5 doing very little, you want it to do something genuinely useful, and you want OpenClaw — the personal AI agent (openclaw.ai) — running on it 24/7 as the brain of the house. The Pi is a real ARM64 Linux box, OpenClaw is a Node.js daemon, the install is short. The two things to get right are the storage path (boot off a USB SSD, not an SD card you will replace in six months) and the model strategy (call cloud APIs, do not try to run a 7B local model on 8 GB of RAM that also has to host the agent loop).

Scenario

A Pi 4 with 4 GB or a Pi 5 with 4-8 GB, headless on the home network, USB-SSD as the root volume, on UPS or at least a quality 5V supply. You want the agent reachable from your phone over Tailscale and your laptop on the LAN, surviving power blinks, with a backup target that picks up ~/.openclaw/ regularly. The Pi Zero 2 W is not a target for this — onboarding alone will OOM.

Outcome and prereqs

When this is done you’ll have:

  • 64-bit Raspberry Pi OS Lite with Node 24 from NodeSource ARM64.
  • USB SSD as the root volume, microSD only as a boot fallback (or fully USB-boot with rpi-eeprom updated).
  • A 2 GB swap file with vm.swappiness=10.
  • OpenClaw installed globally, configured to use a cloud LLM provider (Anthropic, OpenAI, or a remote Ollama on a separate GPU host).
  • A user-systemd unit that brings the gateway back after every reboot, with loginctl enable-linger set.
  • Tailscale on the Pi so you reach the agent from anywhere.

Prereqs:

  • Raspberry Pi 4 (2 GB minimum, 4 GB recommended) or Pi 5 (4 GB or 8 GB).
  • A USB 3.0 SSD, even a cheap 240 GB SATA-to-USB enclosure. Anything is faster and more durable than an SD card.
  • 64-bit Raspberry Pi OS Lite (May 2026 or newer). 32-bit OS will not work for Node 24.
  • An LLM provider API key. Skip local-model dreams; the section below explains why.
  • A reasonable 5V/3A power supply (Pi 4) or the official 27 W USB-C PD supply (Pi 5).

Time and resource footprint

About 40 minutes attended, plus another hour of unattended apt upgrade and ssh-key dance. Steady-state RAM sits around 250 MB for the gateway. The Pi 5 is the comfortable target; the Pi 4 works, you just feel it during onboarding and the first few skill installs.

Step 1 — Flash 64-bit Raspberry Pi OS Lite

Use Raspberry Pi Imager. Pick “Raspberry Pi OS Lite (64-bit)”. Open the gear icon and set:

  • Hostname: openclaw-pi
  • Enable SSH with your authorized public key
  • Set a non-pi username, e.g. op
  • Wi-Fi: only as a fallback; Ethernet is what you want for an always-on home box

Flash to the SD card, boot once, log in, confirm:

uname -m
# aarch64

cat /etc/os-release | grep VERSION_ID

If you are using a Pi 5 or recent Pi 4 firmware, you can boot off USB directly. sudo rpi-eeprom-update -a ensures the bootloader is fresh; then clone the SD card to the SSD with rpi-clone and reboot from USB. The Raspberry Pi docs have the canonical USB-boot procedure.

Step 2 — Base packages and time sync

sudo apt update
sudo apt -y full-upgrade
sudo apt -y install \
  curl ca-certificates gnupg build-essential \
  ufw fail2ban unattended-upgrades \
  chrony jq iproute2 lsof zram-tools
sudo systemctl enable --now chrony
sudo timedatectl set-ntp true

build-essential is here because some npm packages fall back to a native build on ARM64. unattended-upgrades is on a Pi where you will not log in for weeks at a time.

Step 3 — Swap and swappiness

Even with 8 GB on a Pi 5 you want a swap file as a safety net during onboarding and first runs. The Raspberry Pi docs recommend at least 2 GB on lower-RAM boards. Disable the default 100 MB dphys-swapfile and add a real one:

sudo dphys-swapfile swapoff
sudo systemctl disable --now dphys-swapfile

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

# Be reluctant to swap — only when memory is genuinely tight
echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/99-swappiness.conf
sudo sysctl -p /etc/sysctl.d/99-swappiness.conf

vm.swappiness=10 (versus the default 60) is the Pi-tuning recommendation in the OpenClaw Pi docs. It keeps memory in RAM as long as physically possible, which matters when the SSD is over USB and writes are expensive relative to a server-class NVMe.

Also free GPU memory; you do not need the framebuffer on a headless agent host:

echo "gpu_mem=16" | sudo tee -a /boot/firmware/config.txt

Reboot once after the swap changes to confirm free -h shows the new swap size.

Step 4 — Install Node 24

Use NodeSource. They publish prebuilt ARM64 binaries for Debian/Raspberry Pi OS, so you do not pay the cost of compiling Node itself.

curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-mark hold nodejs

node --version    # v24.x.x
npm --version

apt-mark hold nodejs is the cheap insurance — you do not want an unattended-upgrade run to bump Node mid-week and break the daemon. You will deliberately unhold, upgrade, and verify when you choose to.

Step 5 — Install OpenClaw

The one-liner installs Node-toolchain probes and prepares ~/.openclaw/. If you already installed Node above, npm directly is fine:

curl -fsSL https://openclaw.ai/install.sh | bash
sudo npm i -g openclaw
openclaw --version

If npm complains about EACCES on the global prefix, prefer a user-owned prefix to sudo npm:

mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
npm i -g openclaw

Step 6 — Onboard with a cloud LLM, not a local one

openclaw onboard --install-daemon

Pick anthropic/claude-sonnet-4-5 or openai/gpt-5-mini. Paste the API key. Accept the daemon install — onboarding writes a user-systemd unit for you.

Why not local LLM on the Pi: even the Pi 5’s 8 GB is split between the agent runtime (Node, V8 heap, channel workers, browser automation if any) and the model. Loading a 7B-quantized model leaves a few hundred MB for everything else, the agent OOMs the moment a long context lands, and inference latency is in the 30-60 second range per turn anyway. The OpenClaw Pi docs are explicit: do not run local LLMs on a Pi. If you want the privacy story without the latency story, point the Pi at a separate Ollama box on the LAN — that is a perfectly reasonable architecture and the openclaw.json config is the same as any other remote provider.

Lock the env:

chmod 600 ~/.openclaw/.env

Step 7 — Foreground first run

openclaw gateway --port 18789 --verbose

You should see the listener bind on 127.0.0.1:18789. In another SSH session:

openclaw agent --message "What is my Pi model and kernel?" --thinking high

The agent should run cat /proc/cpuinfo | grep Model (or cat /sys/firmware/devicetree/base/model) and uname -a, then summarize. Ctrl-C the gateway — the systemd unit comes next.

Step 8 — User-systemd unit

If openclaw onboard --install-daemon already created ~/.config/systemd/user/openclaw.service, verify it. Otherwise write it:

[Unit]
Description=OpenClaw personal AI agent gateway
Documentation=https://openclaw.ai
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=%h/.npm-global/bin/openclaw gateway --port 18789
Restart=on-failure
RestartSec=5

EnvironmentFile=%h/.openclaw/.env

# Speed up cold starts on a slow USB SSD
Environment="NODE_COMPILE_CACHE=%h/.cache/openclaw-compile-cache"

# Hardening
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=read-only
ReadWritePaths=%h/.openclaw %h/.cache/openclaw-compile-cache
PrivateTmp=true

# Be a good neighbor on a small box
MemoryMax=1500M
TasksMax=512
Nice=5

StandardOutput=journal
StandardError=journal
SyslogIdentifier=openclaw

[Install]
WantedBy=default.target

Adjust ExecStart to whichever path which openclaw returns. NODE_COMPILE_CACHE is the documented Node feature that caches the V8 code cache to disk; on a USB-SSD-backed Pi it noticeably cuts cold-start times.

Reload, enable, start:

mkdir -p ~/.cache/openclaw-compile-cache
systemctl --user daemon-reload
systemctl --user enable --now openclaw.service
systemctl --user status openclaw.service

Make sure the agent survives logout (you log into the Pi over SSH, you do not stay logged in):

sudo loginctl enable-linger "$USER"
loginctl show-user "$USER" | grep Linger
# Linger=yes

enable-linger is the supported pattern documented in loginctl(1) for keeping user services alive without an interactive session.

Step 9 — Tailscale (so you reach the Pi from anywhere)

curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up --hostname=openclaw-pi --ssh --accept-routes
tailscale status

The Pi joins your tailnet with a 100.x.y.z address. The full Tailscale setup, ACLs that restrict the OpenClaw port to your own devices, and MagicDNS are covered in Accessing OpenClaw across devices with Tailscale.

Verification

openclaw doctor

Expect a green gateway, healthy model, paired channels (if any). Confirm the listener:

ss -lntp 'sport = :18789'
# LISTEN 0  511  127.0.0.1:18789  0.0.0.0:*  users:(("node",pid=####,fd=##))

Tail the journal:

journalctl --user -u openclaw -f

Kill the PID, watch systemd respawn it within five seconds. Pull the power, plug it back in, watch the gateway come up after network-online.target.

A real-world smoke test:

openclaw agent --message "Show the top 5 processes by RSS, then tell me if any are runaway"

The agent should run ps aux --sort=-rss | head -6, interpret, and answer.

Rollback

systemctl --user disable --now openclaw.service
rm ~/.config/systemd/user/openclaw.service
systemctl --user daemon-reload
sudo apt-mark unhold nodejs
sudo apt-get remove -y nodejs
mv ~/.openclaw ~/.openclaw.disabled.$(date +%F)

To go back to a stock Pi, sudo apt purge unattended-upgrades chrony fail2ban and re-image the SD card. Keep the archived ~/.openclaw.disabled.<date> if you may come back.

Troubleshooting

apt full-upgrade runs out of memory mid-install. Run it with --no-install-recommends and one batch at a time, or temporarily double the swap (swapon a second /swapfile2) and remove it after the upgrade.

Node install pulls in an old version. nodejs in the Raspberry Pi OS default repo is stale. The setup_24.x script from NodeSource is the canonical source. If you used the default repo by accident, sudo apt remove -y nodejs && curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash - to switch.

Service starts then dies; journal shows JavaScript heap out of memory. Onboarding loaded a memory engine the Pi cannot afford. Either move to a Pi 5 8 GB, or in openclaw.json disable the heavier memory engines (LanceDB embeddings, in particular). The OpenClaw memory docs cover the trade-off.

systemctl --user fails with “Failed to connect to bus” over SSH. sudo loginctl enable-linger "$USER", then reconnect. echo $XDG_RUNTIME_DIR should be /run/user/<uid>.

Browser automation skills fail with chromium-browser not found. Playwright’s bundled Chromium has ARM64 builds, but npx playwright install chromium must be run as the same user the daemon runs as. SSH in as that user (not sudo) and re-run.

Disk I/O is saturated; SD-card-bottlenecked Pi. You are still on the SD card. Move root to the USB SSD per Step 1; check iostat -x 5 to confirm SDA (or NVMe) handles writes, not mmcblk0.

The agent is genuinely slow. Confirm it is not the model provider — time openclaw agent --message "Hello" from the Pi vs. from your laptop tells you where the latency lives. Pi-side overhead is small; cloud LLM latency is what you will most often see.

Production-readiness

For a Pi serving as a permanent home-server agent, “production” means:

  • USB SSD as root, SD card kept around only as a recovery boot.
  • UPS or a battery-backed power supply — sudden power loss with the agent mid-write is the single most common cause of state corruption on a Pi.
  • ~/.openclaw/ backed up off-Pi (rsync to a NAS or restic to a remote repo, weekly minimum).
  • apt-mark hold nodejs plus a quarterly manual Node upgrade with verification.
  • openclaw doctor weekly via cron; output emailed to you on failure.
  • Tailscale ACL limits the Pi’s exposed port to your own tailnet devices.

For organizations that want a managed home-base OpenClaw on a Pi or a small NUC, with patch cadence and remote support, talk to a senior operator at Stack Harbor about your self-hosted OpenClaw setup.

Sources

  • OpenClaw home page and install one-liner — https://openclaw.ai.
  • OpenClaw README and Raspberry Pi notes — https://github.com/openclaw/openclaw.
  • Raspberry Pi documentation, USB boot and SSD migration — https://www.raspberrypi.com/documentation/computers/raspberry-pi.html.
  • NodeSource Node.js distributions — https://github.com/nodesource/distributions.
  • systemd.service(5), systemd.exec(5), loginctl(1) man pages.
  • Node.js compile cache documentation — https://nodejs.org/api/cli.html#node_compile_cachedir.

Last verified on OpenClaw current (May 2026).