LinuxCommandLibrary

dracut

Create initramfs images for booting Linux

TLDR

Generate an initramfs image for the current kernel without overriding any options

$ dracut
copy

Generate an initramfs image for the current kernel and overwrite the existing one
$ dracut [[-f|--force]]
copy

Generate an initramfs image for a specific kernel
$ dracut --kver [kernel_version]
copy

List available modules
$ dracut --list-modules
copy

SYNOPSIS

dracut [options] [image-name] [kernel-version]

PARAMETERS

-f, --force
    Overwrite existing initramfs image

-v, --verbose
    Increase verbosity level (repeat for more)

--kver
    Use specific kernel version

-m, --modules
    Add specified modules (comma-separated)

--omit
    Exclude specified modules

--add-drivers
    Include additional kernel drivers (*.ko)

--filesystems
    Include support for filesystems

--mountpoints
    Include mountpoints in image

--hostname
    Set hostname in image

--hostonly
    Limit to host-specific modules (default on)

--no-hostonly
    Include generic modules

--dry-run
    Print actions without executing

--print-cmdline
    Print suggested kernel command line

--xx-ignore=...
    Ignore specific modules or devices

-H, --hostonly-cmdline
    Optimize command line for hostonly mode

DESCRIPTION

Dracut is a tool for generating initramfs images used during the Linux boot process. It creates a compressed cpio archive containing essential modules, drivers, and scripts needed to mount the root filesystem and transition to the full system. Unlike older tools like mkinitrd, dracut is highly modular, with modules in
/usr/lib/dracut/modules.d/, allowing easy extension for specific hardware, filesystems, or network setups.

Primarily used in Fedora, RHEL, and derivatives, dracut automatically detects required kernel modules based on hardware and /etc/fstab. It supports multiple kernels, kdump images, and rescue environments. The generated initramfs is loaded by the bootloader (e.g., GRUB) into RAM before kernel execution.

Key advantages include faster generation, smaller images via module inclusion, and better support for complex setups like LVM, Btrfs, or iSCSI. Users can customize via /etc/dracut.conf or command-line options, making it flexible for embedded systems or cloud environments.

CAVEATS

Requires root privileges; --force can overwrite critical boot images, risking unbootable systems. Hostonly mode may fail on hardware changes. Large images increase boot time.

CONFIGURATION FILES

Main config: /etc/dracut.conf; drop-ins in /etc/dracut.conf.d/. Use add_dracutmodules+="module" to include extras.

REGENERATION

Often called by kernel package post-install: dracut --force /boot/initramfs-$(uname -r).img $(uname -r)

MODULE DEVELOPMENT

Custom modules in /usr/lib/dracut/modules.d/<priority>/<name>/ with install(), installkernel() hooks.

HISTORY

Developed by Harald Hoyer for Fedora 10 (2008) as a modular mkinitrd replacement. Adopted by RHEL 6+, SUSE. Major versions: 040+ introduced systemd integration; now at 0.55+ with better NVMe, ZFS support.

SEE ALSO

mkinitrd(8), dracut.conf(5), initramfs(7), update-initramfs(8), mkinitcpio(8)

Copied to clipboard