An initramfs is a cpio archive the kernel unpacks into a tmpfs and then executes /init from. That is the entire contract. Every generator — dracut, mkinitcpio, initramfs-tools — is a program that writes files into a directory and runs cpio over it.
1. The smallest thing that boots
mkdir -p initramfs/{bin,dev,proc,sys,new_root}
cp /usr/bin/busybox initramfs/bin/
cat > initramfs/init <<'EOF'
#!/bin/busybox sh
/bin/busybox --install -s /bin
mount -t proc none /proc
mount -t sysfs none /sys
mount -o ro /dev/sda2 /new_root
exec switch_root /new_root /sbin/init
EOF
chmod +x initramfs/init
Pack it the way the kernel expects:
cd initramfs
find . | cpio -o -H newc | zstd -19 > /boot/initramfs-minimal.img
2. Why bother
Because a hand-written init is auditable. A generated initramfs on a stock install carries drivers for hardware you do not own, a plymouth theme, and a shell you never invoke. On an appliance image, dropping to the twelve lines above cut unpack time from 900ms to under 200ms and removed most of what was in the image.
3. Where it goes wrong
Two failures account for nearly everything. The first is a missing module: if the root filesystem driver is built as a module rather than into the kernel, it has to be copied in and loaded before the mount. The second is a dynamically linked binary without its loader — check with ldd before packing, or use a static busybox and stop thinking about it.
Keep a known-good entry in the bootloader. Testing an initramfs without a fallback is how a five-minute experiment becomes an evening with a live USB.