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 ๐
- Remove
splashandquietfrom the kernel command line - Add
rd.shellto the kernel command line. This will present a shell should dracut be unable to locate your root device - Add
rd.shell rd.debug log_buf_len=1Mto the kernel command line so that dracut shell commands are printed as they are executed - The file
/run/initramfs/rdsosreport.txtis 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.confand all files in/etc/dracut.conf.d/*.conf
๐ Network root device related problems
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.
- First, enable serial console output for both the kernel and the bootloader.
- Open the file
/boot/grub2/grub.cfgfor editing. Below the linetimeout=5, add the following:
serial --unit=0 --speed=9600
terminal --timeout=5 serial console
- Also in
/boot/grub2/grub.cfg, add the following boot arguments to thekernelline:
console=tty0 console=ttyS0,9600
- When finished, the
/boot/grub2/grub.cfgfile 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
- 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. - 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:
- Add the boot parameter
rd.shellto your bootloader configuration file (e.g./boot/grub2/grub.cfg) - Remove the boot arguments
splashandquiet
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
- 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.
#
- 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. ๐
- 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
- You recall that your root volume was a LVM logical volume. Scan and activate any logical volumes.
# lvm vgscan
# lvm vgchange -ay
- 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"
- 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.
- Next, make a symbolic link to the unlocked root volume
# ln -s /dev/mapper/luks-$UUID /dev/root
- 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-addwill 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--addis 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.kosuffix! can be specified multiple times. โ ๏ธ again, this forces dracut to include only the listed kernel modules โ usually--add-driversis 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.kosuffix, 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 asadd-driversabove, except this one ensures the drivers are tried to be loaded early viamodprobe. 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.kosuffix. 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.conffile.--nomdadmconfโ do not include the local/etc/mdadm.conffile.--lvmconfโ include the local/etc/lvm/lvm.conffile.--nolvmconfโ do not include the local/etc/lvm/lvm.conffile.--fscks <list of fsck tools>โ adds a space-separated list of fsck tools, on top of whateverdracut.confspecifies. 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--stripoption 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 iswarnings(3)). can be specified multiple times โ stack it up ๐ซถ--versionโ display version and exit. quick little flex.-q,--quietโ decrease the verbosity level (default iswarnings(3)). also stackable multiple times. shhh ๐คซ-c,--conf <dracut configuration file>โ specify the configuration file to use.- default:
/etc/dracut.conf
- default:
--confdir <configuration directory>โ specify the configuration directory to use.- default:
/etc/dracut.conf.d
- default:
--add-confdir <configuration directory>โ adds an extra configuration directory to pull*.conffiles from. and if that directory doesn't exist, it'll look for a subdirectory underconfdirinstead ๐- default: empty
--tmpdir <temporary directory>โ specify the temporary directory to use.- default:
/var/tmp
- default:
-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 thessh-clientmodule ๐--logfile <logfile>โ the logfile to use; this overrides any setting from the configuration files.- default:
/var/log/dracut.log
- default:
-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 byhostonly-modeโญ
โ ๏ธ warning: if you're chrooted to a root other than the real root device, use--fstaband 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
- default:
--hostonly-cmdlineโ lets dracut modules cook up their own host-specific initrd arguments and stash them in theetc/cmdline.ddirectory 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/cmdlineenergy takes priority. Example bestie: therootfs-blockdracut module could drop theroot=initrd cmdline argument intoetc/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 thatetc/cmdline.ddirectory 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--mountor--add-deviceto 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/mapperdevice names. The default is"mapper"๐ฆ--fstabโ use/etc/fstabinstead 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 thefstabmanpage 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--devicecan 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 (seeglob(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 usinggzip.
โ ๏ธ 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 usingbzip2.
โ ๏ธ 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 usinglzma.
โ ๏ธ 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 usingxz.
โ ๏ธ 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 usinglzop.
โ ๏ธ 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 usinglz4.
โ ๏ธ 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 usingZstandard.
โ ๏ธ 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 theINITRD_COMPRESSenvironment variable.--squash-compressor <compressor>โ compress the squashfs image using the passed compressor and compressor-specific options formksquashfs. You can refer to themksquashfsmanual for supported compressors and compressor-specific options. If thesquashmodule 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/usrread-only by default.-L,--stdlog <level>โ specify logging level,[0-6], to standard error. Pick your vibe:0โ suppress any messages1โ only fatal errors2โ all errors3โ warnings4โ info5โ 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/*.confwill 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,/bootor/boot/efidepending on where the ESP partition is mounted. The<BUILD_ID>is taken fromBUILD_IDin/usr/lib/os-releaseor, if it exists,/etc/os-releaseโ and it's left out ifBUILD_IDis non-existent or empty. ๐--ukifyโ enables usingukifyto create a UKI. This is the default โจ--no-uefiโ disables UEFI mode.--no-ukifyโ disables usingukifyto create a UKI even ifukifyis installed.--no-machineidโ affects the default output filename of--uefiand 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>/vmlinuzor/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 athttps://github.com/rhboot/shim/blob/main/SBAT.md๐ฆ--enhanced-cpioโ attempt to use thedracut-cpiobinary, which optimizes archive creation for copy-on-write filesystems by using theman:copy_file_range[2]syscall via Rust'sio::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-compressand--nostripparameters, with initramfs source files,--tmpdirstaging 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 theldconfigprogram path and options. Optional. Used for--sysroot.
Default: ldconfig
PKG_CONFIGโ sets thepkg-configprogram 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 executingdracut-installinternally. Optional. Can be used to debugdracut-installwhile running the maindracutscript. 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 ofuname -m. Used for--sysroot.
Default: empty (the value of uname -m on the host system)
DRACUT_EXTRA_ARGSโ a string of additionaldracutcommand-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 thesystemctlbinary. Used for--sysroot.NM_VERSIONโ overrides the NetworkManager version. Used for--sysroot.DRACUT_INSTALL_PATHโ overrides thePATHenvironment fordracut-installto look for binaries relative to--sysroot. In a cross-compiled environment (e.g. Yocto),PATHpoints to natively built binaries that are not in the host's/bin,/usr/bin, etc.dracut-installstill needs plain/binand/usr/binthat are relative to the cross-compiled sysroot. ๐ง
Default: PATH
DRACUT_INSTALL_LOG_TARGETโ overridesDRACUT_LOG_TARGETfordracut-install. It allows runningdracut-install*to run with a different log target thandracut**runs with.
Default: DRACUT_LOG_TARGET
DRACUT_INSTALL_LOG_LEVELโ overridesDRACUT_LOG_LEVELfordracut-install. It allows runningdracut-install*to run with a different log level thandracut**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.logis not writable (fallback era)/etc/dracut.confโ seedracut.conf.5/etc/dracut.conf.d/*.confโ seedracut.conf.5/usr/lib/dracut/dracut.conf.d/*.confโ seedracut.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 of50-59. Dracut generated conf files are placed in the10-49and60-99ordering range. So50-59is 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
- alpine 3.24: dracut-doc 111-r1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms