]> git.ipfire.org Git - thirdparty/dracut.git/blame - dracut.asc
network-manager: remove useless use of basename
[thirdparty/dracut.git] / dracut.asc
CommitLineData
888d53f2
HH
1dracut
2======
3Harald Hoyer <harald@redhat.com>
b6c89768 4v3.0, October 2013
888d53f2
HH
5
6:language: bash
7
8= Introduction
9This section is a modified version of
10http://en.wikipedia.org/wiki/Initrd which is licensed under the
11Creative Commons Attribution/Share-Alike License.
12
13== Definition
14An _initial ramdisk_ is a temporary file system used in the boot process of the
15Linux kernel. _initrd_ and _initramfs_ refer to slightly different schemes for
16loading this file system into memory. Both are commonly used to make
17preparations before the real root file system can be mounted.
18
19== Rationale
20Many Linux distributions ship a single, generic kernel image that is intended to
21boot as wide a variety of hardware as possible. The device drivers for this
22generic kernel image are included as loadable modules, as it is not possible to
23statically compile them all into the one kernel without making it too large to
24boot from computers with limited memory or from lower-capacity media like floppy
25disks.
26
27This then raises the problem of detecting and loading the modules necessary to
28mount the root file system at boot time (or, for that matter, deducing where or
29what the root file system is).
30
31To further complicate matters, the root file system may be on a software RAID
32volume, LVM, NFS (on diskless workstations), or on an encrypted partition. All
33of these require special preparations to mount.
34
35Another complication is kernel support for hibernation, which suspends the
36computer to disk by dumping an image of the entire system to a swap partition or
37a regular file, then powering off. On next boot, this image has to be made
38accessible before it can be loaded back into memory.
39
40To avoid having to hardcode handling for so many special cases into the kernel,
41an initial boot stage with a temporary root file system
42—now dubbed early user space— is used. This root file system would contain
43user-space helpers that would do the hardware detection, module loading and
44device discovery necessary to get the real root file system mounted.
45
46== Implementation
47An image of this initial root file system (along with the kernel image) must be
48stored somewhere accessible by the Linux bootloader or the boot firmware of the
49computer. This can be:
50
51* The root file system itself
52* A boot image on an optical disc
53* A small ext2/ext3 or FAT-formatted partition on a local disk
54 (a _boot partition_)
55* A TFTP server (on systems that can boot from Ethernet)
56
57The bootloader will load the kernel and initial root file system image into
58memory and then start the kernel, passing in the memory address of the image.
59
60Depending on which algorithms were compiled statically into it, the kernel can
61currently unpack initrd/initramfs images compressed with gzip, bzip2 and LZMA.
62
63== Mount preparations
64dracut can generate a customized initrams image which contains only whatever is
65necessary to boot some particular computer, such as ATA, SCSI and filesystem
66kernel modules (host-only mode).
67
68dracut can also generate a more generic initramfs image (default mode).
69
70dracut's initramfs starts only with the device name of the root file system (or
71its UUID) and must discover everything else at boot time. A complex cascade of
72tasks must be performed to get the root file system mounted:
73
74* Any hardware drivers that the boot process depends on must be loaded. All
75kernel modules for common storage devices are packed onto the initramfs and then
76udev pulls in modules matching the computer's detected hardware.
77
78* On systems which display a boot rd.splash screen, the video hardware must be
79initialized and a user-space helper started to paint animations onto the display
80in lockstep with the boot process.
81
1d22c670 82* If the root file system is on NFS, dracut does then:
888d53f2
HH
83** Bring up the primary network interface.
84** Invoke a DHCP client, with which it can obtain a DHCP lease.
85** Extract the name of the NFS share and the address of the NFS server from the
86lease.
87** Mount the NFS share.
88
89* If the root file system appears to be on a software RAID device, there is no
90way of knowing which devices the RAID volume spans; the standard MD utilities
91must be invoked to scan all available block devices with a raid signature and
92bring the required ones online.
93
94* If the root file system appears to be on a logical volume, the LVM utilities
95must be invoked to scan for and activate the volume group containing it.
96
97* If the root file system is on an encrypted block device:
98** Invoke a helper script to prompt the user to type in a passphrase and/or
99insert a hardware token (such as a smart card or a USB security dongle).
100
101* Create a decryption target with the device mapper.
102
103dracut uses udev, an event-driven hotplug agent, which invokes helper programs
104as hardware devices, disk partitions and storage volumes matching certain rules
105come online. This allows discovery to run in parallel, and to progressively
106cascade into arbitrary nestings of LVM, RAID or encryption to get at the root
107file system.
108
109When the root file system finally becomes visible:
110
111* Any maintenance tasks which cannot run on a mounted root file system
112are done.
113* The root file system is mounted read-only.
114* Any processes which must continue running (such as the rd.splash screen helper
115and its command FIFO) are hoisted into the newly-mounted root file system.
116
117The final root file system cannot simply be mounted over /, since that would
118make the scripts and tools on the initial root file system inaccessible for any
119final cleanup tasks. On an initramfs, the initial root file system cannot be
120rotated away. Instead, it is simply emptied and the final root file system
121mounted over the top.
122
a1ebd771
HH
123If the systemd module is used in the initramfs, the ordering of the services
124started looks like <<dracutbootup7>>.
125
1d22c670
HH
126== Dracut on shutdown
127
ef9ddb91
HH
128On a systemd driven system, the dracut initramfs is also used for the shutdown
129procedure.
1d22c670
HH
130
131The following steps are executed during a shutdown:
132
133* systemd switches to the shutdown.target
ef9ddb91 134* systemd starts
53475faa 135 $prefix/lib/systemd/system/shutdown.target.wants/dracut-shutdown.service
1d22c670
HH
136* dracut-shutdown.service executes /usr/lib/dracut/dracut-initramfs-restore
137 which unpacks the initramfs to /run/initramfs
138* systemd finishes shutdown.target
139* systemd kills all processes
140* systemd tries to unmount everything and mounts the remaining read-only
141* systemd checks, if there is a /run/initramfs/shutdown executable
142* if yes, it does a pivot_root to /run/initramfs and executes ./shutdown.
ef9ddb91
HH
143 The old root is then mounted on /oldroot.
144 /usr/lib/dracut/modules.d/99shutdown/shutdown.sh is the shutdown executable.
145* shutdown will try to umount every /oldroot mount and calls the various
146 shutdown hooks from the dracut modules
1d22c670
HH
147
148This ensures, that all devices are disassembled and unmounted cleanly.
149
888d53f2
HH
150= User Manual
151
a1ebd771 152:leveloffset: 1
888d53f2
HH
153include::dracut.8.asc[]
154
b6c89768 155:leveloffset: 1
888d53f2
HH
156[[dracutconf5]]
157include::dracut.conf.5.asc[]
158
159[[dracutcmdline7]]
160include::dracut.cmdline.7.asc[]
161
e5efb6a7
HH
162[[lsinitrd1]]
163include::lsinitrd.1.asc[]
164
165[[mkinitrd8]]
166include::mkinitrd.8.asc[]
167
b6c89768
HH
168= Developer Manual
169
170:leveloffset: 1
171[[dracutmodules7]]
172include::dracut.modules.7.asc[]
173
174[[dracutbootup7]]
175include::dracut.bootup.7.asc[]
176
3d3f32ae 177:leveloffset: 0
888d53f2
HH
178[appendix]
179License
180-------
181This work is licensed under the Creative Commons Attribution/Share-Alike
182License. To view a copy of this license, visit
183http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
184Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
185