Home Tutorials Categories Skills About
ZH EN JA KO
Installation

Installing and Running OpenClaw on Raspberry Pi

· 17 min read

Introduction

The Raspberry Pi is an affordable choice for running OpenClaw — low power consumption, compact size, and capable of running 24/7 without breaking a sweat. This article walks you through deploying OpenClaw on a Raspberry Pi 4 or Raspberry Pi 5, giving you a dedicated AI assistant server.

Hardware Requirements

Model Experience Notes
Raspberry Pi 5 (8GB) Smooth Recommended model, plenty of performance
Raspberry Pi 5 (4GB) Good Meets basic needs
Raspberry Pi 4 (8GB) Good Best value for money
Raspberry Pi 4 (4GB) Adequate Consider disabling unnecessary services
Raspberry Pi 4 (2GB) Marginal Not recommended, memory will be tight

Additional Accessories

  • MicroSD card: at least 16GB, recommended 32GB Class 10 or higher
  • Power adapter: Raspberry Pi 5 requires 5V/5A USB-C, Raspberry Pi 4 requires 5V/3A USB-C
  • Heatsink or fan (recommended for keeping temperatures down during prolonged operation)
  • Ethernet cable or Wi-Fi connection

Step 1: Prepare the Operating System

Flash the System Image

We recommend Raspberry Pi OS Lite (64-bit), since OpenClaw doesn't require a graphical interface.

  1. Download Raspberry Pi Imager

  2. Insert the MicroSD card

  3. Select the OS: Raspberry Pi OS Lite (64-bit)

  4. In the advanced settings, configure:

    • Hostname (e.g., openclaw)
    • SSH access (enable and set a password or key)
    • Wi-Fi credentials (if not using Ethernet)
    • Timezone and locale
  5. Click "Write" to flash the image

First Boot and Connection

Insert the MicroSD card into the Raspberry Pi and power it on. After about 1 minute, connect via SSH:

ssh [email protected]
# Or use the IP address
ssh [email protected]

System Update

sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js 22 (ARM)

The Raspberry Pi uses an ARM architecture processor, so you need the ARM version of Node.js.

Option A: Using the NodeSource Repository (Recommended)

# Add the NodeSource repository
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -

# Install Node.js
sudo apt install -y nodejs

# Verify the installation
node --version
npm --version

Option B: Using nvm

# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc

# Install Node.js 22
nvm install 22
nvm alias default 22

# Verify
node --version

Verify Architecture

Confirm that Node.js is running under the ARM64 architecture:

node -e "console.log(process.arch)"
# Should output: arm64

Step 3: Install OpenClaw

sudo npm install -g openclaw@latest

Verify the installation:

openclaw --version

Step 4: Initial Configuration

openclaw onboard

Complete the model and channel setup in the configuration wizard. Since the Raspberry Pi has limited resources, here are some recommendations:

  • Model selection: Cloud-based APIs (Claude, OpenAI, Gemini) are recommended over local models
  • Number of channels: Don't connect too many channels at once initially; add more gradually based on actual load
  • Log level: Setting it to warn is recommended to reduce disk writes

Configuration file location:

~/.config/openclaw/openclaw.json5

Step 5: Start and Test

openclaw up

Run diagnostics to confirm everything is working:

openclaw doctor

Step 6: Configure systemd for Auto-Start

Using systemd to manage the OpenClaw service on Raspberry Pi is the best practice.

Create the systemd Service File

sudo tee /etc/systemd/system/openclaw.service > /dev/null << 'EOF'
[Unit]
Description=OpenClaw AI Assistant Platform
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi
ExecStart=/usr/bin/openclaw up
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
Environment=NODE_ENV=production

# Resource limits (optional)
MemoryMax=1G
CPUQuota=80%

[Install]
WantedBy=multi-user.target
EOF

If you installed Node.js via nvm, you'll need to update the ExecStart path to the full path:

# Find the actual path of openclaw
which openclaw
# Example: /home/pi/.nvm/versions/node/v22.x.x/bin/openclaw

