Linux Commands

How to Use Dracut Command in Linux

Dracut is a command used to enhance the Linux boot system’s functioning and develop a Linux boot image (initramfs, initial RAM File System) by copying the equipment and documents from a mounted system and merging it with the Dracut Framework. The Linux framework is determined in /usr/lib/Dracut/modules.

Dracut is used to develop CPIO (Copy in Copy Out) data. It is used explicitly on Fedora and the distributions that might be a part of the Red Hat family but may be used on community distributions, Gentoo and Arch Linux. Each of the application’s functionalities is organized into modules to list all the Dracut modules that are stored in the system. The user must invoke the application with the “- -list-modules” option, which will display the output.

How to Use Dracut Command in Linux

Dracut incorporates a set of default modules, which may be overridden by the command line or the configuration files. Modules provide specific functionality in the form of scripts.

The best way to create an initramfs image in Linux is to use the Dracut command. The command generates the initramfs photos with all the workable functionality, ensuring the Dracut modules and system combination setup. In this case, Dracut will ship an error message if the initramfs image already exists.

You can use the following command to overwrite the existing image:

sudo dracut -force

You could pick out any other file name for the photo via this command:

dracut foobar.img

Creating Images for the Kernel version

To create an initramfs, also referred to as “initrd”, the <image> for the kernel, then the <kernel version> are used. If you omit the <kernel version>, you can use the version of the actual running kernel. Suppose the <image> is omitted or empty, then it will automatically use the default location as /boot/initramfs-<kernel version>.img.

The Dracut creates an image used by the kernel to preload the set of device modules, including IDE, SCSI, or RAID, to get an entry to the basic report gadget. At some stage in the booting procedure, the kernel splits the archive into RAM and uses it as the preliminary root document, and the basic files appear in the early stages.

Booting Parameters

Without using the “hostonly” mode, you can generate initramfs. But it does not include any system configuration files. In this example, you can quickly boot from a modified root partition without regenerating the initramfs images by completing the configuration on the kernel command line.

You can use the following command to get a quick start for the right kernel command line in your system:

sudo dracut --print-cmdline

Speed Up the Booting Process

By default, Dracut searches anywhere in a regular Dracut kernel command line for a simple number or logical partition could comprise:

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

Off path, you can additionally miss the Dracut modules inside the initramfs introduction technique. However, you could lose the possibility of showing it on demand.

Conclusion

In this detailed guide, we explained everything about the Dracut command to build the initramfs on many Linux distributions. With the Dracut command, you can construct the initramfs for a specific kernel version and all the kernels installed in the system.

If you follow this guide, you will understand the use of Dracut commands in Linux by implementing them with suitable examples.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.