-
-
Notifications
You must be signed in to change notification settings - Fork 1
Linux systemd nspawn Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to systemd-nspawn on Linux, covering Arch Linux, CachyOS, and other distributions including container creation, lightweight virtualization, and systemd containers.
- Understanding systemd-nspawn
- systemd-nspawn Installation
- Creating Containers
- Running Containers
- Troubleshooting
systemd-nspawn creates lightweight containers.
Features:
- Lightweight: Minimal overhead
- systemd integration: Uses systemd
- Container creation: Create containers
- Isolation: Process isolation
Why it matters:
- Lightweight virtualization: Lightweight containers
- systemd integration: Integrated with systemd
- Development: Useful for development
Arch/CachyOS:
# systemd-nspawn is part of systemd
# Usually pre-installed
# Verify
systemd-nspawn --versionBasic usage:
# Create container directory
sudo mkdir -p /var/lib/machines/container
# Install system in container
sudo pacstrap /var/lib/machines/container baseStart container:
# Boot container
sudo systemd-nspawn -D /var/lib/machines/container
# Starts containerNetwork access:
# With network
sudo systemd-nspawn -D /var/lib/machines/container --network-bridge=br0
# --network-bridge = bridge networkMount directories:
# With bind mount
sudo systemd-nspawn -D /var/lib/machines/container --bind=/path/to/dir
# Mounts directory in containerCheck permissions:
# Verify directory
ls -la /var/lib/machines/container
# Check systemd
systemctl status systemd-nspawn@container.serviceThis guide covered systemd-nspawn usage, container creation, and lightweight virtualization for Arch Linux, CachyOS, and other distributions.
- machinectl Guide - Container management
- Virtualization - Virtualization guide
- Docker Guide - Docker containers
-
systemd-nspawn Documentation:
man systemd-nspawn
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.