dracut

On this page 7

dracut is a modular initramfs generator for Linux: it assembles the small compressed archive that the kernel unpacks into memory at boot and runs before the real root filesystem is mounted. Inside that early environment, dracut-built code loads drivers, assembles RAID and LVM volumes, unlocks encrypted disks, brings up the network when needed, mounts the root filesystem and then hands control to the system init, normally systemd.

In Linux system initialization, dracut sits between the boot loader and the init system. It is the default initramfs tool on Fedora, RHEL and its rebuilds, openSUSE and several other distributions, and is now developed largely in the community fork dracut-ng, which most of those distributions have adopted.

How dracut builds an initramfs

dracut builds the image by running a set of shell-based modules, each of which copies the binaries, libraries, kernel modules, udev rules and scripts it needs into a staging directory. The directory is then packed as a cpio archive and compressed, typically with zstd, xz or gzip, and written to a path such as /boot/initramfs-6.11.4.img.

Modules live in /usr/lib/dracut/modules.d/ in numbered directories such as 90lvm, 90crypt or 95nfs, where the number sets the order. Each module provides a module-setup.sh script with standard functions that decide whether it applies and what it installs.

FunctionPurposeExample behavior
check()Decides whether the module is neededReturns 0 only if LVM volumes exist
depends()Lists other modules it requirescrypt depends on dm and systemd
install()Copies binaries, rules and hook scriptsInstalls cryptsetup and its udev rules
installkernel()Adds required kernel modulesAdds dm_crypt and cipher drivers
Functions in a dracut module-setup.sh script

Distribution kernel packages call dracut automatically after every kernel update, usually through kernel-install plugins, so administrators rarely run it by hand except after changing storage, drivers or configuration.

What happens inside the dracut initramfs at boot

At boot, the dracut initramfs runs an event-driven sequence: udev discovers devices as they appear, and dracut waits until the configured root device exists instead of sleeping for fixed periods. On modern systems the early environment itself runs systemd in the initramfs, with dracut providing units for each stage.

  1. cmdline parses the kernel command line, for example root= and rd.* options.
  2. pre-udev and pre-trigger prepare udev rules before devices are probed.
  3. initqueue loops while devices appear, assembling RAID, LVM and LUKS volumes.
  4. pre-mount and mount check and mount the root filesystem on /sysroot.
  5. pre-pivot and cleanup finish tasks, then switch_root starts the real init.

If the root device never appears, dracut times out and drops into an emergency shell, which is the main reason it is valued for troubleshooting.

Configuring dracut and its key options

dracut reads /etc/dracut.conf and drop-in files in /etc/dracut.conf.d/, and the same settings can be passed on the command line. Drop-in files are the preferred method because package updates do not overwrite them.

Option or settingEffectTypical use
--hostonly / hostonly=yesIncludes only what this machine needsSmaller, faster images
--no-hostonlyBuilds a generic image for any hardwareRescue images, disk migration
--add / add_dracutmodules+=Forces extra modules into the imageAdding network or iSCSI support
--omit / omit_dracutmodules+=Excludes specific modulesRemoving unused Plymouth or NFS
--force --kverRebuilds an image for one kernel versionAfter editing configuration
--regenerate-allRebuilds images for all installed kernelsAfter a driver or storage change
--uefiProduces a unified kernel imageSecure Boot and systemd-boot setups
Frequently used dracut options

The built image can be inspected with lsinitrd, which lists its files and the modules it contains; checking it before a reboot catches missing drivers or keys early.

dracut compared with other initramfs tools

dracut is one of several initramfs generators on Linux, and each distribution family has its own default. They produce the same kind of artifact, an initramfs, but differ in structure and ecosystem.

ToolMain distributionsDesign notes
dracutFedora, RHEL, openSUSE, VoidEvent-driven, numbered shell modules, systemd-based
mkinitcpioArch LinuxHook-based, configured in mkinitcpio.conf
initramfs-toolsDebian, UbuntuScript hooks, update-initramfs command
boosterOptional on ArchGo-based, focused on fast generation and boot
Initramfs generators on Linux

Arch Linux and Ubuntu have both evaluated or offered dracut as an alternative, so dracut skills transfer widely across enterprise and desktop distributions.

Troubleshooting dracut boot failures

Most dracut problems show up as a boot that stops in the emergency shell with a message that the root device could not be found. The kernel command line offers several rd.* debugging parameters for these cases.

SymptomLikely causeFix
Timeout waiting for root deviceStorage driver missing from host-only imageRebuild with the driver or –no-hostonly
No passphrase prompt for LUKScrypt module omitted or wrong rd.luks.uuidAdd crypt, correct the kernel command line
Old settings still activeImage not rebuilt after config changeRun dracut –force for that kernel
Boot fails after moving disksHost-only image tied to old hardwareBoot a rescue entry, regenerate all images
Common dracut boot problems
  • rd.break=pre-mount stops at a chosen hook and opens a shell for inspection.
  • rd.shell permits a shell after a failure, and rd.debug logs every script step.
  • rd.lvm.lv= and rd.luks.uuid= restrict which volumes dracut activates.

A non-technical view

When a Linux computer starts, it faces a chicken-and-egg problem: the operating system lives on a disk, but the computer may need special software to read that disk, for example to unlock encryption or combine several drives.

dracut solves this by packing a small starter kit ahead of time. The kit is loaded into memory at power-on, opens the real disk, and then steps aside for the full system. If something is missing from the kit, the computer stops early and offers a repair console.

A concrete example

An administrator at a university lab migrates a RHEL server from a single SATA disk to a new NVMe drive inside an encrypted LUKS container with LVM on top. After copying the data and updating /etc/crypttab and the GRUB entry, the first reboot stops in the dracut emergency shell, because the old host-only image contains no NVMe or dm-crypt drivers.

Booting the rescue entry, the administrator adds a drop-in file with add_dracutmodules+=" crypt lvm ", runs dracut --force --regenerate-all, and confirms with lsinitrd | grep nvme that the driver is present. On the next boot the passphrase prompt appears and the server reaches its normal login screen in about twenty seconds, with the fixed configuration preserved for every future kernel update.