The initramfs is a gzip-compressed CPIO archive that the Linux kernel decompresses directly into a tmpfs at boot. Because AmnesiaOS never mounts a persistent root device, this archive is the entire running OS — everything the system does after the kernel hands off to userspace happens inside it.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/damianiglesias/amnesiaOS/llms.txt
Use this file to discover all available pages before exploring further.
scripts/build-initramfs.sh automates the full assembly: downloading BusyBox, building the directory tree, creating device nodes, writing the network and init scripts, and packing the final image.
Running the script
The script must be run as root because creating device nodes withmknod requires elevated privileges:
What the script does
Create directory structure
The script creates the full FHS-compatible skeleton that BusyBox and the init system expect to find at runtime:
Download BusyBox 1.35.0
BusyBox provides every userspace utility the initramfs needs in a single statically-linked binary. The script downloads the pre-built musl-linked x86_64 binary and skips the download if the file is already present:
Create utility symlinks
BusyBox uses All symlinks are created inside
argv[0] to decide which applet to run, so the script creates a symlink for each utility pointing back to the busybox binary:/initramfs/bin/ with ln -sfv busybox /initramfs/bin/<cmd>.Create device nodes
Three device nodes are created with
mknod. These must exist before the kernel tries to open them during early boot:| Node | Type | Major | Minor | Mode |
|---|---|---|---|---|
/dev/console | char | 5 | 1 | 622 |
/dev/null | char | 1 | 3 | 666 |
/dev/tty | char | 5 | 0 | 666 |
Write DHCP script
The The
udhcpc DHCP client calls a helper script to apply the lease it receives from the network. The script is installed at /initramfs/usr/share/udhcpc/default.script:deconfig case flushes the interface address when releasing a lease. The bound/renew case applies the assigned IP, default route, and DNS resolvers.Write /init
/init is the first userspace process the kernel executes after decompressing the initramfs. The script writes the following to /initramfs/init and marks it executable:proc, sysfs, devtmpfs), brings up the loopback interface, iterates over every non-loopback network interface to request a DHCP lease, then drops into an interactive BusyBox shell.Pack the archive
The completed initramfs tree is packed into a gzip-compressed CPIO archive — the exact format the Linux kernel’s initramfs loader expects:The
-H newc flag selects the “new ASCII” CPIO format required by the kernel. gzip -9 applies maximum compression to keep the archive as small as possible since it must be loaded entirely into RAM.