Check out the configs directory to get an overview of what this project is trying to achieve.
configs/defaults provides default/preset mechanisms for rootfs creation. Currently only Debian 13 is implemented.
configs/tests provides config files which users will write to configure their rootfs creation process.
For example:
sudo rootfs-spawn create configs/tests/debian.rootfs my-rootfs-output-dir
This will kick off the parsing stage:
- Read and parse the provided config file
configs/tests/debian.rootfs - Process all statements into a list of statements ordered by their appearance in each file
- Process all
imports = [..]statements just like C's#include
In the end, this provides a list of tasks to do outside of the rootfs itself and inside the rootfs.
TODO needs more explanation.
After parsing, the rootfs creation stage kicks off:
- Run all
spawnstatements in order (on the host system) - Run all
initstatements in order (on the host system) - Run all
provisionstatements in order (on the chrooted rootfs) - Run all
cleanupstatements in order (on the chrooted rootfs) - Run all
disposestatements in order (on the host system)
Where the "host" system is not exactly the host system rootfs-spawn is running on. Currently it is, but it will be a systemd-nspawn container which has all the tools required plus the host system's rootfs mounted under /mnt/host and the target rootfs mounted under /mnt/rootfs. See configs/defaults/debian/init for example.
So the architecture will be something like this (all inside a special systemd-nspawn container):
- Populate
/mnt/rootfsvia the given tool defined byspawnstatements (i.e.,debootstrap) - Execute the
initstatements - Run a nested and ephemeral
systemd-nspawncontainer where/mnt/rootfsbecomes its rootfs and execute theprovisionstatements, after that thecleanupstatements - Execute the
disposestatements
TODO what about the cache config? We need a better way for that... it should probably become part of the spawn config.
TODO add default dispose configs
Depending on the distro you want to spawn, you need the respective tool:
- Debian/Ubuntu:
debootstrapormultistrap(https://wiki.debian.org/EmDebian/CrossDebootstrap) - Arch Linux:
pacstrap(https://wiki.archlinux.org/title/Pacstrap) - YUM/DNF based (Fedora, RHEL, CentOS Alma Linux, Rocky Linux, ...):
yum+dnfand the respective YUM repo setup (see https://quantum5.ca/2025/03/22/whirlwind-tour-of-systemd-nspawn-containers/#installing-rhel-derivatives-with-dnf for an example)
Prerequisites:
Once the prerequisites are installed on your system, run the following commands to clone the project:
git clone https://github.com/thetredev/rootfs-spawn.git
cd rootfs-spawn
Then sync the project via uv:
uv sync
Syncing includes installing. If you for any reason need to install it locally pip-style, you can run
uv pip install .
or
uv pip install -e .