Enable and Start the Service

# Reload systemd configuration
sudo systemctl daemon-reload

# Enable auto-start on boot
sudo systemctl enable openclaw

# Start the service
sudo systemctl start openclaw

# Check status
sudo systemctl status openclaw

View Logs

# View logs in real time
sudo journalctl -u openclaw -f

# View the last 100 lines
sudo journalctl -u openclaw -n 100

Performance Optimization

Reduce Memory Usage

Edit /etc/systemd/system/openclaw.service and add Node.js memory parameters to ExecStart:

ExecStart=/usr/bin/node --max-old-space-size=512 /usr/bin/openclaw up

Expand Memory with Swap

If memory is insufficient, you can increase swap space:

# Disable default swap
sudo dphys-swapfile swapoff

# Set swap size to 1GB
sudo sed -i 's/CONF_SWAPSIZE=.*/CONF_SWAPSIZE=1024/' /etc/dphys-swapfile

# Reinitialize and enable
sudo dphys-swapfile setup
sudo dphys-swapfile swapon

# Verify
free -h

Reduce SD Card Writes

Frequent writes can shorten SD card lifespan. Consider the following:

# Mount temporary file directories to RAM
echo 'tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,size=100m 0 0' | sudo tee -a /etc/fstab

# Reduce log write frequency
sudo sed -i 's/#Storage=auto/Storage=volatile/' /etc/systemd/journald.conf
sudo sed -i 's/#RuntimeMaxUse=/RuntimeMaxUse=50M/' /etc/systemd/journald.conf
sudo systemctl restart systemd-journald

Disable Unnecessary Services

# Disable Bluetooth (if not needed)
sudo systemctl disable bluetooth
sudo systemctl stop bluetooth

# Disable avahi (if .local domain resolution is not needed)
sudo systemctl disable avahi-daemon
sudo systemctl stop avahi-daemon

Temperature Monitoring

For long-running operations, it's a good idea to monitor CPU temperature:

# Check current temperature
vcgencmd measure_temp

# Set up a monitoring script
cat > ~/check_temp.sh << 'SCRIPT'
#!/bin/bash
TEMP=$(vcgencmd measure_temp | grep -oP '\d+\.\d+')
if (( $(echo "$TEMP > 75" | bc -l) )); then
    echo "[WARNING] CPU temperature too high: ${TEMP}°C"
fi
SCRIPT
chmod +x ~/check_temp.sh

# Add to crontab, check every 5 minutes
(crontab -l 2>/dev/null; echo "*/5 * * * * ~/check_temp.sh >> ~/temp.log") | crontab -

If the temperature remains high (above 70°C), install a heatsink and fan.

Headless Operation Tips

The Raspberry Pi typically runs in headless mode (without a monitor). Here are some useful tips:

Manage Sessions with tmux

# Install tmux
sudo apt install -y tmux

# Create a dedicated OpenClaw session
tmux new-session -d -s openclaw 'openclaw up'

# Attach to the session to view output
tmux attach -t openclaw

# Detach from the session (Ctrl+B then press D)

Configure a Static IP

Add the following to /etc/dhcpcd.conf:

interface eth0
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8 8.8.4.4

Then restart networking:

sudo systemctl restart dhcpcd

Troubleshooting

Issue Solution
npm install reports out of memory Increase swap to 1GB or more
Crashes immediately after starting Check logs with journalctl -u openclaw
Network connection timeout Check DNS settings and firewall
SD card is read-only File system corruption, try fsck to repair
CPU temperature too high Install a heatsink, lower CPUQuota

Summary

The Raspberry Pi is an excellent choice for running OpenClaw — low power, low cost, and capable of stable 24/7 operation. With systemd auto-start and appropriate performance tuning, your Raspberry Pi AI assistant server can work reliably for the long haul. We recommend the Raspberry Pi 5 (8GB) for the best experience.

OpenClaw is a free, open-source personal AI assistant that supports WhatsApp, Telegram, Discord, and many more platforms