]> git.ipfire.org Git - thirdparty/dracut.git/blob - dracut.xml
remove dracut-gencmdline
[thirdparty/dracut.git] / dracut.xml
1 <?xml version='1.0' encoding='UTF-8'?>
2 <!-- This document was created with Syntext Serna Free. -->
3 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
4 <book>
5 <title><inlinemediaobject>
6 <imageobject>
7 <imagedata valign="middle" fileref="dracut.png" format="PNG"/>
8 </imageobject>
9 <imageobject>
10 <imagedata valign="middle" fileref="dracut.svg" format="SVG"/>
11 </imageobject>
12 <imageobject>
13 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dracut.svg" encoding="UTF-8" parse="xml"/>
14 </imageobject>
15 </inlinemediaobject>dracut</title>
16 <bookinfo>
17 <author>
18 <firstname>Harald</firstname>
19 <surname>Hoyer</surname>
20 </author>
21 <pubdate>2010</pubdate>
22 <edition>Version 1.0</edition>
23 <copyright>
24 <year>2010</year>
25 <holder>Harald Hoyer</holder>
26 </copyright>
27 <legalnotice>
28 <para>
29 This work is licensed under the Creative Commons Attribution/Share-Alike License. To view a copy of this license, visit <ulink url="http://creativecommons.org/licenses/by-sa/3.0/">http://creativecommons.org/licenses/by-sa/3.0/</ulink> or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
30 </para>
31 </legalnotice>
32 </bookinfo>
33 <toc/>
34 <chapter>
35 <chapterinfo>
36 <legalnotice>
37 <para>
38 This section is a modified version of <ulink url="http://en.wikipedia.org/wiki/Initrd">http://en.wikipedia.org/wiki/Initrd</ulink>, which is licensed under the Creative Commons Attribution/Share-Alike License.
39 </para>
40 </legalnotice>
41 </chapterinfo>
42 <title>Introduction</title>
43 <section>
44 <title>Definition</title>
45 <para>An <emphasis>initial ramdisk</emphasis> is a temporary file system used in the boot process of the Linux kernel. <emphasis>initrd</emphasis> and <emphasis>initramfs</emphasis> refer to slightly different schemes for loading this file system into memory. Both are commonly used to make preparations before the real root file system can be mounted.</para>
46 </section>
47 <section>
48 <title>Rationale </title>
49 <para>Many Linux distributions ship a single, generic kernel image that is intended to boot as wide a variety of hardware as possible. The device drivers for this generic kernel image are included as loadable modules, as it is not possible to statically compile them all into the one kernel without making it too large to boot from computers with limited memory or from lower-capacity media like floppy disks.
50 </para>
51 <para>This then raises the problem of detecting and loading the modules necessary to mount the root file system at boot time (or, for that matter, deducing where or what the root file system is).
52 </para>
53 <para>To further complicate matters, the root file system may be on a software <acronym>RAID</acronym> volume, <acronym>LVM</acronym>, <acronym>NFS</acronym> (on diskless workstations), or on an encrypted partition. All of these require special preparations to mount.
54 </para>
55 <para>Another complication is kernel support for hibernation, which suspends the computer to disk by dumping an image of the entire system to a swap partition or a regular file, then powering off. On next boot, this image has to be made accessible before it can be loaded back into memory. </para>
56 <para>To avoid having to hardcode handling for so many special cases into the kernel, an initial boot stage with a temporary root file system—now dubbed early user space—is used. This root file system would contain user-space helpers that would do the hardware detection, module loading and device discovery necessary to get the real root file system mounted.
57 </para>
58 </section>
59 <section>
60 <title>Implementation </title>
61 <para>An image of this initial root file system (along with the kernel image) must be stored somewhere accessible by the Linux bootloader or the boot firmware of the computer. This can be: </para>
62 <itemizedlist>
63 <listitem>
64 <para>The root file system itself </para>
65 </listitem>
66 <listitem>
67 <para>A boot image on an optical disc
68 </para>
69 </listitem>
70 <listitem>
71 <para>A small ext2/ext3 or <acronym>FAT</acronym>-formatted partition on a local disk (a <emphasis>boot partition</emphasis>)</para>
72 </listitem>
73 <listitem>
74 <para>A <acronym>TFTP</acronym> server (on systems that can boot from Ethernet) </para>
75 </listitem>
76 </itemizedlist>
77 <para>The bootloader will load the kernel and initial root file system image into memory and then start the kernel, passing in the memory address of the image.
78 </para>
79 <para>Depending on which algorithms were compiled statically into it, the kernel can currently unpack initrd/initramfs images compressed with gzip, bzip2 and <acronym>LZMA</acronym>. </para>
80 </section>
81 <section>
82 <title>Mount preparations </title>
83 <para>dracut can generate a customized initrams image which contains only whatever is necessary to boot some particular computer, such as <acronym>ATA</acronym>, <acronym>SCSI</acronym> and filesystem kernel modules (host-only mode).</para>
84 <para>dracut can also generate a more generic initramfs image (default mode). </para>
85 <para>dracut&apos;s initramfs starts only with the device name of the root file system (or its <acronym>UUID</acronym>) and must discover everything else at boot time. A complex cascade of tasks must be performed to get the root file system mounted: </para>
86 <itemizedlist>
87 <listitem>
88 <para>Any hardware drivers that the boot process depends on must be loaded. All kernel modules for common storage devices are packed onto the initramfs and then udev pulls in modules matching the computer&apos;s detected hardware. </para>
89 </listitem>
90 <listitem>
91 <para>On systems which display a boot rd.splash screen, the video hardware must be initialized and a user-space helper started to paint animations onto the display in lockstep with the boot process. </para>
92 </listitem>
93 <listitem>
94 <para>If the root file system is on NFS, dracut does then: <itemizedlist>
95 <listitem>
96 <para>Bring up the primary network interface. </para>
97 </listitem>
98 <listitem>
99 <para>Invoke a DHCP client, with which it can obtain a DHCP lease. </para>
100 </listitem>
101 <listitem>
102 <para>Extract the name of the NFS share and the address of the NFS server from the lease. </para>
103 </listitem>
104 <listitem>
105 <para>Mount the <acronym>NFS</acronym> share. </para>
106 </listitem>
107 </itemizedlist></para>
108 </listitem>
109 <listitem>
110 <para>If the root file system appears to be on a software <acronym>RAID</acronym> device, there is no way of knowing which devices the <acronym>RAID</acronym> volume spans; the standard <acronym>MD</acronym> utilities must be invoked to scan all available block devices with a raid signature and bring the required ones online. </para>
111 </listitem>
112 <listitem>
113 <para>If the root file system appears to be on a logical volume, the <acronym>LVM</acronym> utilities must be invoked to scan for and activate the volume group containing it. </para>
114 </listitem>
115 <listitem>
116 <para>If the root file system is on an encrypted block device: <itemizedlist>
117 <listitem>
118 <para>Invoke a helper script to prompt the user to type in a passphrase and/or insert a hardware token (such as a smart card or a <acronym>USB</acronym> security dongle). </para>
119 </listitem>
120 <listitem>
121 <para>Create a decryption target with the device mapper. </para>
122 </listitem>
123 </itemizedlist></para>
124 </listitem>
125 </itemizedlist>
126 <para>dracut uses udev, an event-driven hotplug agent, which invokes helper programs as hardware devices, disk partitions and storage volumes matching certain rules come online. This allows discovery to run in parallel, and to progressively cascade into arbitrary nestings of <acronym>LVM</acronym>, <acronym>RAID</acronym> or encryption to get at the root file system. </para>
127 <para>When the root file system finally becomes visible: <itemizedlist>
128 <listitem>
129 <para>Any maintenance tasks which cannot run on a mounted root file system are done. </para>
130 </listitem>
131 <listitem>
132 <para>The root file system is mounted read-only. </para>
133 </listitem>
134 <listitem>
135 <para>Any processes which must continue running (such as the rd.splash screen helper and its command <acronym>FIFO</acronym>) are hoisted into the newly-mounted root file system. </para>
136 </listitem>
137 </itemizedlist></para>
138 <para>The final root file system cannot simply be mounted over /, since that would make the scripts and tools on the initial root file system inaccessible for any final cleanup tasks. On an initramfs, the initial root file system cannot be rotated away. Instead, it is simply emptied and the final root file system mounted over the top.
139 </para>
140 </section>
141 </chapter>
142 <chapter>
143 <title>User Manual</title>
144 <section>
145 <title>Creating an initramfs Image</title>
146 <para>To create a initramfs image, the most simple command is:</para>
147 <screen># dracut</screen>
148 <para>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 is /boot/initramfs-<replaceable>&lt;kernel version&gt;</replaceable>.img and contains the kernel modules of the currently active kernel with version <replaceable>&lt;kernel version&gt;</replaceable>.</para>
149 <para>If the initramfs image already exists, dracut will display an error message, and to overwrite the existing image, you have to use the <option>--force</option> option. </para>
150 <screen># dracut --force</screen>
151 <para>If you want to specify another filename for the resulting image you would issue a command like:</para>
152 <screen># dracut foobar.img</screen>
153 <para>To generate an image for a specific kernel version, the command would be:</para>
154 <screen># dracut foobar.img 2.6.40-1.rc5.f20</screen>
155 <para>A shortcut to generate the image at the default location for a specific kernel version is:</para>
156 <screen># dracut &apos;&apos; 2.6.40-1.rc5.f20</screen>
157 <para>If you want to create lighter, smaller initramfs images, you may want to specify the <option>--host-only</option> or <option>-H</option> 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&apos;t put the disk on another controller or machine, and that you can&apos;t switch to another root filesystem, without recreating the initramfs image. The usage of the <option>--host-only</option> option is only for experts and you will have to keep the broken pieces. At least keep a copy of a general purpose image (and corresponding kernel) as a fallback to rescue your system.</para>
158 <section>
159 <title>Inspecting the Contents</title>
160 <para>To see the contents of the image created by dracut, you can use the <command>lsinitrd</command> tool.</para>
161 <screen># lsinitrd /boot/initramfs-$(uname -r).img | less</screen>
162 <para>To display the contents of a file in the initramfs also use the <command>lsinitrd</command> tool:</para>
163 <screen># lsinitrd /boot/initramfs-$(uname -r).img /etc/ld.so.conf
164 include ld.so.conf.d/*.conf</screen>
165 </section>
166 <section>
167 <title>Adding dracut Modules</title>
168 <para>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 <filename>/etc/dracut.conf</filename> or <filename>/etc/dracut.conf.d/myconf.conf</filename>. See the man page <xref linkend="dracutconf5"/>. You can also add dracut modules on the command line by using the <option>-a</option> or <option>--add</option> option:</para>
169 <screen># dracut --add bootchart initramfs-bootchart.img</screen>
170 <para>To see a list of available dracut modules, use the <option>--list-modules</option> option:</para>
171 <screen># dracut --list-modules</screen>
172 <para>or, if you have a dracut version earlier than <literal>008</literal>, issue the command:</para>
173 <screen># for mod in /usr/lib/dracut/modules.d/*; do echo ${mod##*/??}; done</screen>
174 </section>
175 <section>
176 <title>Omitting dracut Modules</title>
177 <para>Sometimes you don&apos;t want a dracut module to be included for reasons of speed, size or functionality. To do this, either specify the <envar>omit_dracutmodules</envar> variable in the <filename>dracut.conf</filename> or <filename>/etc/dracut.conf.d/myconf.conf</filename> configuration file (see man page <xref linkend="dracutconf5"/>), or use the <option>-o</option> or <option>--omit</option> option on the command line:</para>
178 <screen># dracut -o &quot;multipath lvm&quot; no-multipath-lvm.img</screen>
179 </section>
180 <section>
181 <title>Adding Kernel Modules</title>
182 <para>If you need a special kernel module in the initramfs, which is not automatically picked up by dracut, you have the use the <option>--add-drivers</option> option on the command line or the drivers vaiable in the <filename>/etc/dracut.conf</filename> or <filename>/etc/dracut.conf.d/myconf.conf</filename> configuration file (see man page <xref linkend="dracutconf5"/>):</para>
183 <screen># dracut --add-drivers mymod initramfs-with-mymod.img</screen>
184 </section>
185 </section>
186 <section>
187 <title>Boot parameters</title>
188 <para>The generated initramfs.img file normally 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 completly change your root partition (move it inside a md raid with encryption and LVM on top), as long as you specify the correct filesystem <varname>LABEL</varname> or <varname>UUID</varname> on the kernel command line for your root device, dracut will find it and boot from it.</para>
189 <para>The kernel command line usually can be configured in <filename>/boot/grub/grub.conf</filename>, if grub is your bootloader and it also can be edited in the real boot process in the grub menu.</para>
190 <para>The kernel command line can also be provided by the dhcp server with the root-path option. See <xref linkend="NetworkBoot"/>.</para>
191 <para>For a full reference of all kernel command line parameters, see the <xref linkend="dracutconf5"/> or <xref linkend="dracut8"/> man page.</para>
192 <section>
193 <title>Specifying the root Device</title>
194 <para>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 <envar>root=</envar> option. The most basic one is <envar>root=<replaceable>&lt;path to device node&gt;</replaceable></envar>:</para>
195 <screen>root=/dev/sda2</screen>
196 <para>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:</para>
197 <screen>root=UUID=19e9dda3-5a38-484d-a9b0-fa6b067d0331</screen>
198 <para>or</para>
199 <screen>root=LABEL=myrootpartitionlabel</screen>
200 <para>To see all <envar>UUID</envar>s or <envar>LABEL</envar>s on your system, do:</para>
201 <screen># ls -l /dev/disk/by-uuid</screen>
202 <para>or</para>
203 <screen># ls -l /dev/disk/by-label</screen>
204 <para>If your root partition is on the network see <xref linkend="NetworkBoot"/>.</para>
205 </section>
206 <section>
207 <title>Keyboard Settings</title>
208 <para>If you have to input passwords for encrypted disk volumes, you might want to set the keyboard layout and specify a display font.</para>
209 <para>A typical german kernel command would contain:</para>
210 <screen>vconsole.font=latarcyrheb-sun16 vconsole.keymap=de-latin1-nodeadkeys locale.LANG=de_DE.UTF-8</screen>
211 <para>Setting these options can override the setting stored on your system, if you use a modern init system, like systemd.</para>
212 <para>For dracut versions prior to version <literal>008</literal> the line would look like:</para>
213 <screen>LANG=de_DE.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys</screen>
214 </section>
215 <section>
216 <title>Blacklisting Kernel Modules</title>
217 <para>Sometimes it is required to prevent the automatic kernel module loading of a specific kernel module. To do this, just add <envar>rd.blacklist=<replaceable>&lt;kernel module name&gt;</replaceable></envar>, with <replaceable>&lt;kernel module name&gt;</replaceable> not containing the <filename>.ko</filename> suffix, to the kernel command line. For example:</para>
218 <screen>rd.blacklist=mptsas rd.blacklist=nouveau</screen>
219 <para>The option can be specified multiple times on the kernel command line.</para>
220 </section>
221 <section>
222 <title>Speeding up the Boot Process</title>
223 <para>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 <acronym>LVM</acronym> volume or not on a raid partition, or that it lives inside a specific crypto <acronym>LUKS</acronym> encrypted volume. By default, dracut searches everywhere. A typical dracut kernel command line for a plain primary or logical partition would contain:</para>
224 <screen>rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0</screen>
225 <para>on systems with dracut version prior to <literal>008</literal> the line would look like:</para>
226 <screen>rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM</screen>
227 <para>This turns off every automatic assembly of <acronym>LVM</acronym>, <acronym>MD</acronym> raids, <acronym>DM</acronym> raids and crypto <acronym>LUKS</acronym>.</para>
228 <para>Of course, you could also omit the dracut modules in the initramfs creation process, but then you would lose the posibility to turn it on on demand.</para>
229 </section>
230 <section id="Injecting">
231 <title>Injecting custom Files</title>
232 <para>To add your own files to the initramfs image, you have several possibilities.</para>
233 <para>The <option>--include</option> option let you specify a source path and a target path. For example</para>
234 <screen># dracut --include cmdline-preset /etc/cmdline initramfs-cmdline-pre.img</screen>
235 <para>will create an initramfs image, where the file cmdline-preset will be copied inside the initramfs to <filename>/etc/cmdline</filename>. <option>--include</option> can only be specified once.</para>
236 <screen># mkdir rd.live.overlay
237 # mkdir rd.live.overlay/etc
238 # mkdir rd.live.overlay/etc/conf.d
239 # echo &quot;ip=auto&quot; &gt;&gt; rd.live.overlay/etc/cmdline
240 # echo export TESTVAR=testtest &gt;&gt; rd.live.overlay/etc/conf.d/testvar.conf
241 # echo export TESTVAR=testtest &gt;&gt; rd.live.overlay/etc/conf.d/testvar.conf
242 # tree rd.live.overlay/
243 rd.live.overlay/
244 └── etc
245 ├── cmdline
246 └── conf.d
247 └── testvar.conf
248 # dracut --include rd.live.overlay / initramfs-rd.live.overlay.img</screen>
249 <para>This will put the contents of the rd.live.overlay directory into the root of the initramfs image.</para>
250 <para>The <option>--install</option> 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.</para>
251 <screen># dracut --install &apos;strace fsck.ext3 ssh&apos; initramfs-dbg.img</screen>
252 <para>This will create an initramfs with the <command>strace</command>, <command>fsck.ext3</command> and <command>ssh</command> executables, together with the libraries needed to start those. The <option>--install</option> option can be specified multiple times.</para>
253 </section>
254 </section>
255 <section id="NetworkBoot">
256 <title>Network Boot</title>
257 <para>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.</para>
258 <para>On a Red Hat Enterprise Linux or Fedora system, this means, you have to install the <filename>dracut-network</filename> rpm package:</para>
259 <screen># yum install dracut-network</screen>
260 <para>The resulting initramfs image can be served by a boot manager residing on your local hard drive or it can be served by a <acronym>PXE</acronym>/<acronym>TFTP</acronym> server.</para>
261 <para>How to setup your <acronym>PXE</acronym>/<acronym>TFTP</acronym> server can be found in the <ulink url="http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/">Red Hat Enterprise Linux Storage Administration Guide</ulink>.</para>
262 <para>If you specify <envar>rd.ip=auto</envar> on the kernel command line, then dracut asks a dhcp server about the ip adress 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 <acronym>TFTP</acronym>/<acronym>DHCP</acronym> server. If you can&apos;t pass a kernel command line, then you can inject <filename>/etc/cmdline</filename>, with a method described in <xref linkend="Injecting"/>.
263 </para>
264 <section>
265 <title>Reducing the Image Size</title>
266 <para>To reduce the size of the initramfs, you should create it with by ommitting all dracut modules, which you know, you don&apos;t need to boot the machine.</para>
267 <para>You can also specify the exact dracut and kernel modules to produce a very tiny initramfs image.</para>
268 <para>For example for a <acronym>NFS</acronym> image, you would do:</para>
269 <screen># dracut -m &quot;nfs network base&quot; initramfs-nfs-only.img</screen>
270 <para>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 <option>--host-only</option> option:</para>
271 <screen># dracut -m &quot;nfs network base&quot; --host-only initramfs-nfs-host-only.img</screen>
272 <para>This will reduce the size of the initramfs image significantly.</para>
273 </section>
274 <section>
275 <title>NFS Root Device</title>
276 <para/>
277 </section>
278 <section>
279 <title>iSCSI Root Device</title>
280 <para>
281 </para>
282 </section>
283 <section>
284 <title>FCoE Root Device</title>
285 <para>
286 </para>
287 </section>
288 </section>
289 <section>
290 <title>Troubleshooting</title>
291 <para>If the boot process does not succeed, you have several options to debug the situation. Some of the basic operations are covered here. For more information you should also visit: <ulink url="http://fedoraproject.org/wiki/How_to_debug_Dracut_problems">http://fedoraproject.org/wiki/How_to_debug_Dracut_problems</ulink></para>
292 <section id="identifying-your-problem-area">
293 <title>Identifying your problem area</title>
294 <orderedlist>
295 <listitem>
296 <para>Remove &apos;&apos;rhgb&apos;&apos; and &apos;&apos;quiet&apos;&apos; from the kernel command line
297 </para>
298 </listitem>
299 <listitem>
300 <para>Add &apos;&apos;rd.shell&apos;&apos; to the kernel command line. This will present a shell should dracut be unable to locate your root device
301 </para>
302 </listitem>
303 <listitem>
304 <para>Add &apos;&apos;rd.shell rd.debug log_buf_len=1M&apos;&apos; to the kernel command line so that dracut shell commands are printed as they are executed
305 </para>
306 </listitem>
307 <listitem>
308 <para>With dracut &gt;= 002-11, you can inspect the rd.debug output with:
309 </para>
310 <screen># less /run/initramfs/init.log
311 # dmesg | less</screen>
312 </listitem>
313 </orderedlist>
314 </section>
315 <section id="information-to-include-in-your-report">
316 <title id="information-to-include-in-your-report-title">Information to include in your report</title>
317 <section id="all-bug-reports">
318 <title id="all-bug-reports-title">All bug reports</title>
319 <para>In all cases, the following should be mentioned and attached to your bug report:
320 </para>
321 <itemizedlist>
322 <listitem>
323 <para>The exact kernel command-line used. Typically from the bootloader configuration file (e.g. <filename>/etc/grub.conf</filename>) or from <filename>/proc/cmdline</filename>.</para>
324 </listitem>
325 <listitem>
326 <para>A copy of your disk partition information from <filename>/etc/fstab</filename>, which might be obtained booting an old working initramfs or a rescue medium.</para>
327 </listitem>
328 <listitem>
329 <para>A device listing from device-mapper. This can be obtained by running the command <screen># dmsetup ls --tree</screen></para>
330 </listitem>
331 <listitem>
332 <para>A list of block device attributes including vol_id compatible mode. This can be obtained by running the commands: <screen># blkid -p
333 # blkid -p -o udev</screen></para>
334 </listitem>
335 <listitem>
336 <para>Turn on dracut debugging (see <filename>the &apos;debugging dracut&apos; section</filename>), and attach all relevant information from the boot log. This can be obtained by running the command <screen># dmesg|grep dracut</screen></para>
337 </listitem>
338 <listitem>
339 <para>If you use a dracut configuration file, please include <filename>/etc/dracut.conf</filename>
340 and all files in <filename>/etc/dracut.conf.d/*.conf</filename></para>
341 </listitem>
342 </itemizedlist>
343 </section>
344 <section id="logical-volume-management-related-problems">
345 <title id="logical-volume-management-related-problems-title">Logical Volume Management related problems</title>
346 <para>As well as the information from <xref linkend="all-bug-reports"/> include the following information:
347 </para>
348 <itemizedlist>
349 <listitem>
350 <para>Include physical volume information by running the command: <screen># lvm pvdisplay</screen></para>
351 </listitem>
352 <listitem>
353 <para>Include volume group information by running the command: <screen># lvm vgdisplay</screen></para>
354 </listitem>
355 <listitem>
356 <para>Include logical volume information by running the command: <screen># lvm lvdisplay</screen></para>
357 </listitem>
358 </itemizedlist>
359 </section>
360 <section id="software-raid-related-problems">
361 <title id="software-raid-related-problems-title">Software RAID related problems</title>
362 <para>As well as the information from <xref linkend="all-bug-reports"/>, include the following information:
363 </para>
364 <itemizedlist>
365 <listitem>
366 <para>If using software RAID disk partitions, please include the output of <screen># cat /proc/mdstat</screen></para>
367 </listitem>
368 </itemizedlist>
369 </section>
370 <section id="network-root-device-related-problems">
371 <title id="network-root-device-related-problems-title">Network root device related problems</title>
372 <para>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 <xref linkend="all-bug-reports"/>, include the following information:
373 </para>
374 <itemizedlist>
375 <listitem>
376 <para>Please include the output of <screen># /sbin/ifup <replaceable>&lt;interfacename&gt;</replaceable>
377 # ip addr show</screen></para>
378 </listitem>
379 </itemizedlist>
380 </section>
381 </section>
382 <section id="debugging-dracut">
383 <title id="debugging-dracut-title">Debugging dracut</title>
384 <section id="configure-a-serial-console">
385 <title id="configure-a-serial-console-title">Configure a serial console</title>
386 <para>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.
387 </para>
388 <orderedlist>
389 <listitem>
390 <para>First, enable serial console output for both the kernel and the bootloader.
391 </para>
392 </listitem>
393 <listitem>
394 <para>Open the file <filename>/etc/grub.conf</filename> for editing. Below the line &apos;&apos;timeout=5&apos;&apos;, add the following:
395 <screen>serial --unit=0 --speed=9600
396 terminal --timeout=5 serial console</screen></para>
397 </listitem>
398 <listitem>
399 <para>Also in <filename>/etc/grub.conf</filename>, add the following boot arguemnts to the &apos;&apos;kernel&apos;&apos; line:
400 <screen>console=tty0 console=ttyS0,9600</screen></para>
401 </listitem>
402 <listitem>
403 <para>When finished, the <filename>/etc/grub.conf</filename> file should look similar to the example below.
404 <screen>default=0
405 timeout=5
406 serial --unit=0 --speed=9600
407 terminal --timeout=5 serial console
408 title Fedora (2.6.29.5-191.fc11.x86_64)
409 root (hd0,0)
410 kernel /vmlinuz-2.6.29.5-191.fc11.x86_64 ro root=/dev/mapper/vg_uc1-lv_root console=tty0 console=ttyS0,9600
411 initrd /dracut-2.6.29.5-191.fc11.x86_64.img</screen></para>
412 </listitem>
413 <listitem>
414 <para>More detailed information on how to configure the kernel for console output can be found at <ulink url="http://www.faqs.org/docs/Linux-HOWTO/Remote-Serial-Console-HOWTO.html#CONFIGURE-KERNEL">http://www.faqs.org/docs/Linux-HOWTO/Remote-Serial-Console-HOWTO.html#CONFIGURE-KERNEL</ulink>.
415 </para>
416 </listitem>
417 </orderedlist>
418 <note>
419 <title>Redirecting non-interactive output</title>
420 <para>You can redirect all non-interactive output to <filename>/dev/kmsg</filename> and the kernel will put it out on the console when it reaches the kernel buffer by doing<screen># exec &gt;/dev/kmsg 2&gt;&amp;1 &lt;/dev/console</screen></para>
421 </note>
422 </section>
423 <section id="using-the-dracut-shell">
424 <title id="using-the-dracut-shell-title">Using the dracut shell</title>
425 <para>Dracut offers a shell for interactive debugging in the event dracut fails to locate your root filesystem. To enable the shell:
426 <orderedlist>
427 <listitem>
428 <para>Add the boot parameter &apos;&apos;rd.shell&apos;&apos; to your bootloader configuration file (e.g. <filename>/etc/grub.conf</filename>)</para>
429 </listitem>
430 <listitem>
431 <para>Remove the boot arguments &apos;&apos;rhgb&apos;&apos; and &apos;&apos;quiet&apos;&apos;
432 </para>
433 <para>
434 A sample <filename>/etc/grub.conf</filename> bootloader configuration file is listed below.
435 </para>
436 <para><screen>default=0
437 timeout=5
438 serial --unit=0 --speed=9600
439 terminal --timeout=5 serial console
440 title Fedora (2.6.29.5-191.fc11.x86_64)
441 root (hd0,0)
442 kernel /vmlinuz-2.6.29.5-191.fc11.x86_64 ro root=/dev/mapper/vg_uc1-lv_root console=tty0 rd.shell
443 initrd /dracut-2.6.29.5-191.fc11.x86_64.img</screen></para>
444 </listitem>
445 <listitem>
446 <para>If system boot fails, you will be dropped into a shell as seen in the example below.
447 <screen>No root device found
448 Dropping to debug shell.
449
450 sh: can&apos;t access tty; job control turned off
451
452 # </screen></para>
453 </listitem>
454 <listitem>
455 <para>Use this shell prompt to gather the information requested above (see <xref linkend="all-bug-reports"/>).
456 </para>
457 </listitem>
458 </orderedlist></para>
459 </section>
460 <section id="accessing-the-root-volume-from-the-dracut-shell">
461 <title id="accessing-the-root-volume-from-the-dracut-shell-title">Accessing the root volume from the dracut shell</title>
462 <para>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:
463 </para>
464 <itemizedlist>
465 <listitem>
466 <para>A block device (e.g. <filename>/dev/sda7</filename>)
467 </para>
468 </listitem>
469 <listitem>
470 <para>A LVM logical volume (e.g. <filename>/dev/VolGroup00/LogVol00</filename>)
471 </para>
472 </listitem>
473 <listitem>
474 <para>An encrypted device (e.g. <filename>/dev/mapper/luks-4d5972ea-901c-4584-bd75-1da802417d83</filename>)
475 </para>
476 </listitem>
477 <listitem>
478 <para>A network attached device (e.g. netroot=iscsi:@192.168.0.4::3260::iqn.2009-02.org.fedoraproject:for.all)
479 </para>
480 </listitem>
481 </itemizedlist>
482 <para>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 <filename>/dev/root</filename> 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. </para>
483 <orderedlist>
484 <listitem>
485 <para>Inspect your partitions using <command>parted</command><screen># parted /dev/sda -s p
486 Model: ATA HTS541060G9AT00 (scsi)
487 Disk /dev/sda: 60.0GB
488 Sector size (logical/physical): 512B/512B
489 Partition Table: msdos
490 Number Start End Size Type File system Flags
491 1 32.3kB 10.8GB 107MB primary ext4 boot
492 2 10.8GB 55.6GB 44.7GB logical lvm</screen></para>
493 </listitem>
494 <listitem>
495 <para>You recall that your root volume was a LVM logical volume. Scan and activate any logical volumes.
496 <screen># lvm vgscan
497 # lvm vgchange -ay</screen></para>
498 </listitem>
499 <listitem>
500 <para>You should see any logical volumes now using the command <command>blkid</command>:
501 <screen># blkid
502 /dev/sda1: UUID=&quot;3de247f3-5de4-4a44-afc5-1fe179750cf7&quot; TYPE=&quot;ext4&quot;
503 /dev/sda2: UUID=&quot;Ek4dQw-cOtq-5MJu-OGRF-xz5k-O2l8-wdDj0I&quot; TYPE=&quot;LVM2_member&quot;
504 /dev/mapper/linux-root: UUID=&quot;def0269e-424b-4752-acf3-1077bf96ad2c&quot; TYPE=&quot;crypto_LUKS&quot;
505 /dev/mapper/linux-home: UUID=&quot;c69127c1-f153-4ea2-b58e-4cbfa9257c5e&quot; TYPE=&quot;ext3&quot;
506 /dev/mapper/linux-swap: UUID=&quot;47b4d329-975c-4c08-b218-f9c9bf3635f1&quot; TYPE=&quot;swap&quot;
507 </screen></para>
508 </listitem>
509 <listitem>
510 <para>From the output above, you recall that your root volume exists on an encrypted block device. Following the guidance disk encryption guidance from the Installation Guide, you unlock your encrypted root volume.
511 <screen># UUID=$(cryptsetup luksUUID /dev/mapper/linux-root)
512 # cryptsetup luksOpen /dev/mapper/linux-root luks-$UUID
513 Enter passphrase for /dev/mapper/linux-root:
514 Key slot 0 unlocked. </screen></para>
515 </listitem>
516 <listitem>
517 <para>Next, make a symbolic link to the unlocked root volume
518 <screen># ln -s /dev/mapper/luks-$UUID /dev/root</screen></para>
519 </listitem>
520 <listitem>
521 <para>With the root volume available, you may continue booting the system by exiting the dracut shell
522 <screen># exit</screen></para>
523 </listitem>
524 </orderedlist>
525 </section>
526 <section id="additional-dracut-boot-parameters">
527 <title id="additional-dracut-boot-parameters-title">Additional dracut boot parameters</title>
528 <para>For more debugging options, see <xref linkend="dracut-kernel-debug"/> in the man page <xref linkend="dracutkernel7"/>.</para>
529 </section>
530 </section>
531 </section>
532 </chapter>
533 <chapter>
534 <title>Developer Manual</title>
535 <section>
536 <title>dracut Components</title>
537 <para>dracut uses a modular system to build and extend the initramfs image. All modules are located in <filename>/usr/lib/dracut/modules.d</filename> or in <filename><replaceable>&lt;git-src&gt;</replaceable>/modules.d</filename>. The most basic dracut module is <filename>99base</filename>. In <filename>99base</filename> the initial shell script <command>init</command> is defined, which gets run by the kernel after initramfs loading. Although you can replace <command>init</command> with your own version of <filename>99base</filename>, this is not encouraged. Instead you should use, if possible, the hooks of dracut. All hooks, and the point of time in which they are executed, are described in <xref linkend="stages"/>.</para>
538 <para>The main script, which creates the initramfs is <command>dracut</command> itsself. It parses all arguments and sets up the directory, in which everything is installed. It then executes all <command>check</command>, <command>install</command>, <command>installkernel</command> scripts found in the modules, which are to be processed. After everything is installed, the install directory is archived and compressed to the final initramfs image. All helper functions used by <command>check</command>, <command>install</command> and <command>installkernel</command> are found in in the file <filename>dracut-functions</filename>. These shell functions are available to all module installer (<command>install</command>, <command>installkernel</command>) scripts, without the need to source <filename>dracut-functions</filename>.</para>
539 <para>A module can check the preconditions for <command>install</command> and <command>installkernel</command> with the <command>check</command> script. Also dependencies can be expressed with <command>check</command>. If a module passed <command>check</command>, <command>install</command> and <command>installkernel</command> will be called to install all of the necessary files for the module. To split between kernel and non-kernel parts of the installation, all kernel module related parts have to be in <command>installkernel</command>. All other files found in a module directory are module specific and mostly are hook scripts and udev rules.</para>
540 </section>
541 <section id="stages">
542 <title>Boot Process Stages</title>
543 <para>The <command>init</command> script in <filename>99base</filename> is the main script, which prepares the root file system for usage, runs udev, mounts the real root device, kills the remaining processes, and switches to the real root device for further booting. dracut modules can insert custom script at various points, to control the boot process. These hooks are plain directories containing shell scripts ending with &quot;.sh&quot;, which are sourced by <command>init</command>.
544 Common used functions are in <filename>dracut-lib.sh</filename>, which can be sourced by any script. </para>
545 <section>
546 <title>Basic Setup</title>
547 <para>The first thing <command>init</command> does, is to mount <filename>/proc</filename> and <filename>/sys</filename> and manually create the basic device nodes and symbolic links in <filename>/dev</filename> needed to execute basic commands. Then logging is setup according to kernel command line arguments. <filename>/dev/pts</filename> and <filename>/dev/shm</filename> are mounted and the first hook is sourced.</para>
548 </section>
549 <section>
550 <title>Hook: cmdline</title>
551 <para>The <literal>
552 <function>cmdline</function>
553 </literal> hook is a place to insert scripts to parse the kernel command line and prepare the later actions, like setting up udev rules and configuration files.</para>
554 <para>In this hook the most important environment variable is defined: <envar>root</envar>. The second one is <envar>rootok</envar>, which indicates, that a module claimed to be able to parse the <envar>root</envar> defined. So for example, <envar>root=</envar><replaceable>iscsi:....</replaceable> will be claimed by the <function>iscsi</function> dracut module, which then sets <envar>rootok</envar>.</para>
555 </section>
556 <section>
557 <title>Hook: pre-udev</title>
558 <para>This hook is executed right after the <function>cmdline</function> hook and a check if <envar>root</envar> and <envar>rootok</envar> were set. Here modules can take action with the final <envar>root</envar>, and before <command>udev</command> has been run.</para>
559 </section>
560 <section>
561 <title>Start Udev</title>
562 <para>Now <command>udev</command> is started and the logging for <command>udev</command> is setup.</para>
563 </section>
564 <section>
565 <title>Hook: pre-trigger</title>
566 <para>In this hook, you can set udev environment variables with <code>udevadm control --property=<envar>KEY</envar>=<replaceable>value</replaceable></code> or control the further execution of <command>udev</command> with <command>udevadm</command>.</para>
567 </section>
568 <section>
569 <title>Trigger Udev</title>
570 <para><command>udev</command> is triggered by calling <command>udevadm trigger</command>, which sends <constant>add</constant> events for all devices and subsystems.
571 </para>
572 </section>
573 <section>
574 <title>Main Loop</title>
575 <para>Now the main loop of <command>99base/init</command> begins. Here we loop until <command>udev</command> has settled and all scripts in <filename>initqueue/finished</filename> returned true. In this loop there are three hooks, where scripts can be inserted by calling <command>/sbin/initqueue</command>.
576 </para>
577 <section>
578 <title>Initqueue</title>
579 <para>This hook gets executed every time a script is inserted here, regardless of the <command>udev</command> state.</para>
580 </section>
581 <section>
582 <title>Initqueue settled</title>
583 <para>This hooks gets executed every time <command>udev</command> has settled.</para>
584 </section>
585 <section>
586 <title>Initqueue timeout</title>
587 <para>This hooks gets executed, when the main loop counter becomes half of the rd.retry counter.</para>
588 </section>
589 <section>
590 <title>Initqueue finished</title>
591 <para>This hook is called after <command>udev</command> has settled and if all scripts herein return <errorcode>0</errorcode> the main loop will be ended.</para>
592 </section>
593 </section>
594 <section>
595 <title>Hook: pre-mount</title>
596 <para>Before the root device is mounted all scripts in the hook pre-mount are executed. In some cases (e.g. <acronym>NFS</acronym>) the real root device is already mounted, though.</para>
597 </section>
598 <section>
599 <title>Hook: mount</title>
600 <para>This hook is mainly to mount the real root device.</para>
601 </section>
602 <section>
603 <title>Hook: pre-pivot</title>
604 <para>This hook is the last hook and is called before init finally switches root to the real root device. This is a good place to clean up and kill processes not needed anymore.</para>
605 </section>
606 <section>
607 <title>Cleanup and switch_root</title>
608 <para>Init kills all <command>udev</command> processes, cleans up the environment, sets up the arguments for the real <command>init</command> process and finally calls <command>switch_root</command>. <command>switch_root</command> removes the whole filesystem hierarchy of the initramfs, chroot()s to the real root device and calls <command>/sbin/init</command> with the specified arguments.</para>
609 <para>To ensure all files in the initramfs hierarchy can be removed, all processes still running from the initramfs should not have any open file descriptors left.</para>
610 </section>
611 </section>
612 <section>
613 <title>Network Infrastructure</title>
614 <para>
615 </para>
616 </section>
617 <section>
618 <title>Writing a Module</title>
619 <para>A simple example module is <filename>96insmodpost</filename>, which modprobes a kernel module after udev has settled and the basic device drivers have been loaded.</para>
620 <para>All module installation information is in the file module-setup.sh.</para>
621 <para>First we create a <function>check()</function> function, which just exits with <errorcode>0</errorcode> indicating that this module should be included by default.</para>
622 <para><function>check()</function>:</para>
623 <programlisting>return 0</programlisting>
624 <para>The we create the <function>install()</function> function, which installs a cmdline hook with priority number 20 called <filename>parse-insmodpost.sh</filename>. It also installs the <filename>insmodpost.sh</filename> script in <filename>/sbin</filename>.</para>
625 <para><function>install()</function>:</para>
626 <programlisting>inst_hook cmdline 20 &quot;$moddir/parse-insmodpost.sh&quot;
627 inst_simple &quot;$moddir/insmodpost.sh&quot; /sbin/insmodpost.sh</programlisting>
628 <para>The <filename>pase-instmodpost.sh</filename> parses the kernel command line for a argument <envar>rd.driver.post</envar>, blacklists the module from being autoloaded and installs the hook <filename>insmodpost.sh</filename> in the <filename>initqueue/settled</filename>.</para>
629 <para><filename>parse-insmodpost.sh</filename>:</para>
630 <programlisting>for p in $(getargs rd.driver.post=); do
631 echo &quot;blacklist $p&quot; &gt;&gt; /etc/modprobe.d/initramfsblacklist.conf
632 _do_insmodpost=1
633 done
634
635 [ -n &quot;$_do_insmodpost&quot; ] &amp;&amp; /sbin/initqueue --settled --unique --onetime /sbin/insmodpost.sh
636 unset _do_insmodpost
637 </programlisting>
638 <para><filename>insmodpost.sh</filename>, which is called in the <filename>initqueue/settled</filename> hook will just modprobe the kernel modules specified in all <envar>rd.driver.post</envar> kernel command line parameters. It runs after <command>udev</command> has settled and is only called once (<parameter>--onetime</parameter>).</para>
639 <para><filename>insmodpost.sh</filename>:</para>
640 <programlisting>. /lib/dracut-lib.sh
641
642 for p in $(getargs rd.driver.post=); do
643 modprobe $p
644 done
645 </programlisting>
646 <section>
647 <title>check()</title>
648 <para><filename>
649 <function>check()</function>
650 </filename> is called by dracut to evaluate the inclusion of a dracut module in the initramfs.</para>
651 <variablelist>
652 <varlistentry>
653 <term> $hostonly</term>
654 <listitem>
655 <para>If the $hostonly variable is set, then the module check() function should be in &quot;hostonly&quot; mode, which means, that the check() should only return 0, if the module is really needed to boot this specific host.</para>
656 </listitem>
657 </varlistentry>
658 </variablelist>
659 <para><function>check()</function> should return with:</para>
660 <variablelist>
661 <varlistentry>
662 <term>0</term>
663 <listitem>
664 <para>Include the dracut module in the initramfs.</para>
665 </listitem>
666 </varlistentry>
667 <varlistentry>
668 <term>1</term>
669 <listitem>
670 <para>Do not include the dracut module. The requirements are not fullfilled (missing tools, etc.)</para>
671 </listitem>
672 </varlistentry>
673 <varlistentry>
674 <term>255</term>
675 <listitem>
676 <para>Only include the dracut module, if another module requires it or if explicitly specified in the config file or on the argument list.</para>
677 </listitem>
678 </varlistentry>
679 </variablelist>
680 </section>
681 <section>
682 <title>depends()</title>
683 <para>The function <function>depends()</function> should <function>echo</function> all other dracut module names the module depends on.</para>
684 </section>
685 <section>
686 <title>install()</title>
687 <para>dracut_install</para>
688 <para>inst</para>
689 <para>inst_hook</para>
690 <para>inst_rules</para>
691 <para/>
692 </section>
693 <section>
694 <title>installkernel()</title>
695 <para>instmods</para>
696 </section>
697 <section>
698 <title>Creation Functions</title>
699 <para>
700 </para>
701 </section>
702 <section>
703 <title>Initramfs Functions</title>
704 <para>
705 </para>
706 </section>
707 <section>
708 <title>Network Modules</title>
709 <para>
710 </para>
711 </section>
712 </section>
713 </chapter>
714 <appendix>
715 <title>Man Pages</title>
716 <section id="dracut.man">
717 <title>dracut</title>
718 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dracut.8.xml" encoding="UTF-8" parse="xml"/>
719 </section>
720 <section id="dracut.conf">
721 <title>dracut.conf</title>
722 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dracut.conf.5.xml" encoding="UTF-8" parse="xml"/>
723 </section>
724 <section id="dracut.cmdline">
725 <title>dracut.cmdline</title>
726 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dracut.cmdline.7.xml" encoding="UTF-8" parse="xml"/>
727 </section>
728 </appendix>
729 </book>