I've just tried out Fedora after using Arch for several months, and I was following some of the tutorials I used for Arch which mentioned running makeinitcpio for GPU drivers. However, on Fedora, it seems the equivalent command is dracut. This got me thinking: if there are different commands to achieve similar tasks, can I switch mkinitcpio for dracut on Fedora or vice versa on Arch? From what I gather, both commands rebuild the initramfs file in /boot, which is essentially a set of kernel modules that need to be loaded during the system boot. Did I get that right or am I misunderstanding something? Also, how does it work if I'm not explicitly specifying which modules to load? I'm feeling a bit lost on this whole topic. Can someone clarify how these elements work together?
3 Answers
An initramfs is essentially a temporary filesystem that contains everything necessary to go from just the kernel to having mounted filesystems and working devices. Typically, you won't need to manually tweak it much. Dracut is pretty smart and can even handle encrypted filesystems without extra configuration. When you boot your PC, GRUB loads the initramfs, and then the control passes to the kernel, which gets the drivers ready for the init system.
Mkinitcpio and dracut both function as initramfs generators. Basically, an initramfs is a minimal version of your root filesystem that the kernel can use to boot your system. After it’s unpacked into RAM, the kernel initializes it before switching to the main filesystem. The reason we use an initramfs is to provide flexibility, such as booting from exotic filesystems that the kernel can't access directly. The Linux kernel already includes some modules by default, but you can specify additional ones in the generator's config. And yes, you can swap mkinitcpio and dracut on different distros as they serve the same purpose with slight differences.
Kernel modules are like dynamic link libraries specifically designed to attach and detach from the kernel at runtime. They have unique requirements since they interact with the kernel—unlike standard libraries, which just link at startup. During the boot process, you need certain kernel modules loaded early, and they have to be included in the initramfs. The whole sequence starts with your BIOS or UEFI, loads the bootloader (GRUB), which then loads the initramfs. The boot process is about building an environment gradually until you load the full OS, which is why you see this layering.
To simplify, dracut and mkinitcpio are just two tools to achieve the same goal—setting up a simple OS boot process. Think of kernel modules as drivers, and initramfs as the initial drivers that help your hardware boot before loading the full OS. The beauty of Linux is that the bootloader and init processes automate a lot of this, so you generally don't have to manually specify modules.