DRACUT(8)

๐Ÿ’– dracut(8) ๐Ÿ’–

okay bestie, welcome to dracut, the manual page, part one of five โœจ this is the dracut(8) page and it is a lot, but we're gonna get through it together, i promise ๐Ÿซถ


๐ŸŒธ NAME ๐ŸŒธ

dracut โ€” a low-level tool for generating an initramfs/initrd image. that's it, that's the whole name section, she's lowkey humble about it ๐Ÿ’…


โœจ SYNOPSIS โœจ

dracut [OPTION...] [<image> [<kernel version>]]

look at her. so simple. so powerful. the way that syntax just sits there ๐Ÿ˜ญ


๐ŸŽ€ DESCRIPTION ๐ŸŽ€

so here's the vibe: dracut creates an initramfs <image> for the kernel with the version <kernel version>. if you don't pass <kernel version>, it just uses the version of the kernel that's actually running right now, no questions asked. and if <image> is omitted or empty? the default location is decided by your local configuration or your Linux distribution's policy. iykyk.

what does it actually do, you ask? excellent question, bestie. dracut creates an initial image that the kernel uses for preloading the block device modules (think IDE, SCSI, or RAID) โ€” the ones you literally need in order to access the root filesystem, mount the root filesystem, and boot into the real system. it's giving backstage crew at a concert. nobody claps for them but nothing works without them ๐Ÿซถ

at boot time, the kernel unpacks that archive into a RAM disk, mounts it, and uses it as the initial root file system. all the finding of the root device happens in this early userspace. iconic behavior, truly.

also, initramfs images are also called "initrd". same thing, different nickname. like how everyone calls you by your government name in one group chat and your chaos name in another.

for a complete list of kernel command line options, see man:dracut.cmdline[7] โญ

now, the serious bit โ€” listen up ๐Ÿ”ฅ if you get dropped to an emergency shell while booting your initramfs, the file /run/initramfs/rdsosreport.txt gets created, and you can save it to a partition (that you have to mount by hand โ€” usually /boot) or to a USB stick. you can also get extra debugging info by adding rd.debug to the kernel command line. /run/initramfs/rdsosreport.txt contains all the logs plus the output of some tools. it should be attached to any report about dracut problems. no cap, that's how the maintainers actually figure out what went wrong, don't leave it out.

one more thing: dracut is expected to run as the root user so it has unrestricted access to the root filesystem while generating the initramfs. running dracut as any user other than root supports only a limited set of functionalities. for example โ€” to facilitate secure sulogin in the emergency console with the host password, it requires read access to /etc/shadow on the host, and that's usually only allowed for root. so yeah. root it is ๐Ÿ‘‘


๐ŸŒˆ USAGE ๐ŸŒˆ

to create an initramfs image, the most simple command is literally:

# dracut

that's it. that's the whole thing. and it'll generate a general purpose initramfs image with all possible functionality โ€” the combo of whatever dracut modules and system tools you have installed. the image contains the kernel modules of the currently active kernel with version <kernel-version>. default image location? again, decided by your local configuration or your Linux distribution policy. she's mysterious like that.

โš ๏ธ if the initramfs image already exists, dracut will display an error message. to overwrite the existing image you have to use the --force option:

# dracut --force

like, she will not just help herself to your existing image. consent matters ๐Ÿ’…

wanna name the resulting image something else? go off:

# dracut foobar.img

wanna generate an image for a specific kernel version? bet:

# dracut foobar.img 2.6.40-1.rc5.f20

and a shortcut to generate the image at the default location for a specific kernel version is:

# dracut --kver 2.6.40-1.rc5.f20

okay so now the interesting one ๐Ÿฆ‹ if you want lighter, smaller initramfs images, you might want to specify the --hostonly or -H option. with this, the resulting image only contains those dracut modules, kernel modules and filesystems that are needed to boot this specific machine. slay, right? but โ€” and it's a big but โ€” the drawback is that you can't put the disk on another controller or machine, and you can't switch to another root filesystem without recreating the initramfs image. so it's recommended to keep a copy of a general purpose image (and the corresponding kernel) as a fallback to rescue your system. don't say i didn't warn you ๐Ÿ˜ญ


๐Ÿฆ‹ INSPECTING THE CONTENTS ๐Ÿฆ‹

wanna snoop? valid. to see the contents of the image created by dracut, you can use the lsinitrd tool:

# lsinitrd | less

and to display the contents of a file inside the initramfs, also use lsinitrd:

