A fun weekend project exploring how to run a personal AI agent in the background on an old M1 MacBook Air without draining the battery.
Recently, I decided to play around with the [OpenClaw AI agent](https://openclaw.ai) and see if I could get it running 24/7 on my trusty fanless M1 MacBook Air. Instead of just running it normally, I wanted to treat this as a learning experience to dive deeper into macOS internals—figuring out how to keep the agent out of the way, prevent it from eating up all my space, and having it run quietly in the background.
Here’s a look at what I learned and how I threw this setup together!
## 1. The Game Plan
Since this is my personal laptop with a 256GB SSD, I couldn’t just let the AI run wild:
* **Storage Limits:** I wanted to learn about APFS, so I decided to restrict OpenClaw to a 30GB volume just for fun.
* **User Separation:** To learn more about user permissions, I made a separate standard `openclaw` macOS user to see how hard it would be to run standard apps as another user.
* **Background Tasks:** I’ve never really messed with macOS background services, so I wanted to try making a `LaunchDaemon` so it starts up when the computer boots.
—
## 2. Setting up a Sandbox for the AI
I started by making a separate user and trying out creating a dedicated storage layer.
### Making the User
I popped open the terminal on my main account to create a non-admin user:
“`bash
# Create standard user (non-admin)
sudo sysadminctl -addUser openclaw -fullName “OpenClaw Service” -password “YOUR_SECURE_PASSWORD” -admin 0 -shell /bin/zsh
# Ensure the user is completely stripped of admin group rights
sudo dseditgroup -o edit -d openclaw -t user admin
“`
### Creating an APFS Volume
I learned that macOS APFS doesn’t use the old BSD `edquota` commands. The new way is to make an APFS volume with a quota, which I thought was pretty neat:
“`bash
# Provide exactly 30GB to the AI
sudo diskutil apfs addVolume disk3 APFS “OpenClawData” -quota 30g
# Hand ownership to the new openclaw user
sudo chown openclaw:staff /Volumes/OpenClawData
sudo chmod 750 /Volumes/OpenClawData
“`
### Keeping the Mac Awake
Since I wanted this open 24/7, I had to stop the Mac from sleeping.
“`bash
# Prevent all system sleep mechanisms entirely
sudo pmset -a disablesleep 1 sleep 0 hibernatemode 0
“`
> **Side note on battery health:** Since it’s plugged in all the time, I grabbed [AlDente](https://apphousekitchen.com/) to lock the charge at 70% so I don’t ruin the battery.
—
## 3. Getting it Installed
First up was installing the global stuff like OpenClaw on my main account:
“`bash
# As the admin user
npm install -g openclaw@latest
“`
Next, I switched to the new user I made. I noticed the OpenClaw wizard gets confused if it needs a `sudo` password while in the background, so I just kept some admin stuff in a separate terminal tab.
“`bash
# Switch to the limited user
su – openclaw
# Run the onboarding script
openclaw onboard –install-daemon
“`
I set up Google Gemini 2.5 Flash just to test things out. When the installer asked where to put data, I pointed it to my new APFS volume: `/Volumes/OpenClawData/workspace`.
—
## 4. Keeping it running in the background
The default setup installs a `LaunchAgent`, which means it only starts when the `openclaw` user logs in graphically. I wanted it to start at boot, so I had to learn how to write a System Daemon.
**First, I removed the standard one:**
“`bash
launchctl unload ~/Library/LaunchAgents/ai.openclaw.gateway.plist
rm ~/Library/LaunchAgents/ai.openclaw.gateway.plist
“`
**Then, from my main account, I created a `LaunchDaemon`:**
“`xml
sudo tee /Library/LaunchDaemons/com.openclaw.agent.plist << ‘EOF’
EOF
“`
Loading it into macOS requires pretty strict permissions, which was an interesting learning curve:
“`bash
sudo chown root:wheel /Library/LaunchDaemons/com.openclaw.agent.plist
sudo chmod 644 /Library/LaunchDaemons/com.openclaw.agent.plist
sudo launchctl load /Library/LaunchDaemons/com.openclaw.agent.plist
“`
—
## 5. Tweaking Settings
OpenClaw uses something called `JSON5` for its config at `~/.openclaw/openclaw.json`. I thought it would be fun to play around with permissions and restrict it tightly just to see what broke.
Here’s the snippet I modified:
“`json5
“tools”: {
“enabled”: true,
“defaultPolicy”: “deny”, // Block everything by default
“allowlist”: [
“browser_navigate”,
“browser_click”,
“file_read”,
“file_write”
]
},
“`
Because I only gave it 30GB, I also ended up putting together a couple of simple scripts to delete old logs every 10 days so it wouldn’t crash.
—
## Thoughts and What I Learned
It’s been pretty cool having my own personal AI running constantly in the background. It barely touches the CPU (around 1.3%) and it was a great excuse to poke around macOS internals!
Some fun takeaways from this weekend experiment:
1. **Quotas are different now:** If you want hard storage limits on macOS, APFS Volume Quotas are the way to go. You can’t resize them easily though, so that was a lesson learned!
2. **Double check background tasks:** When I swapped from `LaunchAgent` to `LaunchDaemon`, I accidentally had both running and spiked my CPU to 125%. `ps aux | grep openclaw` was my best friend saving me there!
3. **Configs use JSON5:** I kept trying to use YAML before realizing the agent strictly parsed JSON5.
4. **Sudo is tricky:** Automating `sudo` prompts is a headache, so keeping an admin terminal handy while working as a standard user made life much easier.
Have you tried running any AI models locally or playing around with OpenClaw? Let me know!
Leave a Reply