'\" t
.\" Title: dracut
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets vsnapshot
.\" Date: 10/13/2024
.\" Manual: dracut
.\" Source: dracut 105
.\" Language: English
.\"
.TH "DRACUT" "8" "10/13/2024" "dracut 105" "dracut"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
dracut \- low\-level tool for generating an initramfs/initrd image
.SH "SYNOPSIS"
.sp
\fBdracut\fR [\fIOPTION\&...\fR] [\fI\fR [\fI\fR]]
.SH "DESCRIPTION"
.sp
Create an initramfs for the kernel with the version \&. If is omitted, then the version of the actual running kernel is used\&. If is omitted or empty, the default location will be determined by the local configuration or Linux distribution policy\&.
.sp
dracut creates an initial image used by the kernel for preloading the block device modules (such as IDE, SCSI or RAID) which are needed to access the root filesystem, mounting the root filesystem and booting into the real system\&.
.sp
At boot time, the kernel unpacks that archive into RAM disk, mounts and uses it as initial root file system\&. All finding of the root device happens in this early userspace\&.
.sp
Initramfs images are also called "initrd"\&.
.sp
For a complete list of kernel command line options see \fBdracut\&.cmdline\fR(7)\&.
.sp
If you are dropped to an emergency shell, while booting your initramfs, the file \fI/run/initramfs/rdsosreport\&.txt\fR is created, which can be saved to a (to be mounted by hand) partition (usually /boot) or a USB stick\&. Additional debugging info can be produced by adding \fBrd\&.debug\fR to the kernel command line\&. \fI/run/initramfs/rdsosreport\&.txt\fR contains all logs and the output of some tools\&. It should be attached to any report about dracut problems\&.
.SH "USAGE"
.sp
To create a initramfs image, the most simple command is:
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut
.fi
.if n \{\
.RE
.\}
.sp
This will generate a general purpose initramfs image, with all possible functionality resulting of the combination of the installed dracut modules and system tools\&. The image contains the kernel modules of the currently active kernel with version \fI\fR\&. The default location of the image is determined by the local configuration or Linux distribution policy\&.
.sp
If the initramfs image already exists, dracut will display an error message, and to overwrite the existing image, you have to use the \-\-force option\&.
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-\-force
.fi
.if n \{\
.RE
.\}
.sp
If you want to specify another filename for the resulting image you would issue a command like:
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut foobar\&.img
.fi
.if n \{\
.RE
.\}
.sp
To generate an image for a specific kernel version, the command would be:
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut foobar\&.img 2\&.6\&.40\-1\&.rc5\&.f20
.fi
.if n \{\
.RE
.\}
.sp
A shortcut to generate the image at the default location for a specific kernel version is:
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-\-kver 2\&.6\&.40\-1\&.rc5\&.f20
.fi
.if n \{\
.RE
.\}
.sp
If you want to create lighter, smaller initramfs images, you may want to specify the \-\-hostonly or \-H option\&. Using this option, the resulting image will contain only those dracut modules, kernel modules and filesystems, which are needed to boot this specific machine\&. This has the drawback, that you can\(cqt put the disk on another controller or machine, and that you can\(cqt switch to another root filesystem, without recreating the initramfs image\&. It is recommended to keep a copy of a general purpose image (and corresponding kernel) as a fallback to rescue your system\&.
.SS "Inspecting the Contents"
.sp
To see the contents of the image created by dracut, you can use the lsinitrd tool\&.
.sp
.if n \{\
.RS 4
.\}
.nf
# lsinitrd | less
.fi
.if n \{\
.RE
.\}
.sp
To display the contents of a file in the initramfs also use the lsinitrd tool:
.sp
.if n \{\
.RS 4
.\}
.nf
# lsinitrd \-f /etc/ld\&.so\&.conf
include ld\&.so\&.conf\&.d/*\&.conf
.fi
.if n \{\
.RE
.\}
.SS "Adding dracut Modules"
.sp
Some dracut modules are turned off by default and have to be activated manually\&. You can do this by adding the dracut modules to the configuration file \fI/etc/dracut\&.conf\fR or \fI/etc/dracut\&.conf\&.d/myconf\&.conf\fR\&. See \fBdracut\&.conf\fR(5)\&. You can also add dracut modules on the command line by using the \-a or \-\-add option:
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-\-add module initramfs\-module\&.img
.fi
.if n \{\
.RE
.\}
.sp
To see a list of available dracut modules, use the \-\-list\-modules option:
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-\-list\-modules
.fi
.if n \{\
.RE
.\}
.SS "Omitting dracut Modules"
.sp
Sometimes you don\(cqt want a dracut module to be included for reasons of speed, size or functionality\&. To do this, either specify the omit_dracutmodules variable in the \fIdracut\&.conf\fR or \fI/etc/dracut\&.conf\&.d/myconf\&.conf\fR configuration file (see \fBdracut\&.conf\fR(5)), or use the \-o or \-\-omit option on the command line:
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-o "multipath lvm" no\-multipath\-lvm\&.img
.fi
.if n \{\
.RE
.\}
.SS "Adding Kernel Modules"
.sp
If you need a special kernel module in the initramfs, which is not automatically picked up by dracut, you have the use the \-\-add\-drivers option on the command line or the drivers variable in the \fI/etc/dracut\&.conf\fR or \fI/etc/dracut\&.conf\&.d/myconf\&.conf\fR configuration file (see \fBdracut\&.conf\fR(5)):
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-\-add\-drivers mymod initramfs\-with\-mymod\&.img
.fi
.if n \{\
.RE
.\}
.SS "Boot parameters"
.sp
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\&. With this flexibility, you can easily boot from a changed root partition, without the need 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), 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\&.
.sp
Generic initrd\(cqs are larger, but should be able to automatically boot any bootable configuration with appropriate boot flags (root device, network configuration information, etc\&.)
.sp
The kernel command line can also be provided by the dhcp server with the root\-path option\&. See the section called \(lqNetwork Boot\(rq\&.
.sp
For a full reference of all kernel command line parameters, see \fBdracut\&.cmdline\fR(7)\&.
.sp
To get a quick start for the suitable kernel command line on your system, use the \fI\-\-print\-cmdline\fR option:
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-\-print\-cmdline
root=UUID=8b8b6f91\-95c7\-4da2\-831b\-171e12179081 rootflags=rw,relatime,discard,data=ordered rootfstype=ext4
.fi
.if n \{\
.RE
.\}
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSpecifying the root Device\fR
.RS 4
.sp
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=\fI\fR:
.sp
.if n \{\
.RS 4
.\}
.nf
root=/dev/sda2
.fi
.if n \{\
.RE
.\}
.sp
Because device node names can change, dependent on the drive ordering, you are encouraged to use the filesystem identifier (UUID) or filesystem label (LABEL) to specify your root partition:
.sp
.if n \{\
.RS 4
.\}
.nf
root=UUID=19e9dda3\-5a38\-484d\-a9b0\-fa6b067d0331
.fi
.if n \{\
.RE
.\}
.sp
or
.sp
.if n \{\
.RS 4
.\}
.nf
root=LABEL=myrootpartitionlabel
.fi
.if n \{\
.RE
.\}
.sp
To see all UUIDs or LABELs on your system, do:
.sp
.if n \{\
.RS 4
.\}
.nf
# ls \-l /dev/disk/by\-uuid
.fi
.if n \{\
.RE
.\}
.sp
or
.sp
.if n \{\
.RS 4
.\}
.nf
# ls \-l /dev/disk/by\-label
.fi
.if n \{\
.RE
.\}
.sp
If your root partition is on the network see the section called \(lqNetwork Boot\(rq\&.
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBKeyboard Settings\fR
.RS 4
.sp
If you have to input passwords for encrypted disk volumes, you might want to set the keyboard layout and specify a display font\&.
.sp
A typical german kernel command line would contain:
.sp
.if n \{\
.RS 4
.\}
.nf
rd\&.vconsole\&.font=eurlatgr rd\&.vconsole\&.keymap=de\-latin1\-nodeadkeys rd\&.locale\&.LANG=de_DE\&.UTF\-8
.fi
.if n \{\
.RE
.\}
.sp
Setting these options can override the setting stored on your system, if you use a modern init system, like systemd\&.
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBBlacklisting Kernel Modules\fR
.RS 4
.sp
Sometimes it is required to prevent the automatic kernel module loading of a specific kernel module\&. To do this, just add rd\&.driver\&.blacklist=\fI\fR, with \fI\fR not containing the \fI\&.ko\fR suffix, to the kernel command line\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
rd\&.driver\&.blacklist=mptsas rd\&.driver\&.blacklist=nouveau
.fi
.if n \{\
.RE
.\}
.sp
The option can be specified multiple times on the kernel command line\&.
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBSpeeding up the Boot Process\fR
.RS 4
.sp
If you want to speed up the boot process, you can specify as much information for dracut on the kernel command as possible\&. For example, you can tell dracut, that you root partition is not on a LVM volume or not on a raid partition, or that it lives inside a specific crypto LUKS encrypted volume\&. By default, dracut searches everywhere\&. A typical dracut kernel command line for a plain primary or logical partition would contain:
.sp
.if n \{\
.RS 4
.\}
.nf
rd\&.luks=0 rd\&.lvm=0 rd\&.md=0 rd\&.dm=0
.fi
.if n \{\
.RE
.\}
.sp
This turns off every automatic assembly of LVM, MD raids, DM raids and crypto LUKS\&.
.sp
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\&.
.RE
.SS "Injecting custom Files"
.sp
To add your own files to the initramfs image, you have several possibilities\&.
.sp
The \-\-include option let you specify a source path and a target path\&. For example
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-\-include cmdline\-preset /etc/cmdline\&.d/mycmdline\&.conf initramfs\-cmdline\-pre\&.img
.fi
.if n \{\
.RE
.\}
.sp
will create an initramfs image, where the file cmdline\-preset will be copied inside the initramfs to \fI/etc/cmdline\&.d/mycmdline\&.conf\fR\&. \-\-include can only be specified once\&.
.sp
.if n \{\
.RS 4
.\}
.nf
# mkdir \-p rd\&.live\&.overlay/etc/cmdline\&.d
# mkdir \-p rd\&.live\&.overlay/etc/conf\&.d
# echo "ip=dhcp" >> rd\&.live\&.overlay/etc/cmdline\&.d/mycmdline\&.conf
# echo export FOO=testtest >> rd\&.live\&.overlay/etc/conf\&.d/testvar\&.conf
# echo export BAR=testtest >> rd\&.live\&.overlay/etc/conf\&.d/testvar\&.conf
# tree rd\&.live\&.overlay/
rd\&.live\&.overlay/
`\-\- etc
|\-\- cmdline\&.d
| `\-\- mycmdline\&.conf
`\-\- conf\&.d
`\-\- testvar\&.conf
# dracut \-\-include rd\&.live\&.overlay / initramfs\-rd\&.live\&.overlay\&.img
.fi
.if n \{\
.RE
.\}
.sp
This will put the contents of the rd\&.live\&.overlay directory into the root of the initramfs image\&.
.sp
The \-\-install option let you specify several files, which will get installed in the initramfs image at the same location, as they are present on initramfs creation time\&.
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-\-install \*(Aqstrace fsck\&.ext4 ssh\*(Aq initramfs\-dbg\&.img
.fi
.if n \{\
.RE
.\}
.sp
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\&.
.SS "Network Boot"
.sp
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\&.
.sp
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\(cqt pass a kernel command line, then you can inject \fI/etc/cmdline\&.d/mycmdline\&.conf\fR, with a method described in the section called \(lqInjecting custom Files\(rq\&.
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBReducing the Image Size\fR
.RS 4
.sp
To reduce the size of the initramfs, you should create it with by omitting all dracut modules, which you know, you don\(cqt need to boot the machine\&.
.sp
You can also specify the exact dracut and kernel modules to produce a very tiny initramfs image\&.
.sp
For example for a NFS image, you would do:
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-m "nfs network base" initramfs\-nfs\-only\&.img
.fi
.if n \{\
.RE
.\}
.sp
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:
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-m "nfs network base" \-\-host\-only initramfs\-nfs\-host\-only\&.img
.fi
.if n \{\
.RE
.\}
.sp
This will reduce the size of the initramfs image significantly\&.
.RE
.SH "TROUBLESHOOTING"
.sp
If the boot process does not succeed, you have several options to debug the situation\&.
.SS "Identifying your problem area"
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 1." 4.2
.\}
Remove
\fI\*(Aqrhgb\fR\*(Aq and
\fI\*(Aqquiet\fR\*(Aq from the kernel command line
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 2." 4.2
.\}
Add
\fI\*(Aqrd\&.shell\fR\*(Aq to the kernel command line\&. This will present a shell should dracut be unable to locate your root device
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 3.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 3." 4.2
.\}
Add
\fI\*(Aqrd\&.shell rd\&.debug log_buf_len=1M\fR\*(Aq to the kernel command line so that dracut shell commands are printed as they are executed
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 4.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 4." 4.2
.\}
The file /run/initramfs/rdsosreport\&.txt is generated, which contains all the logs and the output of all significant tools, which are mentioned later\&.
.RE
.sp
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\&.
.SS "Information to include in your report"
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBAll bug reports\fR
.RS 4
.sp
In all cases, the following should be mentioned and attached to your bug report:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The exact kernel command\-line used\&. Typically from the bootloader configuration file (e\&.g\&.
\fI/boot/grub2/grub\&.cfg\fR) or from
\fI/proc/cmdline\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
A copy of your disk partition information from
\fI/etc/fstab\fR, which might be obtained booting an old working initramfs or a rescue medium\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Turn on dracut debugging (see
\fIthe \fR\fI\fIdebugging dracut\fR\fR\fI section\fR), and attach the file /run/initramfs/rdsosreport\&.txt\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
If you use a dracut configuration file, please include
\fI/etc/dracut\&.conf\fR
and all files in
\fI/etc/dracut\&.conf\&.d/*\&.conf\fR
.RE
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNetwork root device related problems\fR
.RS 4
.sp
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 the section called \(lqAll bug reports\(rq, include the following information:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Please include the output of
.sp
.if n \{\
.RS 4
.\}
.nf
# /sbin/ifup
# ip addr show
.fi
.if n \{\
.RE
.\}
.RE
.RE
.SS "Debugging dracut"
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBConfigure a serial console\fR
.RS 4
.sp
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\&.
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 1." 4.2
.\}
First, enable serial console output for both the kernel and the bootloader\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 2." 4.2
.\}
Open the file
\fI/boot/grub2/grub\&.cfg\fR
for editing\&. Below the line
\fI\*(Aqtimeout=5\fR\*(Aq, add the following:
.sp
.if n \{\
.RS 4
.\}
.nf
serial \-\-unit=0 \-\-speed=9600
terminal \-\-timeout=5 serial console
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 3.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 3." 4.2
.\}
Also in
\fI/boot/grub2/grub\&.cfg\fR, add the following boot arguments to the
\fI\*(Aqkernel\fR\*(Aq line:
.sp
.if n \{\
.RS 4
.\}
.nf
console=tty0 console=ttyS0,9600
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 4.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 4." 4.2
.\}
When finished, the
\fI/boot/grub2/grub\&.cfg\fR
file should look similar to the example below\&.
.sp
.if n \{\
.RS 4
.\}
.nf
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
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 5.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 5." 4.2
.\}
More detailed information on how to configure the kernel for console output can be found at
\m[blue]\fBhttp://www\&.faqs\&.org/docs/Linux\-HOWTO/Remote\-Serial\-Console\-HOWTO\&.html#CONFIGURE\-KERNEL\fR\m[]\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 6.\h'+01'\c
.\}
.el \{\
.sp -1
.IP " 6." 4.2
.\}
Redirecting non\-interactive output
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
You can redirect all non\-interactive output to
\fI/dev/kmsg\fR
and the kernel will put it out on the console when it reaches the kernel buffer by doing
.sp .5v
.RE
.sp
.if n \{\
.RS 4
.\}
.nf
# exec >/dev/kmsg 2>&1 /run/initramfs/etc/cmdline\&.d/debug\&.conf
# touch /run/initramfs/\&.need_shutdown
.fi
.if n \{\
.RE
.\}
.sp
This will give you a dracut shell after the system pivot\(cqed back in the initramfs\&.
.RE
.SH "OPTIONS"
.PP
\fB\-\-kver\fR \fI\fR
.RS 4
Set the kernel version\&. This enables to specify the kernel version, without specifying the location of the initramfs image\&. For example:
.RE
.sp
.if n \{\
.RS 4
.\}
.nf
# dracut \-\-kver 3\&.5\&.0\-0\&.rc7\&.git1\&.2\&.fc18\&.x86_64
.fi
.if n \{\
.RE
.\}
.PP
\fB\-f, \-\-force\fR
.RS 4
Overwrite existing initramfs file\&.
.RE
.PP
\fI