rsinit is a minimalistic single binary init for the initramfs for embedded systems. It's main objective is to mount the root filesystem as fast as possible and then hand over to the actual init program.
The main use-case is, to mount root filesystems that cannot be mounted by the Linux kernel directly. But it can also mount just about anything that the kernel can mount directly based on the command-line.
Currently supported root filesystems are:
-
9pfs with USB gadget transport
-
filesystems on a dm-verity device
-
regular devices or anything that requires just specifying the device and mount options
-
nfsroot
-
9pfs with virtio transport (for QEMU)
One important design goal for rsinit is to be as fast as possible. For cases where the kernel can mount the same root filesystem directly, booting with rsinit should be just as fast as booting without it.
To achieve this, the initramfs must be as small as possible. Changes that significantly increase the binary size of rsinit are not acceptable. Crates that wrap external (C) libraries cannot be used.
In general, the binary size should be kept in mind when making any changes.
rsinit itself will only cover the simple use-cases to mount the root filesystem and related generic tasks with minimal runtime and build time configuration.
For more complex use-cases, e.g. to mount additional (overlay) filesystems, rsinit can be used as a crate in a custom rust application. The code is structured in a way that makes it possible to reuse the existing code and add new functionality as needed.
The project includes a Makefile for easy cross-compilation.
Before building, ensure you have the following tools installed:
cross- Cross-compilation tool for Rustrustup- Rust toolchain managerpodmanordocker- Container runtime for crosscpio- For creating cpio/initramfs archivesgzip- For compressing cpio/initramfs archives- A
nightlyRust toolchain
You can verify all dependencies are installed by running:
make check-toolchainTo see all available make targets and options:
make helpCommon build commands:
# Build binaries and CPIO archives for all default targets
make all
# Build for a specific target only
make aarch64-unknown-linux-musl-build
# Create CPIO archive for a specific target
make aarch64-unknown-linux-musl-cpio
# Build with minimal profile (smaller binary size)
make MINIMAL_BUILD=1 all
# Use Docker instead of Podman
make CROSS_CONTAINER_ENGINE=docker allDefault target architectures:
aarch64-unknown-linux-muslarm-unknown-linux-musleabihfx86_64-unknown-linux-musl
Build artifacts are placed in target/<arch>/<profile>/ directories.