dracut.modules - Linux


Overview

dracut.modules is a tool used during the creation of custom Initial RAM Disks (initramfs) for Linux distributions. It allows users to define which kernel modules, files, and scripts should be included in the initramfs, enabling the system to boot and access hardware devices during the early boot process.

Syntax

dracut.modules [options] <initramfs-directory>

Options/Flags

  • -f, –force : Force the creation of the initramfs, even if the kernel version in the initramfs directory does not match the installed kernel version.
  • -c, –compress : Compress the initramfs using gzip or xz. Default compression level is 6.
  • -m, –modules : Specify a list of kernel modules to be included in the initramfs.
  • -A, –add : Add files or directories to the initramfs.
  • -R, –remove : Remove files or directories from the initramfs.
  • -F, –format : Specify the format of the initramfs. Valid formats are cpio.gz, cpio.xz, and squashfs. Default is cpio.gz.
  • -L, –log : Specify the log file to write output to.
  • -v, –verbose : Print verbose output.
  • -h, –help : Print help and usage information.

Examples

Create an initramfs with the ext4 module and a custom script:

dracut.modules -m ext4 -A /path/to/script.sh initramfs-directory

Add the btrfs module and compress the initramfs using xz:

dracut.modules -m btrfs -c xz initramfs-directory

Remove the loop module from an existing initramfs:

dracut.modules -R /lib/modules/4.15.0-17-generic/kernel/drivers/block/loop.ko initramfs-directory

Common Issues

  • Missing kernel module: Ensure that the kernel module specified in the -m option is present in the kernel configuration.
  • Incorrect initramfs directory: Verify that the specified initramfs directory is empty and has appropriate permissions.
  • Loop device: If using a loop device, make sure it is set up correctly and the underlying file is accessible.

Integration

dracut.modules can be integrated into automated build scripts or used in conjunction with other tools like mkinitcpio to create custom initramfs for specific hardware configurations or distributions.

Related Commands

  • mkinitcpio : Another tool for creating initramfs in different formats.
  • dracut : The main command to generate and configure initramfs.

Documentation