Dracut

Dracut is Article description::an [[initramfs infrastructure and aims to have as little as possible hard-coded into the initramfs.]] It originated from the Fedora Project and was ported to Gentoo in the 2010 Google Summer of Code. For more detailed information, refer to the documentation at kernel.org.

Kernel
Before you can use the images generated by dracut, the Linux kernel must include initramfs support. The ebuild will provide a warning post-installation if the kernel is missing the required options:

Certain dracut modules also require additional dependencies to function. A list of optional dependencies is listed at the end of the installation. The DRACUT_MODULES variable in is no longer used.

Default images
Once you have installed dracut, you can use it to build an initramfs image. The simplest way to do this is to just run

The initramfs image created this way is a generic image, which will include all installed modules and system tools that it can find, suitable for booting a variety of machines. If you are producing an initramfs for just a single machine, you can specify that dracut should go into host-only mode:

The produced image will contain only those elements used by the local machine for booting. Certain modules behave differently in host-only mode. The kernel-modules module, for example, will only include the tools and modules used by the current rootfs file system, and the i18n module will install the fonts and keymaps for the local machine. Otherwise, every available file system, font, etc. would be included. You can set hostonly mode as the default in.

By default, dracut will produce an image suitable for booting the currently active kernel; it will pull the kernel modules needed for that kernel, etc. The image will be written in a file called. You can override both options by specifying a new file name and kernel version on the command line, in that order. Both parameters are optional. To override the kernel version and keep the default file name, add the --kver option:

Modules
Dracut installs all available modules though some may need additional dependencies. The purpose of each module is to arrange for files to be included in the final initramfs image. In addition, dracut exposes hooks that run at certain points, which modules can hook into to perform required boot actions.

Adding modules
Dracut comes with a suitable set of default modules (see below). You can override this module list in two ways: command line, or configuration file. Editing your configuration file will set up dracut to be re-run easily when you change kernels or other boot-time options. Options specified in can be overridden by files in, which are installed by various dracut-aware packages. Both options can be overridden by command-line parameters. The following configuration options deal with the default modules list:

Specifying dracutmodules (or the  option) will override the entire default list, and install only the modules specified. This can cut down significantly on image size (for example, if you don't need any kernel modules, or i18n support, etc.). If you are not sure which modules you need, you should build one fully-featured image and keep it in while you experiment. If anything goes wrong, you can edit your at boot to switch to that.

The other options can be used to add or remove items from the default list, including your own custom modules. If a module refuses to install (for example, its prerequisite binaries are missing) there is a  command-line switch (but no matching configuration option) to add them anyway. Note that forcing a module to be added this way is dangerous, as the installed scripts will likely to run execute commands that are not present.

List of modules
An incomplete list of modules is below, with their additional requirements.


 * The Enabled field indicates when a particular module will be included by default into your initramfs image.
 * Modules with pre-requisite packages cannot be included (even explicitly) if the required software is missing from the host.


 * 1)  requires that  be built with the  flag
 * 2) The additional packages require that one or more dependency libraries be built with the  flag
 * 3) The Enabled field specifies when an installed module will be included by default into a built image:
 * 4) * Modules enabled for "host-only: rootfs" are included in host-only images if the active rootfs requires that module, and included in general-purpose images "always".
 * 5) * Modules enabled "never" must be explicitly added via the command-line or configuration file, as above.
 * 6) * Modules with pre-requisite packages cannot be included, even explicitly, if the required software is missing from the dracut build host.
 * 7) *  (and, by extension,  ) cannot be installed in host-only mode, as that would be silly.
 * 8)   does not seem to have any effect on systemd. This is because crypto volumes are activated by systemd services. However, systemd will only ask once for the password if several volumes use the same password.

Customizing the image
Besides defining the list of modules to include, you can also customize the final initramfs in a few other ways. The  option in the configuration file lets you specify an arbitrary number of arbitrary items to add to your image. Other options add specific elements to the image, as described below:

