Master the fundamental concepts of the boot process: theory through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksAn initramfs is a cpio archive the bootloader loads into memory before the kernel starts. Early kernel code mounts it as a tmpfs root so drivers and scripts can run before the real root disk is available. For example, a typical Linux image ships initramfs-linux.img containing module-loading helpers and init glue that finds the LUKS or LVM root.
cLoading…
The kernel mounts tmpfs, extracts the cpio archive into rootfs, and executes /init. Dracut-generated images include udev rules to modprobe storage drivers before pivot_root. If /init exits, the kernel panics; keep the process alive until switch_root completes. Inspect an image with lsinitrd or zcat initramfs.img | cpio -itv to see which helpers your distro ships.
You will trace how the bootloader passes an initramfs blob to the kernel and what early /init must accomplish. This exercise requires describing why root-on-LUKS or NFS roots depend on initramfs content before pivot_root.
Before the real root filesystem is mounted, /init in the initramfs loads the kernel modules it needs, dependencies first. Simulate it.
For each required module, in input order, load it depth-first: first its dependencies, in their listed order, each with its own dependencies, then the module itself. A module loads only once. Track each module's state (not visited, loading, loaded), so a cycle is detected instead of recursing forever.
NAME DEPCOUNT dep1 dep2 ...: the modules the initramfs ships.LOAD <name> each time a module finishes loading.MISSING <dep> (needed by <module>), then EMERGENCY SHELL, and stop.MISSING <name> (not in initramfs), then EMERGENCY SHELL, and stop.DEPENDENCY CYCLE at <name>, then EMERGENCY SHELL, and stop.ROOT MOUNTED and SWITCH_ROOT on separate lines.