Build custom PiKVM OS images with your local code modifications.
Hybrid Approach:
- ✅ Your local kvmd code (always rebuilt)
- ✅ Official pre-built packages (fast downloads)
- ⚡ Result: 5-10 minute builds instead of 60+ minutes
From PiKVM documentation:
- Linux kernel >= 5.8
- glibc >= 2.33
- Docker >= 19.03.13
- git, make, curl, binutils
cd /mnt/e/GitHub/Symmetric/pikvm/os
# Automated setup (Ubuntu/Debian/Fedora/Arch)
./setup-build-env.shWhat it does:
- ✅ Checks system requirements (kernel, glibc, Docker)
- ✅ Installs missing packages
- ✅ Adds you to docker group
- ✅ Enables Docker service
- ✅ Tests Docker privileged mode
After setup: Log out and back in, or run:
newgrp dockerEdit config.mk:
# Hardware
BOARD = rpi4
PLATFORM = v4plus-hdmi
# Credentials
ROOT_PASSWD = rootpass
WEBUI_ADMIN_PASSWD = adminpass
IPMI_ADMIN_PASSWD = adminpass
# Locale
HOSTNAME = pikvm
LOCALE = en_US
TIMEZONE = America/Los_Angeles
# Source paths (REQUIRED - already configured for WSL)
LOCAL_KVMD_REPO = /pikvm/kvmd
LOCAL_PACKAGES_REPO = /pikvm/packages# For rpi4 (64-bit)
sudo bash -c 'echo -1 > /proc/sys/fs/binfmt_misc/aarch64'
# For rpi2/rpi3/zero2w (32-bit)
sudo bash -c 'echo -1 > /proc/sys/fs/binfmt_misc/arm'The build.sh script handles all the complexities:
cd /mnt/e/GitHub/Symmetric/pikvm/os
# Build OS and create image
sudo ./build.shWhat it does:
- Copies pikvm directory to
/pikvm/(avoids WSL path issues) - Builds kvmd package from your local source
- Creates OS image with official packages + your kvmd
- Copies images back to
os/images/ - Shows build time and summary
Options:
# Build in /tmp (auto-cleanup on reboot)
sudo BUILD_IN_TMP=1 ./build.shOutput: os/images/v4plus-hdmi-rpi4/arm/*.img
cd /mnt/e/GitHub/Symmetric/pikvm/os
# Build OS
make os
# Create flashable image
make imageOutput: os/images/v4plus-hdmi-rpi4/arm/*.img
# 1. Edit your code in Windows
# Edit: E:\GitHub\Symmetric\pikvm\kvmd\apps\kvmd\api.py
# 2. Rebuild (fast!)
cd /mnt/e/GitHub/Symmetric/pikvm/os
sudo ./build.sh
# Total time: ~5-10 minutes
# - Build kvmd: ~5 min
# - Create image: ~2 min
# 3. Flash to SD card and testYour changes are automatically included!
Check that your local code was used:
# After building
./verify-local-build.shExample output:
1. Checking for local kvmd package in build...
✅ Found kvmd package: kvmd-4.32-1-any.pkg.tar.xz
2. Checking Dockerfile configuration...
✅ Dockerfile configured to use local kvmd
3. Checking package sources...
✅ Local package repository found (45 packages)
4. Checking build markers...
✅ Git commit: abc1234 Custom changes
✅ Build verification PASSED
On device:
ssh root@pikvm
cat /usr/share/kvmd/.build-infoRemove build artifacts to free disk space:
cd /mnt/e/GitHub/Symmetric/pikvm/os
# Interactive cleanup (asks what to remove)
./clean.sh
# Force cleanup (no prompts)
./clean.sh --force
# Only Docker images
./clean.sh --docker
# Everything including Docker system prune
./clean.sh --allWhat gets cleaned:
os/.pi-builder/- OS build cachepackages/.pi-builder/- Package build cachepackages/.build/- Package build directoryos/images/- Built OS images (asks first)packages/repos/- Built packages (asks first)- Docker images (pi-builder., pikvm-packages.)
After cleanup:
# Clean up /pikvm build location (if using build.sh)
sudo rm -rf /pikvm| Board | ARCH | PLATFORM Options |
|---|---|---|
| rpi4 | arm | v4plus-hdmi, v4mini-hdmi |
| rpi3 | arm | v3-hdmi |
| rpi2 | arm | v2-hdmi |
| zero2w | arm | v2-hdmi |
Raspberry Pi 4 Plus:
BOARD = rpi4
PLATFORM = v4plus-hdmiRaspberry Pi 3:
BOARD = rpi3
PLATFORM = v3-hdmiSolution: Ensure you run with sudo:
sudo ./build.shThe script needs sudo to copy to /pikvm/ but runs builds as your user.
Solution:
sudo usermod -aG docker $USER
newgrp docker # or log out/inSolution: Use legacy builder:
export DOCKER_BUILDKIT=0
make osOr use build.sh which handles this automatically.
Solution: Upgrade your distribution:
sudo apt-get update && sudo apt-get dist-upgrade
sudo rebootOr use Ubuntu 22.04 or newer.
If you see errors about binfmt, reset it:
# For rpi4
sudo bash -c 'echo -1 > /proc/sys/fs/binfmt_misc/aarch64'
# For rpi2/rpi3
sudo bash -c 'echo -1 > /proc/sys/fs/binfmt_misc/arm'| Environment | Build Time | Notes |
|---|---|---|
| Native Linux VM | ~10-15 min | Best performance |
| WSL2 (with build.sh) | ~15-20 min | Handles path issues |
| WSL2 (direct make) | ~10-15 min | If paths work |
Tips:
- Use SSD storage
- Allocate 4+ GB RAM to Docker
- Native Linux VM is fastest
build.shsolves WSL path issues automatically
| Component | Source | Time |
|---|---|---|
| kvmd | Your local repo | ~5 min |
| ustreamer | Official package | Downloaded |
| kvmd-webterm | Official package | Downloaded |
| kvmd-fan | Official package | Downloaded |
| Dependencies | Official packages | Downloaded |
Total: ~10-15 minutes vs 60+ minutes for full local build
Automated build with WSL path handling.
Usage:
sudo ./build.sh # Build in /pikvm
sudo BUILD_IN_TMP=1 ./build.sh # Build in /tmpRemove build artifacts and Docker images.
Usage:
./clean.sh # Interactive
./clean.sh --force # No prompts
./clean.sh --docker # Only Docker
./clean.sh --all # Everything + system pruneInstall and configure build prerequisites.
Usage:
./setup-build-env.shVerify your local code was used in build.
Usage:
./verify-local-build.sh- PiKVM Documentation: https://docs.pikvm.org/
- Discord: https://discord.gg/bpmXfz5
- Forum: https://forum.pikvm.org/
- GitHub Issues: https://github.com/pikvm/os/issues
Pre-built images (if you don't need custom builds): https://files.pikvm.org