# OpenClaw on Raspberry Pi

Canonical: https://clawdocx.com/docs/getting-started-raspberry-pi
Author: Sam Okafor
Difficulty: BEGINNER
Published: 2026-02-24
Updated: 2026-02-25

> Turn a Raspberry Pi 4 or Pi 5 into a dedicated OpenClaw home server: OS setup, Node.js ARM installation, performance tuning, heat management, and running 24/7.

## Why Raspberry Pi?

A Raspberry Pi makes a surprisingly capable always-on OpenClaw server. It's cheap, silent, uses minimal power (5-15W), and sits on your desk or closet shelf running 24/7. Your data stays local, and there are no monthly server bills.

> **Note**
>
> **Recommended**: Raspberry Pi 5 (4GB+ RAM) or Pi 4 (4GB+ RAM). The Pi 4 with 2GB works but you'll want swap enabled. Pi 3 and older are not recommended — Node.js performance is too limited.

### What You Need

| Item | Notes |
|------|-------|
| **Raspberry Pi 4 or 5** | 4GB RAM recommended (8GB is overkill for OpenClaw) |
| **MicroSD card** | 32GB+ Class 10 / A2 rated |
| **Power supply** | Official USB-C PSU (5V/3A for Pi 4, 5V/5A for Pi 5) |
| **Ethernet cable** | Recommended over WiFi for reliability |
| **Case with fan** | Essential for 24/7 operation — Pi 5 runs hot |
| **Keyboard/monitor** | Only for initial setup (headless after that) |

---

## Step 1: Flash Raspberry Pi OS

1. Download [Raspberry Pi Imager](https://www.raspberrypi.com/software/) on your computer
2. Insert your MicroSD card
3. Open Raspberry Pi Imager:
   - **OS**: Raspberry Pi OS Lite (64-bit) — no desktop needed for a server
   - **Storage**: Your MicroSD card
   - **Settings** (gear icon):
     - Enable SSH
     - Set username: `openclaw`
     - Set password
     - Configure WiFi (optional, Ethernet preferred)
     - Set timezone
4. Click **Write** and wait for it to finish

> **Warning**
>
> Use the **64-bit (arm64)** version of Raspberry Pi OS, not the 32-bit. Node.js and OpenClaw perform significantly better on 64-bit.

---

## Step 2: First Boot and SSH

1. Insert the MicroSD card into your Pi
2. Connect Ethernet and power
3. Wait 1-2 minutes for boot

```bash
# Find your Pi's IP (from your computer)
# Option 1: Check your router's DHCP client list
# Option 2: Use mDNS
ping raspberrypi.local

# SSH in
ssh openclaw@raspberrypi.local
# Or: ssh openclaw@192.168.x.x
```

### Initial System Setup

```bash
# Update everything
sudo apt update && sudo apt full-upgrade -y

# Set a static hostname
sudo hostnamectl set-hostname openclaw-pi

# Expand filesystem (if not auto-expanded)
sudo raspi-config --expand-rootfs

# Reboot to apply changes
sudo reboot
```

---

## Step 3: Optimize for 24/7 Operation

### Reduce SD Card Wear

SD cards have limited write cycles. Minimize unnecessary writes:

```bash
# Reduce swap writes
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf

# Disable swap if you have 4GB+ RAM (optional)
# sudo dphys-swapconfig swapoff
# sudo systemctl disable dphys-swapfile

# Or increase swap for 2GB Pi models
sudo nano /etc/dphys-swapfile
# Set CONF_SWAPSIZE=2048
sudo systemctl restart dphys-swapfile

# Move logs to tmpfs (RAM)
echo 'tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=50m 0 0' | sudo tee -a /etc/fstab
```

> **Note**
>
> For maximum SD card longevity, consider booting from a USB SSD instead of MicroSD. Both Pi 4 and Pi 5 support USB boot natively.

### Thermal Management

```bash
# Check temperature
vcgencmd measure_temp

# Install monitoring
sudo apt install -y lm-sensors

# Target: under 70°C under load
# If consistently over 80°C, improve cooling
```

**Cooling recommendations:**
- Pi 5: Active cooling is **essential** — use the official active cooler or a case with fan
- Pi 4: A heatsink + fan case is strongly recommended for 24/7 use
- Passive cooling alone is not recommended for always-on operation

---

## Step 4: Install Node.js (ARM64)

```bash
# Install Node.js 22 LTS
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs

# Verify
node --version   # v22.x.x
npm --version

# Also install build tools (needed by some npm packages)
sudo apt install -y build-essential
```

---

## Step 5: Install OpenClaw

```bash
# Install globally
npm install -g openclaw

# Run setup
openclaw setup
```

---

## Step 6: systemd Service

```bash
sudo nano /etc/systemd/system/openclaw.service
```

```ini
[Unit]
Description=OpenClaw AI Agent
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=openclaw
WorkingDirectory=/home/openclaw/.openclaw/workspace
ExecStart=/usr/bin/openclaw gateway start --foreground
Restart=always
RestartSec=15
StandardOutput=journal
StandardError=journal
Environment=NODE_ENV=production
# Limit memory to prevent OOM on low-RAM Pis
MemoryMax=512M

[Install]
WantedBy=multi-user.target
```

```bash
sudo systemctl daemon-reload
sudo systemctl enable openclaw
sudo systemctl start openclaw
sudo systemctl status openclaw
```

---

## Performance Tips

### Pi 5 vs Pi 4

| Metric | Pi 4 (4GB) | Pi 5 (4GB) |
|--------|-----------|-----------|
| **Node.js startup** | ~3s | ~1.5s |
| **Agent response overhead** | ~100ms | ~50ms |
| **RAM available for OpenClaw** | ~3 GB | ~3.5 GB |
| **Power consumption** | ~5-7W | ~7-12W |
| **Overall feel** | Capable | Snappy |

### Memory Optimization

```bash
# Check memory usage
free -h

# Disable unnecessary services
sudo systemctl disable bluetooth
sudo systemctl disable avahi-daemon
sudo systemctl disable triggerhappy

# On Pi OS Lite, most services are already minimal
```

---

## Accessing Remotely

### From Your Local Network
```bash
ssh openclaw@openclaw-pi.local
```

### From Outside Your Network

Options:
1. **Tailscale** (recommended) — Zero-config VPN
   ```bash
   curl -fsSL https://tailscale.com/install.sh | sh
   sudo tailscale up
   ```
2. **Port forwarding** — Less secure, configure on your router
3. **Cloudflare Tunnel** — Free, no port forwarding needed

---

## Troubleshooting

### Pi Won't Boot
- Try a different MicroSD card
- Re-flash with Raspberry Pi Imager
- Check power supply — underpowered PSU causes random crashes

### Slow Performance
- Check temperature: `vcgencmd measure_temp`
- Check if throttled: `vcgencmd get_throttled` (0x0 = no throttling)
- Add swap if RAM is low: check with `free -h`

### Network Drops
- Use Ethernet over WiFi for 24/7 operation
- If WiFi required, disable power management:
  ```bash
  sudo iw wlan0 set power_save off
  ```

---

## Next Steps

- [Your First 24 Hours with OpenClaw](/docs/first-24-hours) — Set up SOUL.md and connect Telegram
- [Keeping OpenClaw Running 24/7](/docs/process-management) — Monitoring and auto-restart
- [Security Hardening](/docs/security-hardening) — Secure your Pi server