# lsinitrd -f /etc/ld.so.conf
include ld.so.conf.d/*.conf

the way that just prints the file like it's nothing?? obsessed ๐ŸŽ€


โญ ADDING DRACUT MODULES โญ

some dracut modules are turned off by default and have to be activated manually. rude, but okay. you can do this by adding the dracut modules to the configuration file /etc/dracut.conf or /etc/dracut.conf.d/myconf.conf. see man:dracut.conf[5].

you can also add dracut modules right on the command line using the -a or --add option:

# dracut --add module initramfs-module.img

to see a list of available dracut modules, use the --list-modules option:

# dracut --list-modules
๐Ÿ’ก Tip: omitted modules will override added modules. --force-add can be used to add a module in host-only mode if it is specified as omitted (usually via a distribution configuration file).

that's the drama of it. omission wins the argument, but --force-add is the uno reverse card ๐Ÿ”ฅ


๐Ÿ’œ OMITTING DRACUT MODULES ๐Ÿ’œ

sometimes you just don't want a dracut module included, for reasons of speed, size or functionality. totally fair, bestie. to do this, either specify the omit_dracutmodules variable in the dracut.conf or /etc/dracut.conf.d/myconf.conf configuration file (see man:dracut.conf[5]), or use the -o or --omit option on the command line:

# dracut -o "multipath lvm" no-multipath-lvm.img

note the quotes around "multipath lvm" โ€” she's picky about her quoting and honestly? respect โœจ


๐Ÿš ADDING KERNEL MODULES ๐Ÿš

if you need a special kernel module in the initramfs that is not automatically picked up by dracut, you have to use the --add-drivers option on the command line, or the drivers variable in the /etc/dracut.conf or /etc/dracut.conf.d/myconf.conf configuration file (see man:dracut.conf[5]):

# dracut --add-drivers mymod initramfs-with-mymod.img

manual override energy. main character module. we love to see it ๐Ÿ’…


๐ŸŒŸ BOOT PARAMETERS ๐ŸŒŸ

okay this is the big one, sit down, hydrate ๐Ÿ“

an initramfs generated without the "hostonly" mode does not contain any system configuration files (except for some special exceptions), so the configuration has to be done on the kernel command line. and honestly? that's the whole flex โ€” with this flexibility you can easily boot from a changed root partition without needing to recompile the initramfs image. so you could completely change your root partition (move it inside a md raid with encryption and LVM on top) and as long as you specify the correct filesystem LABEL or UUID on the kernel command line for your root device, dracut will find it and boot from it. she's nothing if not resourceful.

now, a rule โ€” and please actually read it ๐Ÿ™ˆ files from the host root filesystem under the /etc, /var, or /run directories should only be copied over to the generated initramfs in "hostonly" mode, because those host directories are meant to be customized by users for each host. only host files from the /usr directory in the host root filesystem are meant to be included in the generated initramfs in both "hostonly" and "non-hostonly" mode. as an example, /etc/fstab and /etc/cryptab files should be only consulted when dracut is run in "hostonly" mode.

the only exception to this rule is the /etc/dracut.conf file and /etc/dracut.conf.d/ directory, which are considered in both "hostonly" and "non-hostonly" modes.

and psst โ€” some command line arguments (e.g. --include) can override the default "hostonly"/"non-hostonly" modes. so like, don't be shocked when they do.

generic initrds are larger, but should be able to automatically boot any bootable configuration with appropriate boot flags (root device, network configuration information, etc.). big image, big heart ๐Ÿ’–

the kernel command line can also be provided by the dhcp server with the root-path option. see NETWORK BOOT.

for a full reference of all kernel command line parameters, see man:dracut.cmdline[7].

wanna get a quick start for the suitable kernel command line on your system? use the --print-cmdline option:

# dracut --print-cmdline
 root=UUID=8b8b6f91-95c7-4da2-831b-171e12179081 rootflags=rw,relatime,discard,data=ordered rootfstype=ext4

look at all that. it's giving chef's kiss ๐Ÿ‘‘

๐ŸŒธ Specifying the root Device ๐ŸŒธ

this is the only option dracut really needs to boot from your root partition. because your root partition can live in various environments, there are a lot of formats for the root= option. the most basic one is root=<path to device node>:

root=/dev/sda2

but โ€” because device node names can change depending on the drive ordering โ€” you are encouraged to use the filesystem identifier (UUID) or filesystem label (LABEL) to specify your root partition:

root=UUID=19e9dda3-5a38-484d-a9b0-fa6b067d0331

or

root=LABEL=myrootpartitionlabel

to see all UUIDs or LABELs on your system, do:

# ls -l /dev/disk/by-uuid

or

# ls -l /dev/disk/by-label

and if your root partition is on the network, see NETWORK BOOT. we'll get there ๐Ÿฆ‹

๐ŸŽ€ Keyboard Settings ๐ŸŽ€

if you have to input passwords for encrypted disk volumes, you might want to set the keyboard layout and specify a display font. because typing your LUKS password on the wrong layout is a special kind of pain ๐Ÿ˜ญ

a typical german kernel command line would contain:

rd.vconsole.font=eurlatgr rd.vconsole.keymap=de-latin1-nodeadkeys rd.locale.LANG=de_DE.UTF-8

heads up though โ€” setting these options can override the setting stored on your system, if you use a modern init system like systemd. so like, know that you're doing that ๐Ÿ™ˆ

๐Ÿ’€ Blacklisting Kernel Modules ๐Ÿ’€

sometimes it's required to prevent the automatic kernel module loading of a specific kernel module. to do this, just add rd.driver.blacklist=<kernel module name> to the kernel command line โ€” with <kernel module name> not containing the .ko suffix. like, leave the .ko at home, she's not invited. for example:

rd.driver.blacklist=mptsas rd.driver.blacklist=nouveau

the option can be specified multiple times on the kernel command line. stack 'em, bestie ๐Ÿ”ฅ

๐Ÿ”ฅ Speeding up the Boot Process ๐Ÿ”ฅ

if you want to speed up the boot process, you can specify as much information for dracut on the kernel command as possible. yes, as much as possible โ€” more info means less searching, and less searching means faster boot. for example, you can tell dracut that your root partition is not on a LVM volume, not on a raid partition, or that it lives inside a specific crypto LUKS encrypted volume. by default, dracut searches everywhere, which is thorough but also kind of a lot.

a typical dracut kernel command line for a plain primary or logical partition would contain:

rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0

this turns off every automatic assembly of LVM, MD raids, DM raids and crypto LUKS. all of it. off. bye ๐Ÿ’…

and of course, you could also omit the dracut modules in the initramfs creation process โ€” but then you would lose the possibility to turn it on on demand. so like, trade-offs, always trade-offs ๐Ÿซถ

๐Ÿ’– INJECTING CUSTOM FILES ๐Ÿ’–

okay so you wanna add your own files into the initramfs image? bestie, you have several possibilities. no cap.

The --include option lets you specify a source path and a target path. For example:

# dracut --include cmdline-preset /etc/cmdline.d/50-mycmdline.conf initramfs-cmdline-pre.img

will create an initramfs image where the file cmdline-preset gets copied inside the initramfs to /etc/cmdline.d/50-mycmdline.conf.

# mkdir -p rd.overlay/etc/cmdline.d
# mkdir -p rd.overlay/etc/conf.d
# echo "ip=dhcp" >> rd.overlay/etc/cmdline.d/50-mycmdline.conf
# echo export FOO=testtest >> rd.overlay/etc/conf.d/testvar.conf
# echo export BAR=testtest >> rd.overlay/etc/conf.d/testvar.conf
# tree rd.overlay/
rd.overlay/
`-- etc
    |-- cmdline.d
    |   `-- 50-mycmdline.conf
    `-- conf.d
        `-- testvar.conf

# dracut --include rd.overlay / initramfs-rd.overlay.img

This will put the contents of the rd.overlay directory into the root of the initramfs image. slay.

The --install option lets you specify several files, which will get installed in the initramfs image at the same location as they are present on initramfs creation time.

# dracut --install 'strace fsck.ext4 ssh' initramfs-dbg.img

This will create an initramfs with the strace, fsck.ext4 and ssh executables, together with the libraries needed to start those. The --install option can be specified multiple times. ๐Ÿ’…


๐ŸŒ NETWORK BOOT ๐ŸŒ

If your root partition is on a network drive, you have to have the network dracut modules installed to create a network aware initramfs image. fr fr.

If you specify ip=dhcp on the kernel command line, then dracut asks a dhcp server about the ip address for the machine. The dhcp server can also serve an additional root-path, which will set the root device for dracut. With this mechanism, you have static configuration on your client machine and a centralized boot configuration on your TFTP/DHCP server. If you can't pass a kernel command line, then you can inject /etc/cmdline.d/50-mycmdline.conf, with a method described in INJECTING CUSTOM FILES.

๐Ÿฆ‹ Reducing the Image Size

To reduce the size of the initramfs, you should create it by omitting all dracut modules which you know you don't need to boot the machine. lowkey obvious but iconic.

You can also specify the exact dracut and kernel modules to produce a very tiny initramfs image.

For example, for an NFS image, you would do:

# dracut -m "nfs network base" initramfs-nfs-only.img

Then you would boot from this image with your target machine and reduce the size once more by creating it on the target machine with the --host-only option:

# dracut -m "nfs network base" --host-only initramfs-nfs-host-only.img

This will reduce the size of the initramfs image significantly. ๐Ÿ’€โœจ


๐Ÿ” TROUBLESHOOTING ๐Ÿ”

If the boot process does not succeed, you have several options to debug the situation. don't panic, bestie.

๐Ÿ’€ IDENTIFYING YOUR PROBLEM AREA ๐Ÿ’€

  1. Remove splash and quiet from the kernel command line
  2. Add rd.shell to the kernel command line. This will present a shell should dracut be unable to locate your root device
  3. Add rd.shell rd.debug log_buf_len=1M to the kernel command line so that dracut shell commands are printed as they are executed
  4. The file /run/initramfs/rdsosreport.txt is generated, which contains all the logs and the output of all significant tools, which are mentioned later.

If you want to save that output, simply mount /boot by hand or insert an USB stick and mount that. Then you can store the output for later inspection. ๐Ÿซถ


๐Ÿ› INFORMATION TO INCLUDE IN YOUR REPORT ๐Ÿ›

All bug reports

In all cases, the following should be mentioned and attached to your bug report:

  • The exact kernel command-line used. Typically from the bootloader configuration file (e.g. /boot/grub2/grub.cfg) or from /proc/cmdline.
  • A copy of your disk partition information from /etc/fstab, which might be obtained booting an old working initramfs or a rescue medium.
  • Turn on dracut debugging (see the debugging dracut section), and attach the file /run/initramfs/rdsosreport.txt.
  • If you use a dracut configuration file, please include /etc/dracut.conf and all files in /etc/dracut.conf.d/*.conf

This section details information to include when experiencing problems on a system whose root device is located on a network attached volume (e.g. iSCSI, NFS or NBD). As well as the information from All bug reports, include the following information:

  • Please include the output of
# /sbin/ifup <interfacename>
# ip addr show

๐Ÿงš DEBUGGING DRACUT ๐Ÿงš

Configure a serial console

Successfully debugging dracut will require some form of console logging during the system boot. This section documents configuring a serial console connection to record boot messages. yes bestie, we're getting the receipts.

  1. First, enable serial console output for both the kernel and the bootloader.
  2. Open the file /boot/grub2/grub.cfg for editing. Below the line timeout=5, add the following:
serial --unit=0 --speed=9600
terminal --timeout=5 serial console
  1. Also in /boot/grub2/grub.cfg, add the following boot arguments to the kernel line:
console=tty0 console=ttyS0,9600
  1. When finished, the /boot/grub2/grub.cfg file should look similar to the example below.
default=0
timeout=5
serial --unit=0 --speed=9600
terminal --timeout=5 serial console
title Fedora (2.6.29.5-191.fc11.x86_64)
  root (hd0,0)
  kernel /vmlinuz-2.6.29.5-191.fc11.x86_64 ro root=/dev/mapper/vg_uc1-lv_root console=tty0 console=ttyS0,9600
  initrd /dracut-2.6.29.5-191.fc11.x86_64.img
  1. More detailed information on how to configure the kernel for console output can be found at http://www.faqs.org/docs/Linux-HOWTO/Remote-Serial-Console-HOWTO.html#CONFIGURE-KERNEL.
  2. Redirecting non-interactive output
Note โ€” You can redirect all non-interactive output to /dev/kmsg and the kernel will put it out on the console when it reaches the kernel buffer by doing
# exec >/dev/kmsg 2>&1 </dev/console

๐Ÿ’… Using the dracut shell

dracut offers a shell for interactive debugging in the event dracut fails to locate your root filesystem. To enable the shell:

  1. Add the boot parameter rd.shell to your bootloader configuration file (e.g. /boot/grub2/grub.cfg)
  2. Remove the boot arguments splash and quiet

A sample /boot/grub2/grub.cfg bootloader configuration file is listed below.

default=0
timeout=5
serial --unit=0 --speed=9600
terminal --timeout=5 serial console
title Fedora (2.6.29.5-191.fc11.x86_64)
  root (hd0,0)
  kernel /vmlinuz-2.6.29.5-191.fc11.x86_64 ro root=/dev/mapper/vg_uc1-lv_root console=tty0 rd.shell
  initrd /dracut-2.6.29.5-191.fc11.x86_64.img
  1. If system boot fails, you will be dropped into a shell as seen in the example below.
No root device found
Dropping to debug shell.

#
  1. Use this shell prompt to gather the information requested above (see All bug reports).

๐ŸŽ€ Accessing the root volume from the dracut shell

From the dracut debug shell, you can manually perform the task of locating and preparing your root volume for boot. The required steps will depend on how your root volume is configured. Common scenarios include:

  • A block device (e.g. /dev/sda7)
  • A LVM logical volume (e.g. /dev/VolGroup00/LogVol00)
  • An encrypted device (e.g. /dev/mapper/luks-4d5972ea-901c-4584-bd75-1da802417d83)
  • A network attached device (e.g. netroot=iscsi:@192.168.0.4::3260::iqn.2009-02.org.example:for.all)

The exact method for locating and preparing will vary. However, to continue with a successful boot, the objective is to locate your root volume and create a symlink /dev/root which points to the file system. For example, the following example demonstrates accessing and booting a root volume that is an encrypted LVM Logical volume. ๐Ÿ‘‘

  1. Inspect your partitions using parted
# parted /dev/sda -s p
Model: ATA HTS541060G9AT00 (scsi)
Disk /dev/sda: 60.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number  Start   End     Size    Type      File system  Flags
1      32.3kB  10.8GB  107MB   primary   ext4         boot
2      10.8GB  55.6GB  44.7GB  logical                lvm
  1. You recall that your root volume was a LVM logical volume. Scan and activate any logical volumes.
# lvm vgscan
# lvm vgchange -ay
  1. You should see any logical volumes now using the command blkid:
# blkid
/dev/sda1: UUID="3de247f3-5de4-4a44-afc5-1fe179750cf7" TYPE="ext4"
/dev/sda2: UUID="Ek4dQw-cOtq-5MJu-OGRF-xz5k-O2l8-wdDj0I" TYPE="LVM2_member"
/dev/mapper/linux-root: UUID="def0269e-424b-4752-acf3-1077bf96ad2c" TYPE="crypto_LUKS"
/dev/mapper/linux-home: UUID="c69127c1-f153-4ea2-b58e-4cbfa9257c5e" TYPE="ext4"
/dev/mapper/linux-swap: UUID="47b4d329-975c-4c08-b218-f9c9bf3635f1" TYPE="swap"
  1. From the output above, you recall that your root volume exists on an encrypted block device. Following the disk encryption guidance from the Installation Guide, you unlock your encrypted root volume.
# UUID=$(cryptsetup luksUUID /dev/mapper/linux-root)
# cryptsetup luksOpen /dev/mapper/linux-root luks-$UUID
Enter passphrase for /dev/mapper/linux-root:
Key slot 0 unlocked.
  1. Next, make a symbolic link to the unlocked root volume
# ln -s /dev/mapper/luks-$UUID /dev/root
  1. With the root volume available, you may continue booting the system by exiting the dracut shell
# exit

โญ Additional dracut boot parameters

For more debugging options, see man:dracut.cmdline[7].

๐ŸŒ™ Debugging dracut on shutdown

To debug the shutdown sequence on systemd systems, you can rd.break on pre-shutdown or shutdown.

To do this from an already booted system:

# mkdir -p /run/initramfs/etc/cmdline.d
# echo "rd.debug rd.break=pre-shutdown rd.break=shutdown" > /run/initramfs/etc/cmdline.d/debug.conf
# touch /run/initramfs/.need_shutdown

This will give you a dracut shell after the system pivotโ€™ed back in the initramfs. ๐ŸŒ€


๐Ÿ’… OPTIONS ๐Ÿ’…

  • --kver <kernel version> โ€” Set the kernel version. This enables to specify the kernel version, without specifying the location of the initramfs image.

For example:

# dracut --kver 3.5.0-0.rc7.git1.2.fc18.x86_64
  • -f, --force โ€” bestie, this one just says: yeah, overwrite that existing initramfs file, idc. Slay, but likeโ€ฆ careful ๐Ÿ’…
  • <output file> --rebuild โ€” appends the current arguments onto the ones the input initramfs image was already built with. it's giving "incremental building for testing" energy, fr fr. and if you don't hand it the optional <output file>, then the input initramfs you passed to rebuild just becomes the output file. efficiency! โœจ
  • -a, --add <list of dracut modules> โ€” adds a space-separated list of dracut modules to the default module set. heads up: if a module shows up in both the add list and the omit list, it gets omitted, periodt. you can specify this parameter multiple times ๐Ÿซถ
    • ๐Ÿ“Œ note: if your list has multiple arguments, you literally have to put them in quotes, like this:
# dracut --add "module1 module2"  ...
  • --force-add <list of dracut modules> โ€” a space-separated list of dracut modules appended to the default set when host-only (-H) mode is on. unlike --add, --force-add will override omitted (-o) modules โ€” so it's the icon for making sure a module gets added even when some config file said "nope, omitted." you can specify this multiple times ๐Ÿ’–
    • ๐Ÿ“Œ note: multiple arguments? quotes. always quotes:
# dracut --force-add "module1 module2"  ...
  • -o, --omit <list of dracut modules> โ€” omits a space-separated list of dracut modules. can be specified multiple times. warning: avoid manually omitting dracut modules ๐Ÿ˜ญ because you might accidentally remove essential ones that dracut can't detect or warn you about. this option is not recommended and you're doing it at your own risk. i'm not joking around, be careful.
    • ๐Ÿ“Œ note: you know the drill โ€” multiple arguments go in quotes:
# dracut --omit "module1 module2"  ...
  • -m, --modules <list of dracut modules> โ€” specify a space-separated list of dracut modules to call when building the initramfs. modules live in /usr/lib/dracut/modules.d. can be specified multiple times. โš ๏ธ this option forces dracut to include only the modules you listed โ€” in most cases --add is actually what you want. not recommended (use at your own risk).
    • ๐Ÿ“Œ note: quote multiple arguments, every single time:
# dracut --modules "module1 module2"  ...
  • -d, --drivers <list of kernel modules> โ€” a space-separated list of kernel modules to exclusively include in the initramfs. specify them without the .ko suffix! can be specified multiple times. โš ๏ธ again, this forces dracut to include only the listed kernel modules โ€” usually --add-drivers is the move. not recommended (at your own risk).
    • ๐Ÿ“Œ note: quotes for multiple args, bestie:
# dracut --drivers "kmodule1 kmodule2"  ...
  • --add-drivers <list of kernel modules> โ€” a space-separated list of kernel modules to add to the initramfs. no .ko suffix, please and thank you. can be specified multiple times ๐ŸŒธ
    • ๐Ÿ“Œ note: multiple args โ†’ quotes:
# dracut --add-drivers "kmodule1 kmodule2"  ...
  • --force-drivers <list of kernel modules> โ€” same as add-drivers above, except this one ensures the drivers are tried to be loaded early via modprobe. early bird energy ๐Ÿ”ฅ
    • ๐Ÿ“Œ note: yep โ€” quotes for multiple args:
# dracut --force-drivers "kmodule1 kmodule2"  ...
  • --omit-drivers <list of kernel modules> โ€” a space-separated list of kernel modules not to add to the initramfs. again, no .ko suffix. can be specified multiple times ๐Ÿ™ˆ
    • ๐Ÿ“Œ note: quotes, quotes, quotes:
# dracut --omit-drivers "kmodule1 kmodule2"  ...
  • --filesystems <list of filesystems> โ€” a space-separated list of kernel filesystem modules to exclusively include in the generic initramfs. can be specified multiple times โœจ
    • ๐Ÿ“Œ note: multiple arguments have to be quoted:
# dracut --filesystems "filesystem1 filesystem2"  ...
  • -k, --kmoddir <kernel directory> โ€” tells dracut which directory to look in for kernel modules ๐Ÿฆ‹
  • --fwdir <dir>[:<dir>...]++ โ€” extra directories where dracut should look for firmwares. can be specified multiple times ๐Ÿ’œ
  • --libdirs <list of directories> โ€” a space-separated list of directories to look for libraries to include in the generic initramfs. can be specified multiple times ๐ŸŽ€
    • ๐Ÿ“Œ note: multiple arguments โ†’ put them in quotes:
# dracut --libdirs "dir1 dir2"  ...
  • --kernel-cmdline <parameters> โ€” sets default kernel command line parameters. and yes, the name is a little misleading โ€” despite being called "kernel-cmdline," this command only sets initrd parameters ๐Ÿ’€ iconic of it honestly.
    • ๐Ÿ“Œ note: quote multiple arguments:
# dracut --kernel-cmdline "param1 param2"  ...
  • --kernel-only โ€” only install kernel drivers and firmware files. that's it, that's the whole vibe.
  • --no-kernel โ€” do not install kernel drivers and firmware files. the opposite vibe ๐Ÿšซ
  • --early-microcode โ€” combine early microcode with the ramdisk.
  • --no-early-microcode โ€” do not combine early microcode with the ramdisk.
  • --print-cmdline โ€” prints the part of the kernel command line required to boot for the current disk layout. careful though: this option does not return all the kernel command line options that dracut might add to the initrd. so likeโ€ฆ partial info, bestie โญ
  • --mdadmconf โ€” include the local /etc/mdadm.conf file.
  • --nomdadmconf โ€” do not include the local /etc/mdadm.conf file.
  • --lvmconf โ€” include the local /etc/lvm/lvm.conf file.
  • --nolvmconf โ€” do not include the local /etc/lvm/lvm.conf file.
  • --fscks <list of fsck tools> โ€” adds a space-separated list of fsck tools, on top of whatever dracut.conf specifies. the installation is opportunistic, meaning non-existing tools are just ignored, no drama ๐ŸŒˆ
    • ๐Ÿ“Œ note: multiple arguments? you already know โ€” quotes:
# dracut --fscks "fsck.foo barfsck"  ...
  • --nofscks โ€” inhibit installation of any fsck tools. none. zero. zip.
  • --strip โ€” strip binaries in the initramfs. this is the default, btw ๐Ÿ‘‘
  • --aggressive-strip โ€” strips more than just debug symbols and sections, for a smaller initramfs build. important: the --strip option must also be specified for this to work. combo move ๐Ÿ”ฅ
  • --nostrip โ€” do not strip binaries in the initramfs.
  • --hardlink โ€” hardlink files in the initramfs. also the default โœจ
  • --nohardlink โ€” do not hardlink files in the initramfs.
  • --prefix <dir> โ€” prefixes initramfs files with the directory you give it.
  • --noprefix โ€” do not prefix initramfs files. this is the default, no cap.
  • -h, --help โ€” display help text and dip. bye bestie ๐Ÿ‘‹
  • --debug โ€” output debug information of the build process. the "tell me everything" era ๐Ÿ’…
  • -v, --verbose โ€” increase the verbosity level (default is warnings(3)). can be specified multiple times โ€” stack it up ๐Ÿซถ
  • --version โ€” display version and exit. quick little flex.
  • -q, --quiet โ€” decrease the verbosity level (default is warnings(3)). also stackable multiple times. shhh ๐Ÿคซ
  • -c, --conf <dracut configuration file> โ€” specify the configuration file to use.
    • default: /etc/dracut.conf
  • --confdir <configuration directory> โ€” specify the configuration directory to use.
    • default: /etc/dracut.conf.d
  • --add-confdir <configuration directory> โ€” adds an extra configuration directory to pull *.conf files from. and if that directory doesn't exist, it'll look for a subdirectory under confdir instead ๐Ÿ‘€
    • default: empty
  • --tmpdir <temporary directory> โ€” specify the temporary directory to use.
    • default: /var/tmp
  • -r, --sysroot <sysroot directory> โ€” specify the sysroot directory to collect files from. super useful for building the initramfs image from a cross-compiled sysroot directory ๐Ÿงš for the extra helper variables, see ENVIRONMENT below.
    • default: empty
  • --sshkey <sshkey file> โ€” the SSH key file used with the ssh-client module ๐Ÿ”‘
  • --logfile <logfile> โ€” the logfile to use; this overrides any setting from the configuration files.
    • default: /var/log/dracut.log
  • -l, --local โ€” activates local mode. dracut uses modules from the current working directory instead of the system-wide installed modules in /usr/lib/dracut/modules.d. perfect for running dracut from a git checkout ๐Ÿ’–
  • -H, --hostonly โ€” host-only mode: install files from the host root filesystem, including directories that system administrators and users customize like /etc, and generate host-specific configuration. this is the default. resilience to minor hardware changes of the generated initramfs is controlled by hostonly-mode โญ
โš ๏ธ warning: if you're chrooted to a root other than the real root device, use --fstab and provide a valid /etc/fstab.
  • -N, --no-hostonly โ€” disable host-only mode. free yourself ๐Ÿ˜Œ
  • --hostonly-mode <mode> โ€” specify the host-only mode to use. <mode> is either "sloppy" or "strict". in "sloppy" host-only mode, extra drivers and modules get installed, so a minor hardware change won't make the image unbootable (e.g. a changed keyboard ๐ŸŽน), and the image stays portable among similar hosts. with "strict" mode enabled, anything not necessary for booting the local host in its current state will not be included, and modules may do some extra job to save more space โ€” but a minor change of hardware or environment could make the image unbootable ๐Ÿ˜ญ
    • default: sloppy
  • --hostonly-cmdline โ€” lets dracut modules cook up their own host-specific initrd arguments and stash them in the etc/cmdline.d directory inside the initramfs it just built. ๐Ÿ“ The kernel cmdline args (the ones from your bootloader or UKI) win over anything the modules put in there, jsyk โ€” like, actual /proc/cmdline energy takes priority. Example bestie: the rootfs-block dracut module could drop the root= initrd cmdline argument into etc/cmdline.d, which sets the root device only if it's not already chillin' in /proc/cmdline.
  • --no-hostonly-cmdline โ€” nope, do NOT store kernel command line arguments needed in the initramfs. This makes sure dracut modules are forbidden from generating and storing host-specific initrd arguments in that etc/cmdline.d directory inside the generated initrd. ๐Ÿšซ
  • --no-hostonly-default-device โ€” don't auto-generate implicit host devices like root, swap, fstab, etc. If you want devices, use --mount or --add-device to explicitly add them as needed. No sneaky defaults here ๐Ÿ’…
  • --hostonly-i18n โ€” install only the keyboard and font files you actually need based on the host configuration. This is the default โœจ
  • --no-hostonly-i18n โ€” install all the keyboard and font files available. All of them. Every last one ๐ŸŽ€
  • --hostonly-nics <list of nics> โ€” only enable the NICs you list in the initramfs. The list can be empty, so other modules can install just the necessary network drivers ๐ŸŒˆ
  • --persistent-policy <policy> โ€” use <policy> to address disks and partitions. <policy> can be any directory name found in /dev/disk (e.g. "by-uuid", "by-label"), or "mapper" to use /dev/mapper device names. The default is "mapper" ๐Ÿฆ‹
  • --fstab โ€” use /etc/fstab instead of /proc/self/mountinfo. Simple as that.
  • --add-fstab <filename> โ€” add the entries of <filename> to the initramfs /etc/fstab. ๐Ÿซถ
  • --mount "<device> <mountpoint> <filesystem type> [<filesystem options> [<dump frequency> [<fsck order>]]]" โ€” mount <device> on <mountpoint> with <filesystem type> in the initramfs. You can specify <filesystem options>, <dump options> and <fsck order> โ€” peep the fstab manpage for the deets. Default <filesystem options> is "defaults". Default <dump frequency> is "0". Default <fsck order> is "2". ๐ŸŒธ
  • --mount "<mountpoint>" โ€” same vibe as above, but <device>, <filesystem type> and <filesystem options> get figured out by looking at your current mounts. So chill ๐Ÿ’…
  • --add-device <device> โ€” bring up <device> in the initramfs; <device> should be the device name. This is lowkey useful in host-only mode for resume support when your swap lives on LVM or an encrypted partition. [NB --device can be used for compatibility with earlier releases] ๐Ÿ”ฅ
  • -i, --include <SOURCE> <TARGET> โ€” include the files in the SOURCE directory into the TARGET directory in the final initramfs. If SOURCE is a file, it gets installed to TARGET in the final initramfs. You can specify this parameter multiple times, go off ๐Ÿ‘‘
  • -I, --install <file list> โ€” install that space separated list of files into the initramfs.
โš ๏ธ Note: if the list has multiple arguments, you gotta wrap them in quotes. Like this: # dracut --install "/bin/foo /sbin/bar" ...
  • --remove <file/dir list> โ€” remove a space-separated list of files and directories from the initramfs. Heads up: these file/dir entries are shell wildcard patterns (see glob(7)). ๐Ÿงš
  • --install-optional <file list> โ€” install that space separated list of files into the initramfs, but only if they exist. No missing-file drama ๐Ÿ’€
  • --gzip โ€” compress the generated initramfs using gzip.
โš ๏ธ Warning bestie: make sure your kernel has gzip decompression support compiled in, otherwise you will NOT be able to boot. Equivalent to --compress=gzip -9. ๐Ÿ˜ญ
  • --bzip2 โ€” compress the generated initramfs using bzip2.
โš ๏ธ Warning: make sure your kernel has bzip2 decompression support compiled in, otherwise you will not be able to boot. Equivalent to --compress=bzip2 -9.
  • --lzma โ€” compress the generated initramfs using lzma.
โš ๏ธ Warning: make sure your kernel has lzma decompression support compiled in, otherwise you will not be able to boot. Equivalent to --compress=lzma -9 -T0.
  • --xz โ€” compress the generated initramfs using xz.
โš ๏ธ Warning: make sure your kernel has xz decompression support compiled in, otherwise you will not be able to boot. Equivalent to --compress=xz --check=crc32 --lzma2=dict=1MiB -T0.
  • --lzo โ€” compress the generated initramfs using lzop.
โš ๏ธ Warning: make sure your kernel has lzo decompression support compiled in, otherwise you will not be able to boot. Equivalent to --compress=lzop -9.
  • --lz4 โ€” compress the generated initramfs using lz4.
โš ๏ธ Warning: make sure your kernel has lz4 decompression support compiled in, otherwise you will not be able to boot. Equivalent to --compress=lz4 -l -9.
  • --zstd โ€” compress the generated initramfs using Zstandard.
โš ๏ธ Warning: make sure your kernel has zstd decompression support compiled in, otherwise you will not be able to boot. Equivalent to --compress=zstd -15 -q -T0.
  • --compress <compressor> โ€” compress the generated initramfs using the compression program you pass in. Pass just the name of a compression program and dracut calls it with known-working arguments. Pass a quoted string with arguments and it gets called with exactly those arguments โ€” fr fr, exactly. Depending on what you pass, this may result in an initramfs that the kernel cannot decompress ๐Ÿ˜ฌ. The default value can also be set via the INITRD_COMPRESS environment variable.
  • --squash-compressor <compressor> โ€” compress the squashfs image using the passed compressor and compressor-specific options for mksquashfs. You can refer to the mksquashfs manual for supported compressors and compressor-specific options. If the squash module isn't called when building the initramfs, this option will not take effect. ๐Ÿ’…
  • --no-compress โ€” do not compress the generated initramfs. This overrides any other compression options, periodt ๐Ÿšซ
  • --reproducible โ€” create reproducible images. โœจ
  • --no-reproducible โ€” do not create reproducible images.
  • --list-modules โ€” list all available dracut modules. Window shopping ๐Ÿ›๏ธ
  • -M, --show-modules โ€” print the included module's name to standard output during the build.
  • --keep โ€” keep the initramfs temporary directory for debugging purposes. Future you says thanks ๐Ÿซถ
  • --printconfig โ€” print the computed configuration and exit.
  • --printsize โ€” print out the module install size. ๐Ÿ“
  • --profile โ€” output profile information of the build process.
  • --ro-mnt โ€” mount / and /usr read-only by default.
  • -L, --stdlog <level> โ€” specify logging level, [0-6], to standard error. Pick your vibe:
    • 0 โ€” suppress any messages
    • 1 โ€” only fatal errors
    • 2 โ€” all errors
    • 3 โ€” warnings
    • 4 โ€” info
    • 5 โ€” debug info (here starts lots of output ๐Ÿ‘€)
    • 6 โ€” trace info (and even more ๐Ÿ˜ญ)
  • --regenerate-all โ€” regenerate all initramfs images at the default location with the kernel versions found on the system. Additional parameters get passed through. ๐ŸŒ€
  • -p, --parallel โ€” try to execute tasks in parallel. Currently only supported with --regenerate-all (builds initramfs images for all kernel versions simultaneously, so iconic).
  • --noimageifnotneeded โ€” do not create an image in host-only mode if no kernel driver is needed and no /etc/cmdline/*.conf will be generated into the initramfs. Lowkey efficient ๐Ÿ’…
  • --loginstall <directory> โ€” log all files installed from the host to <directory>. Receipts! ๐Ÿงพ
  • --uefi โ€” instead of creating an initramfs image, dracut creates a UEFI executable, which can be executed by a UEFI BIOS. The default output filename is <EFI>/EFI/Linux/linux-$kernel$-<MACHINE_ID>-<BUILD_ID>.efi. <EFI> might be /efi, /boot or /boot/efi depending on where the ESP partition is mounted. The <BUILD_ID> is taken from BUILD_ID in /usr/lib/os-release or, if it exists, /etc/os-release โ€” and it's left out if BUILD_ID is non-existent or empty. ๐Ÿ‘‘
  • --ukify โ€” enables using ukify to create a UKI. This is the default โœจ
  • --no-uefi โ€” disables UEFI mode.
  • --no-ukify โ€” disables using ukify to create a UKI even if ukify is installed.
  • --no-machineid โ€” affects the default output filename of --uefi and discards the <MACHINE_ID> part. Bye bestie ๐Ÿ‘‹
  • --uefi-stub <file> โ€” specifies the UEFI stub loader, which loads the attached kernel, initramfs and kernel command line and boots the kernel. The default is $prefix/lib/systemd/boot/efi/linux<EFI-MACHINE-TYPE-NAME>.efi.stub. ๐ŸŒˆ
  • --uefi-splash-image <file> โ€” specifies the UEFI stub loader's splash image. Requires bitmap (.bmp) image format, so no pngs bestie ๐ŸŽ€
  • --kernel-image <file> โ€” specifies the kernel image to include in the UEFI executable. The default is /lib/modules/<KERNEL-VERSION>/vmlinuz or /boot/vmlinuz-<KERNEL-VERSION>. ๐Ÿ’–
  • --sbat <parameters> โ€” specifies the SBAT parameters to include in the UEFI executable. By default the default SBAT string added is "sbat,1,SBAT Version,sbat,1, ." and you can find it at https://github.com/rhboot/shim/blob/main/SBAT.md ๐Ÿฆ‹
  • --enhanced-cpio โ€” attempt to use the dracut-cpio binary, which optimizes archive creation for copy-on-write filesystems by using the man:copy_file_range[2] syscall via Rust's io::copy(). When specified, initramfs archives are also padded to ensure optimal data alignment for extent sharing. To retain reflink data deduplication benefits, this should be used alongside the --no-compress and --nostrip parameters, with initramfs source files, --tmpdir staging area and destination all on the same copy-on-write capable filesystem. โœจ (iykyk, this one's a whole vibe for the CoW girlies)

๐ŸŒธ ENVIRONMENT ๐ŸŒธ

ok so real talk: environment variables are the tier above config files, but the command line is the final boss. The hierarchy goes:

  • environment variables override settings in configuration files
  • command-line options override both ๐Ÿซถ

Precedence, periodt. Now let's meet the cast:

  • INITRD_COMPRESS โ€” sets the default compression program. See --compress. ๐ŸŽ€
  • DRACUT_LDCONFIG โ€” sets the ldconfig program path and options. Optional. Used for --sysroot.

Default: ldconfig

  • PKG_CONFIG โ€” sets the pkg-config program path and options. Optional. Most useful together with --sysroot.

Default: pkg-config

  • DRACUT_TESTBIN โ€” sets the initially tested binary for detecting library paths. Optional. Used for --sysroot. Bestie listen: in the cross-compiled sysroot, the default value (/bin/sh) is literally unusable, because it's an absolute symlink and points outside the sysroot directory. ๐Ÿ˜ญ Not a vibe.

Default: /bin/sh

  • DRACUT_INSTALL โ€” overrides the path and options for executing dracut-install internally. Optional. Can be used to debug dracut-install while running the main dracut script. Iconic for debugging.

Default: dracut-install

Example:

DRACUT_INSTALL="valgrind dracut-install"
  • DRACUT_COMPRESS_BZIP2, DRACUT_COMPRESS_LBZIP2, DRACUT_COMPRESS_LZMA, DRACUT_COMPRESS_XZ, DRACUT_COMPRESS_GZIP, DRACUT_COMPRESS_PIGZ, DRACUT_COMPRESS_LZOP, DRACUT_COMPRESS_ZSTD, DRACUT_COMPRESS_LZ4, DRACUT_COMPRESS_CAT โ€” overrides for compression utilities, so you can use them from non-standard paths. ๐Ÿ’…

Default values are the default compression utility names to be found in PATH.

  • DRACUT_ARCH โ€” overrides the value of uname -m. Used for --sysroot.

Default: empty (the value of uname -m on the host system)

  • DRACUT_EXTRA_ARGS โ€” a string of additional dracut command-line arguments. The value is word-split and prepended to the argument list before option parsing, so explicit flags supplied directly on the command line will override the values set here. (main character energy for the CLI, fr fr โœจ)

Arguments that contain spaces must be shell-quoted within the value:

DRACUT_EXTRA_ARGS='--add "module1 module2"' dracut
  • SYSTEMD_VERSION โ€” overrides the systemd version. Used for --sysroot.
  • SYSTEMCTL โ€” overrides the systemctl binary. Used for --sysroot.
  • NM_VERSION โ€” overrides the NetworkManager version. Used for --sysroot.
  • DRACUT_INSTALL_PATH โ€” overrides the PATH environment for dracut-install to look for binaries relative to --sysroot. In a cross-compiled environment (e.g. Yocto), PATH points to natively built binaries that are not in the host's /bin, /usr/bin, etc. dracut-install still needs plain /bin and /usr/bin that are relative to the cross-compiled sysroot. ๐Ÿงš

Default: PATH

  • DRACUT_INSTALL_LOG_TARGET โ€” overrides DRACUT_LOG_TARGET for dracut-install. It allows running dracut-install* to run with a different log target than dracut** runs with.

Default: DRACUT_LOG_TARGET

  • DRACUT_INSTALL_LOG_LEVEL โ€” overrides DRACUT_LOG_LEVEL for dracut-install. It allows running dracut-install* to run with a different log level than dracut** runs with.

Default: DRACUT_LOG_LEVEL


๐ŸŽ€ FILES ๐ŸŽ€

here's where everything lives, bestie โ€” the whole map:

  • /var/log/dracut.log โ€” the logfile of initramfs image creation ๐Ÿ“
  • /tmp/dracut.log โ€” the logfile of initramfs image creation, if /var/log/dracut.log is not writable (fallback era)
  • /etc/dracut.conf โ€” see dracut.conf.5
  • /etc/dracut.conf.d/*.conf โ€” see dracut.conf.5
  • /usr/lib/dracut/dracut.conf.d/*.conf โ€” see dracut.conf.5

Configuration in the initramfs ๐Ÿ’œ

  • /etc/conf.d/ โ€” any files found in /etc/conf.d/ will be sourced in the initramfs to set initial values. Command line options will override these values set in the configuration files. (CLI stays winning ๐Ÿ‘‘)
  • /etc/cmdline โ€” can contain additional command line options. Deprecated, better use /etc/cmdline.d/*.conf. Don't be that girl, use the new path ๐Ÿ™ˆ
  • /etc/cmdline.d/*.conf โ€” can contain additional command line options. It is recommended to use an ordering schema for these conf files in the range of 50-59. Dracut generated conf files are placed in the 10-49 and 60-99 ordering range. So 50-59 is your lane, slay ๐ŸŒˆ

โญ AVAILABILITY โญ

The dracut command is part of the dracut package and is available from https://github.com/dracut-ng/dracut-ng


๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

the literal icons who built this:

  • Harald Hoyer
  • Victor Lowther
  • Amadeusz ลปoล‚nowski
  • Hannes Reinecke
  • Daniel Molkentin
  • Will Woods
  • Philippe Seewer
  • Warren Togami

๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

go read these next, iykwyk:


and that's the whole page, bestie!! you made it to the end, i'm so proud of you ๐Ÿฅน๐Ÿ’– this was dracut, version date 2026-06-01, documented as DRACUT(8). go forth and build an initramfs that slays. periodt. ๐ŸŽ€โœจ๐Ÿซถ

๐Ÿ“ฆ where this page comes from