]>
Commit | Line | Data |
---|---|---|
2e7b8713 | 1 | Most of the functionality that dracut implements are actually implemented |
600c8769 | 2 | by dracut modules. dracut modules live in modules.d, and have the following |
2e7b8713 VL |
3 | structure: |
4 | ||
5 | dracut_install_dir/modules.d/ | |
6 | 00modname/ | |
6600691f | 7 | module-setup.sh |
2e7b8713 VL |
8 | check |
9 | <other files as needed by the hook> | |
10 | ||
11 | 00modname: The name of the module prefixed by a two-digit numeric sort code. | |
12 | The numeric code must be present and in the range of 00 - 99. | |
13 | Modules with lower numbers are installed first. This is important | |
14 | because the dracut install functions (which install files onto | |
3b403b32 HH |
15 | the initrd) refuse to overwrite already installed files. This makes |
16 | it easy for an earlier module to override the functionality of a | |
2e7b8713 VL |
17 | later module, so that you can have a distro or system specific |
18 | module override or modify the functionality of a generic module | |
d726d811 | 19 | without having to patch the more generic module. |
2e7b8713 | 20 | |
6600691f | 21 | module-setup.sh: |
3b403b32 | 22 | dracut sources this script to install the functionality that a |
2e7b8713 VL |
23 | module implements onto the initrd. For the most part, this amounts |
24 | to copying files from the host system onto the initrd in a controlled | |
3b403b32 | 25 | manner. |
6600691f HH |
26 | |
27 | install(): | |
3b403b32 | 28 | This function of module-setup.sh is called to install all |
6600691f | 29 | non-kernel files. dracut supplies several install functions that are |
2e7b8713 VL |
30 | specialized for different file types. Browse through dracut-functions |
31 | fore more details. dracut also provides a $moddir variable if you | |
32 | need to install a file from the module directory, such as an initrd | |
33 | hook, a udev rule, or a specialized executable. | |
34 | ||
6600691f | 35 | installkernel(): |
3b403b32 | 36 | This function of module-setup.sh is called to install all |
6600691f HH |
37 | kernel related files. |
38 | ||
39 | ||
3b403b32 | 40 | check(): |
600c8769 | 41 | dracut calls this function to check and see if a module can be installed |
2e7b8713 | 42 | on the initrd. |
3b403b32 | 43 | |
2e7b8713 VL |
44 | When called without options, check should check to make sure that |
45 | any files it needs to install into the initrd from the host system | |
46 | are present. It should exit with a 0 if they are, and a 1 if they are | |
47 | not. | |
48 | ||
3b403b32 HH |
49 | When called with $hostonly set, it should perform the same check |
50 | that it would without it set, and it should also check to see if the | |
2e7b8713 VL |
51 | functionality the module implements is being used on the host system. |
52 | For example, if this module handles installing support for LUKS | |
53 | encrypted volumes, it should return 0 if all the tools to handle | |
54 | encrpted volumes are available and the host system has the root | |
55 | partition on an encrypted volume, 1 otherwise. | |
56 | ||
6600691f HH |
57 | depends(): |
58 | This function should output a list of dracut modules | |
8d04a128 VL |
59 | that it relies upon. An example would be the nfs and iscsi modules, |
60 | which rely on the network module to detect and configure network | |
61 | interfaces. | |
62 | ||
3b403b32 | 63 | Any other files in the module will not be touched by dracut directly. |
2e7b8713 | 64 | |
07253f00 HH |
65 | You are encouraged to provide a README that describes what the module is for. |
66 | ||
67 | ||
68 | HOOKS | |
69 | ===== | |
70 | ||
71 | init has the following hook points to inject scripts: | |
72 | ||
6600691f | 73 | /lib/dracut/hooks/cmdline/*.sh |
07253f00 HH |
74 | scripts for command line parsing |
75 | ||
6600691f | 76 | /lib/dracut/hooks/pre-udev/*.sh |
07253f00 HH |
77 | scripts to run before udev is started |
78 | ||
6600691f | 79 | /lib/dracut/hooks/pre-trigger/*.sh |
07253f00 HH |
80 | scripts to run before the main udev trigger is pulled |
81 | ||
6600691f | 82 | /lib/dracut/hooks/initqueue/*.sh |
07253f00 HH |
83 | runs in parallel to the udev trigger |
84 | Udev events can add scripts here with /sbin/initqueue. | |
85 | If /sbin/initqueue is called with the "--onetime" option, the script | |
86 | will be removed after it was run. | |
3b403b32 | 87 | If /lib/dracut/hooks/initqueue/work is created and udev >= 143 then |
6600691f | 88 | this loop can process the jobs in parallel to the udevtrigger. |
07253f00 HH |
89 | If the udev queue is empty and no root device is found or no root |
90 | filesystem was mounted, the user will be dropped to a shell after | |
91 | a timeout. | |
92 | Scripts can remove themselves from the initqueue by "rm $job". | |
93 | ||
6600691f | 94 | /lib/dracut/hooks/pre-mount/*.sh |
07253f00 | 95 | scripts to run before the root filesystem is mounted |
3b403b32 | 96 | Network filesystems like NFS that do not use device files are an |
07253f00 HH |
97 | exception. Root can be mounted already at this point. |
98 | ||
6600691f | 99 | /lib/dracut/hooks/mount/*.sh |
07253f00 HH |
100 | scripts to mount the root filesystem |
101 | If the udev queue is empty and no root device is found or no root | |
102 | filesystem was mounted, the user will be dropped to a shell after | |
103 | a timeout. | |
104 | ||
6600691f | 105 | /lib/dracut/hooks/pre-pivot/*.sh |
2e7257a2 DY |
106 | scripts to run before latter initramfs cleanups |
107 | ||
eef7649e | 108 | /lib/dracut/hooks/cleanup/*.sh |
07253f00 HH |
109 | scripts to run before the real init is executed and the initramfs |
110 | disappears | |
111 | All processes started before should be killed here. | |
112 |