2009-05-23 06:24:29 +04:00
Most of the functionality that dracut implements are actually implemented
2012-10-10 16:15:11 +04:00
by dracut modules. dracut modules live in modules.d, and have the following
2009-05-23 06:24:29 +04:00
structure:
dracut_install_dir/modules.d/
00modname/
2011-04-06 11:57:39 +04:00
module-setup.sh
2009-05-23 06:24:29 +04:00
check
<other files as needed by the hook>
00modname: The name of the module prefixed by a two-digit numeric sort code.
The numeric code must be present and in the range of 00 - 99.
Modules with lower numbers are installed first. This is important
because the dracut install functions (which install files onto
2011-05-10 13:39:10 +04:00
the initrd) refuse to overwrite already installed files. This makes
it easy for an earlier module to override the functionality of a
2009-05-23 06:24:29 +04:00
later module, so that you can have a distro or system specific
module override or modify the functionality of a generic module
2009-06-03 17:16:44 +04:00
without having to patch the more generic module.
2009-05-23 06:24:29 +04:00
2011-04-06 11:57:39 +04:00
module-setup.sh:
2011-05-10 13:39:10 +04:00
dracut sources this script to install the functionality that a
2009-05-23 06:24:29 +04:00
module implements onto the initrd. For the most part, this amounts
to copying files from the host system onto the initrd in a controlled
2011-05-10 13:39:10 +04:00
manner.
2011-04-06 11:57:39 +04:00
install():
2011-05-10 13:39:10 +04:00
This function of module-setup.sh is called to install all
2011-04-06 11:57:39 +04:00
non-kernel files. dracut supplies several install functions that are
2009-05-23 06:24:29 +04:00
specialized for different file types. Browse through dracut-functions
fore more details. dracut also provides a $moddir variable if you
need to install a file from the module directory, such as an initrd
hook, a udev rule, or a specialized executable.
2011-04-06 11:57:39 +04:00
installkernel():
2011-05-10 13:39:10 +04:00
This function of module-setup.sh is called to install all
2011-04-06 11:57:39 +04:00
kernel related files.
2011-05-10 13:39:10 +04:00
check():
2012-10-10 16:15:11 +04:00
dracut calls this function to check and see if a module can be installed
2009-05-23 06:24:29 +04:00
on the initrd.
2011-05-10 13:39:10 +04:00
2009-05-23 06:24:29 +04:00
When called without options, check should check to make sure that
any files it needs to install into the initrd from the host system
are present. It should exit with a 0 if they are, and a 1 if they are
not.
2011-05-10 13:39:10 +04:00
When called with $hostonly set, it should perform the same check
that it would without it set, and it should also check to see if the
2009-05-23 06:24:29 +04:00
functionality the module implements is being used on the host system.
For example, if this module handles installing support for LUKS
encrypted volumes, it should return 0 if all the tools to handle
encrpted volumes are available and the host system has the root
partition on an encrypted volume, 1 otherwise.
2011-04-06 11:57:39 +04:00
depends():
This function should output a list of dracut modules
2009-08-20 23:14:21 +04:00
that it relies upon. An example would be the nfs and iscsi modules,
which rely on the network module to detect and configure network
interfaces.
2011-05-10 13:39:10 +04:00
Any other files in the module will not be touched by dracut directly.
2009-05-23 06:24:29 +04:00
2009-07-13 14:26:14 +04:00
You are encouraged to provide a README that describes what the module is for.
HOOKS
=====
init has the following hook points to inject scripts:
2011-04-06 11:57:39 +04:00
/lib/dracut/hooks/cmdline/*.sh
2009-07-13 14:26:14 +04:00
scripts for command line parsing
2011-04-06 11:57:39 +04:00
/lib/dracut/hooks/pre-udev/*.sh
2009-07-13 14:26:14 +04:00
scripts to run before udev is started
2011-04-06 11:57:39 +04:00
/lib/dracut/hooks/pre-trigger/*.sh
2009-07-13 14:26:14 +04:00
scripts to run before the main udev trigger is pulled
2011-04-06 11:57:39 +04:00
/lib/dracut/hooks/initqueue/*.sh
2009-07-13 14:26:14 +04:00
runs in parallel to the udev trigger
Udev events can add scripts here with /sbin/initqueue.
If /sbin/initqueue is called with the "--onetime" option, the script
will be removed after it was run.
2011-05-10 13:39:10 +04:00
If /lib/dracut/hooks/initqueue/work is created and udev >= 143 then
2011-04-06 11:57:39 +04:00
this loop can process the jobs in parallel to the udevtrigger.
2009-07-13 14:26:14 +04:00
If the udev queue is empty and no root device is found or no root
filesystem was mounted, the user will be dropped to a shell after
a timeout.
Scripts can remove themselves from the initqueue by "rm $job".
2011-04-06 11:57:39 +04:00
/lib/dracut/hooks/pre-mount/*.sh
2009-07-13 14:26:14 +04:00
scripts to run before the root filesystem is mounted
2011-05-10 13:39:10 +04:00
Network filesystems like NFS that do not use device files are an
2009-07-13 14:26:14 +04:00
exception. Root can be mounted already at this point.
2011-04-06 11:57:39 +04:00
/lib/dracut/hooks/mount/*.sh
2009-07-13 14:26:14 +04:00
scripts to mount the root filesystem
If the udev queue is empty and no root device is found or no root
filesystem was mounted, the user will be dropped to a shell after
a timeout.
2011-04-06 11:57:39 +04:00
/lib/dracut/hooks/pre-pivot/*.sh
2012-04-19 08:01:36 +04:00
scripts to run before latter initramfs cleanups
2012-04-23 13:31:32 +04:00
/lib/dracut/hooks/cleanup/*.sh
2009-07-13 14:26:14 +04:00
scripts to run before the real init is executed and the initramfs
disappears
All processes started before should be killed here.