]> git.ipfire.org Git - thirdparty/dracut.git/blame - dracut.modules.7.asc
Revert "wait for IPv6 RA if using none/static IPv6 assignment"
[thirdparty/dracut.git] / dracut.modules.7.asc
CommitLineData
b6c89768
HH
1DRACUT.MODULES(7)
2=================
3:doctype: manpage
4:man source: dracut
5:man manual: dracut
50057af1 6:man version: {version}
b6c89768
HH
7
8NAME
9----
10dracut.modules - dracut modules
11
12DESCRIPTION
13-----------
b6c89768
HH
14
15dracut uses a modular system to build and extend the initramfs image. All
16modules are located in _/usr/lib/dracut/modules.d_ or in _<git-src>/modules.d_.
17The most basic dracut module is _99base_. In _99base_ the initial shell script
18init is defined, which gets run by the kernel after initramfs loading. Although
19you can replace init with your own version of _99base_, this is not encouraged.
20Instead you should use, if possible, the hooks of dracut. All hooks, and the
21point of time in which they are executed, are described in <<stages>>.
22
d5e5855b 23The main script, which creates the initramfs is dracut itself. It parses all
b6c89768
HH
24arguments and sets up the directory, in which everything is installed. It then
25executes all check, install, installkernel scripts found in the modules, which
26are to be processed. After everything is installed, the install directory is
27archived and compressed to the final initramfs image. All helper functions used
28by check, install and installkernel are found in in the file _dracut-functions_.
29These shell functions are available to all module installer (install,
30installkernel) scripts, without the need to source _dracut-functions_.
31
32A module can check the preconditions for install and installkernel with the
33check script. Also dependencies can be expressed with check. If a module passed
34check, install and installkernel will be called to install all of the necessary
35files for the module. To split between kernel and non-kernel parts of the
36installation, all kernel module related parts have to be in installkernel. All
37other files found in a module directory are module specific and mostly are hook
38scripts and udev rules.
39
40
41[[stages]]
42== Boot Process Stages
43
44dracut modules can insert custom script at various points, to control the boot
45process.
46These hooks are plain directories containing shell scripts ending with ".sh",
47which are sourced by init.
48Common used functions are in _dracut-lib.sh_, which can be sourced by any script.
49
50=== Hook: cmdline
51
52The _cmdline_ hook is a place to insert scripts to parse the kernel command line
53and prepare the later actions, like setting up udev rules and configuration
54files.
55
56In this hook the most important environment variable is defined: root. The
57second one is rootok, which indicates, that a module claimed to be able to parse
58the root defined. So for example, **root=**__iscsi:....__ will be claimed by the
59iscsi dracut module, which then sets rootok.
60
61=== Hook: pre-udev
62
63This hook is executed right after the cmdline hook and a check if root and
64rootok were set. Here modules can take action with the final root, and before
65udev has been run.
66
67=== Start Udev
68
69Now udev is started and the logging for udev is setup.
70
71=== Hook: pre-trigger
72
73In this hook, you can set udev environment variables with **udevadm control
74--property=KEY=_value_** or control the further execution of udev with
75udevadm.
76
77=== Trigger Udev
78
79udev is triggered by calling udevadm trigger, which sends add events for all
80devices and subsystems.
81
82=== Main Loop
83
84In the main loop of dracut loops until udev has settled and
85all scripts in _initqueue/finished_ returned true.
86In this loop there are three hooks, where scripts can be inserted
87by calling /sbin/initqueue.
88
89==== Initqueue
90
91This hook gets executed every time a script is inserted here, regardless of the
92udev state.
93
94==== Initqueue settled
95
96This hooks (initqueue/settled) gets executed every time udev has settled.
97
98==== Initqueue timeout
99
ef9ddb91
HH
100This hooks (initqueue/timeout) gets executed, when the main loop counter becomes
101half of the rd.retry counter.
b6c89768
HH
102
103==== Initqueue finished
104
105This hook (initqueue/finished) is called after udev has settled and
106if all scripts herein return 0 the main loop will be ended.
ead8729b 107Arbitrary scripts can be added here, to loop in the
b6c89768
HH
108initqueue until something happens, which a dracut module wants to wait for.
109
110=== Hook: pre-mount
111
112Before the root device is mounted all scripts in the hook pre-mount are
113executed. In some cases (e.g. NFS) the real root device is already mounted,
114though.
115
116=== Hook: mount
117
118This hook is mainly to mount the real root device.
119
120=== Hook: pre-pivot
121
122This hook is called before cleanup hook, This is a good place for
123actions other than cleanups which need to be called before pivot.
124
125=== Hook: cleanup
126
127This hook is the last hook and is called before init finally switches root to
128the real root device. This is a good place to clean up and kill processes not
129needed anymore.
130
131
132=== Cleanup and switch_root
133
134Init (or systemd) kills all udev processes, cleans up the environment,
135sets up the arguments for the real init process and finally calls switch_root.
136switch_root removes the whole filesystem hierarchy of the initramfs,
ef9ddb91
HH
137chroot()s to the real root device and calls /sbin/init with the specified
138arguments.
b6c89768
HH
139
140To ensure all files in the initramfs hierarchy can be removed, all processes
141still running from the initramfs should not have any open file descriptors left.
142
143== Network Infrastructure
144
145FIXME
146
147== Writing a Module
148
149A simple example module is _96insmodpost_, which modprobes a kernel module after
150udev has settled and the basic device drivers have been loaded.
151
152All module installation information is in the file module-setup.sh.
153
154First we create a check() function, which just exits with 0 indicating that this
155module should be included by default.
156
157check():
158----
159return 0
160----
161
162The we create the install() function, which installs a cmdline hook with
163priority number 20 called _parse-insmodpost.sh_. It also installs the
164_insmodpost.sh_ script in _/sbin_.
165
166install():
167----
168inst_hook cmdline 20 "$moddir/parse-insmodpost.sh"
169inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
170----
171
f2c42365 172The _parse-instmodpost.sh_ parses the kernel command line for a argument
b6c89768
HH
173rd.driver.post, blacklists the module from being autoloaded and installs the
174hook _insmodpost.sh_ in the _initqueue/settled_.
175
176_parse-insmodpost.sh_:
177----
178for p in $(getargs rd.driver.post=); do
179 echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf
180 _do_insmodpost=1
181done
182
183[ -n "$_do_insmodpost" ] && /sbin/initqueue --settled --unique --onetime /sbin/insmodpost.sh
184unset _do_insmodpost
185
186----
187
188_insmodpost.sh_, which is called in the _initqueue/settled_ hook will just
189modprobe the kernel modules specified in all rd.driver.post kernel command line
190parameters. It runs after udev has settled and is only called once (--onetime).
191
192_insmodpost.sh_:
193----
194. /lib/dracut-lib.sh
195
196for p in $(getargs rd.driver.post=); do
197 modprobe $p
198done
199
200----
201
202
203=== module-setup.sh: check()
204
205_check()_ is called by dracut to evaluate the inclusion of a dracut module in
206the initramfs.
207
208$hostonly:: If the $hostonly variable is set, then the module check() function
209should be in "hostonly" mode, which means, that the check() should only return
2100, if the module is really needed to boot this specific host.
211
212check() should return with:
213
2140:: Include the dracut module in the initramfs.
215
d0921882 2161:: Do not include the dracut module. The requirements are not fulfilled
b6c89768
HH
217(missing tools, etc.)
218
219255:: Only include the dracut module, if another module requires it or if
220explicitly specified in the config file or on the argument list.
221
222
223=== module-setup.sh: depends()
224
225The function depends() should echo all other dracut module names the module
226depends on.
227
228=== module-setup.sh: cmdline()
229
ef9ddb91
HH
230This function should print the kernel command line options needed to boot the
231current machine setup. It should start with a space and should not print a
232newline.
b6c89768
HH
233
234=== module-setup.sh: install()
235
ef9ddb91
HH
236The install() function is called to install everything non-kernel related.
237To install binaries, scripts, and other files, you can use the functions
238mentioned in <<creation>>.
b6c89768
HH
239
240To address a file in the current module directory, use the variable "$moddir".
241
242=== module-setup.sh: installkernel()
243
ef9ddb91
HH
244In installkernel() all kernel related files should be installed. You can use all
245of the functions mentioned in <<creation>> to install files.
b6c89768
HH
246
247=== [[creation]]Creation Functions
248
249==== inst_multiple [-o] <file> [ <file> ...]
250
ef9ddb91
HH
251installs multiple binaries and files. If executables are specified without a
252path, dracut will search the path PATH=/usr/sbin:/sbin:/usr/bin:/bin for the
253binary. If the option "-o" is given as the first parameter, a missing file does
254not lead to an error.
b6c89768
HH
255
256==== inst <src> [<dst>]
257
ef9ddb91 258installs _one_ file <src> either to the same place in the initramfs or to an
d0921882
TK
259optional <dst>. inst with more than two arguments is treated the same as
260inst_multiple, all arguments are treated as files to install and none as
3161dea8 261install destinations.
b6c89768
HH
262
263==== inst_hook <hookdir> <prio> <src>
264
ef9ddb91
HH
265installs an executable/script <src> in the dracut hook <hookdir> with priority
266<prio>.
b6c89768
HH
267
268==== inst_rules <udevrule> [ <udevrule> ...]
269
fb280834 270installs one or more udev rules. Non-existant udev rules are reported, but do
ef9ddb91 271not let dracut fail.
b6c89768
HH
272
273==== instmods <kernelmodule> [ <kernelmodule> ... ]
274
275instmods should be used only in the installkernel() function.
276
ef9ddb91
HH
277instmods installs one or more kernel modules in the initramfs. <kernelmodule>
278can also be a whole subsystem, if prefixed with a "=", like "=drivers/net/team".
b6c89768 279
ef9ddb91
HH
280instmods will not install the kernel module, if $hostonly is set and the kernel
281module is not currently needed by any /sys/*...*/uevent MODALIAS.
b6c89768
HH
282To install a kernel module regardless of the hostonly mode use the form:
283----
284hostonly='' instmods <kernelmodule>
285----
286
287=== Initramfs Functions
288
289FIXME
290
291
292=== Network Modules
293
294FIXME
295
296AUTHOR
297------
298Harald Hoyer
299
300SEE ALSO
301--------
302*dracut*(8)