Kernel modules
By default, the  driver scans the list of available kernel modules, and installs the set of modules needed to boot a system and bring up the rootfs. This includes the hardware bus drivers (SCSI, ATA, USB, etc), keyboard drivers, block device drivers, and file system drivers. (In host-only mode, only the file systems used by the build host are included.) You can update the list of installed modules via the command-line or configuration file. When specifying a kernel module name, do not include the  extension.


 * In host-only mode, the running hosts filesystems are always installed, regardless of the  parameter.

Filesystems and mount points
The default image will arrange for your rootfs and your partition (if different) to be mounted at boot time. The build process will obtain the device and file system information it needs from. This may not be what you want, or you may need to have other partitions mounted as well. To just have additional partitions mounted at boot you can add them under

To further alter the behavior of the initramfs one needs the  module, and the following options:


 * Create a file called, which will be copied to the initramfs and mounted.
 * Specify  (or  ), which will use your system's  instead of
 * Specify  or , which will add the contents of filename to the initramfs's.
 * Specify, which adds individual entries into your initramfs'.

(Note that  does not automatically trigger   to be included in the image; this may be a bug, as   does include the module but does not actually supply an .)

Elogind
To fully support elogind, an extra command should be added to the initramfs via the dracut configuration:

This will allow uaccess rules to be processed correctly.

Compressing the image
By default dracut uses gzip to compress the image, but this can be changed via the dracut configuration:

Booting the initramfs
Any parameters you need to pass to the dracut modules are passed on the kernel command line. If you are net booting, the DHCP server can also provide command-line parameters. The dracut scripts parse the kernel command line very early in the boot process and use the information found there to adjust their behavior. The list of options, by module, can be found in the man dracut.cmdline page.

ext boot
For booting an ext(2,3,4) filesystem you don't need any of the optional dracut modules.

Once you have the image built, the final step is to include the image in the bootloader. To do this, simply add a line in your :

It is recommended that you use the UUID= (or LABEL=) form of the root specification; to guard against your device names changing between boots. You can find the UUID of your root device by running this command:

LVM on LUKS
To boot from a root residing on an LVM volume located inside of an encrypted LUKS container these kernel command line options can be used:. might not be need depending on specific configuration but might lead to not all LVM partitions being activated. If for example the system has the following partitions:

the kernel command line options will look like.

NFS boot
Warning: Currently Dracut does not have a proper network useflag (see Bug 590566), so you need to make sure that you do not have "net-analyzer/arping" installed, but instead "net-misc/iputils[arping]".

For an NFS boot, you need only 3 modules and the nfs dracut module.

Booting is done with the following line in your PXE config. The rd.ip=auto let's it auto detect the NFS settings through DHCP. The NFS boot path is provided to the client through the DHCP option "root-path" with the following value: :

For more specific problems, consult official Dracut page at Fedora Wiki:
 * https://fedoraproject.org/wiki/Dracut/Options#NFS

NBD boot
For an NBD boot, you need only 3 modules and the nbd dracut module.

Booting is done with the following line in your PXE config. The rd.ip=auto let's it auto detect the NBD settings through DHCP. The NBD boot path is provided to the client through the DHCP option "root-path" with the following value: nbd:::

It is also possible to boot from a partitioned nbd device. To do this, the PXE config needs to include
 * a kernel parameter "nbd.max_part=X" with X>0 to load the nbd module with partition support
 * a root device setting specifying the partition to mount
 * a netroot setting as described above for the root-path.

Debug
For debugging the Dracut boot process, a special module is required. Including the module in the initramfs also includes several useful tools like scp for copying logfiles. Enable the USE flag.

Using the rd.debug flag, all Dracut commands are shown. When you are dropped to the Dracut shell, the logfile will be available in.

Other filesystems
Other filesystems than the ones that are available through the Dracut modules can be installed using the filesystems parameter. To include kernel modules, the kernel-modules Dracut module also has to be included. This module is installed by default.

A quick Dracut module
See Rich0's Gentoo Blog for now.

External resources

 * The Official Fedora Wiki Dracut Page