___ __ _____ ____
/ | __________/ /_ / ___/____ _____ ___/ / /_ ____ _ __
/ /| | / ___/ ___/ __ \ \__ \/ __ `/ __ \/ __ / __ \/ __ \| |/_/
/ ___ |/ / / /__/ / / / ___/ / /_/ / / / / /_/ / /_/ / /_/ /> <
/_/ |_/_/ \___/_/ /_/ /____/\__,_/_/ /_/\__,_/_.___/\____/_/|_|
arch-sandbox is a powerful command-line tool that spins up isolated Arch Linux environments using overlay filesystems and systemd-nspawn. Perfect for developers, system administrators, and Linux enthusiasts who need safe, disposable environments for testing and experimentation.
Features β’ Installation β’ Usage β’ Contributing β’ License
- π Isolated Environments - Run Arch Linux sandboxes without affecting your host system
- π¦ Overlay Filesystem - Keep changes separate using overlayfs technology
- πΎ Persistent or Ephemeral - Choose to keep or discard your sandbox after use
- πΈ Snapshot Management - Save and restore sandbox states
- π¦ Package Installation - Install packages directly in persistent sandboxes
- π― Simple CLI - Powered by Cobra for an intuitive command-line experience
- β‘ Lightweight - Minimal overhead, maximum performance
Ensure you have the following installed on your Arch Linux system:
- systemd-nspawn - for containerization
- mount - for overlay filesystem operations
- pacman - for Arch Linux package management
- zstd - for
.tar.zstarchive handling
Install prerequisites on Arch Linux:
sudo pacman -S systemd zstdNote: You'll need root privileges (
sudo) to run arch-sandbox due tosystemd-nspawnandmountrequirements.
The easiest way to install arch-sandbox is through the Arch User Repository (AUR):
# Using yay
yay -S arch-sandbox
# Or using paru
paru -S arch-sandboxNote: The AUR package may be in the process of being published. If it's not available yet, please use Method 2 (Manual Installation) below.
This method automatically handles dependencies and keeps the tool up-to-date with your system.
If you prefer to build from source or want the latest development version:
sudo pacman -S go git systemd zstdgit clone https://github.com/OminduD/arch-sandbox.git
cd arch-sandboxgo build -o arch-sandboxsudo install -Dm755 arch-sandbox /usr/local/bin/arch-sandboxOr copy it to a directory in your PATH:
sudo mv arch-sandbox /usr/local/bin/arch-sandbox --helpCreate a disposable sandbox for quick testing:
sudo arch-sandbox new mysandboxCreate a persistent sandbox that survives reboots:
sudo arch-sandbox new mysandbox --persistarch-sandbox new <name> [flags]Flags:
-p, --persist- Keep the sandbox after exiting (default: cleanup on exit)--base-dir string- Base directory for sandboxes (default:~/.arch-sandbox)
Examples:
# Create a disposable sandbox
sudo arch-sandbox new testbox
# Create a persistent sandbox
sudo arch-sandbox new devbox --persist
# Create a sandbox in a custom location
sudo arch-sandbox new projectbox --persist --base-dir /data/sandboxesInstall packages directly in a persistent sandbox:
sudo arch-sandbox install <sandbox-name> <package>Example:
# Install vim in a sandbox
sudo arch-sandbox install devbox vim
# Install git in a sandbox
sudo arch-sandbox install devbox gitSave and restore sandbox states:
# Save a snapshot
sudo arch-sandbox snapshot <sandbox-name> save <snapshot-id>
# Restore a snapshot
sudo arch-sandbox snapshot <sandbox-name> restore <snapshot-id>
# List snapshots
sudo arch-sandbox snapshot <sandbox-name> listThe tool follows these steps to create a sandbox:
Start
β
[Create Directories] β [Check Dependencies]
β
[Download Tarball]
β
[Extract Tarball]
β
[Mount Overlayfs]
β
[Launch systemd-nspawn]
β
[Cleanup (if not persistent)]
You'll enter a /bin/bash shell where you can:
- π¦ Install packages with
pacman - π§ͺ Test scripts or configurations safely
- π§ Experiment with system changes
- π Develop and test software
- πͺ Exit with
exitorCtrl+D
- Disposable Sandboxes: Automatically deleted on exit
- Persistent Sandboxes: Stored in
~/.arch-sandbox/<name>
Delete a persistent sandbox manually:
rm -rf ~/.arch-sandbox/<name>ls -la ~/.arch-sandbox/- π Run as
rootor withsudoforsystemd-nspawnandmountoperations - π Internet access is required for tarball download
- π¦ Tarball source:
https://archive.archlinux.org/iso/2025.07.01/archlinux-bootstrap-2025.07.01-x86_64.tar.zst
We welcome contributions from everyone! Whether you're fixing bugs, adding features, or improving documentation, your help makes arch-sandbox better.
Please see our Contributing Guide for detailed instructions on how to get started, set up your development environment, and submit your pull requests.
MIT License. See LICENSE for details.