Revision as of 13:54, 17 March 2016

dracut

dracut is an event driven initramfs infrastructure. dracut (the tool) is used to create an initramfs image by copying tools and files from an installed system and combining it with the dracut framework, usually found in /usr/lib/dracut/modules.d.

Unlike existing initramfs's, dracut's framework attempts at having as little as possible hard-coded into the initramfs as possible. The initramfs has (basically) one purpose in life -- getting the rootfs mounted so that we can transition to the real rootfs. This is all driven off of device availability. Therefore, instead of scripts hard-coded to do various things, dracut's initramfs depends on udev to create symbolic links to device nodes and then when the rootfs's device node appears, it is mounted and root is switched to it. This helps to keep the time required in the initramfs as little as possible so that things like a 5 second boot aren't made impossible as a result of the very existence of an initramfs.

Most of the initramfs generation functionality in dracut is provided by a bunch of generator modules that are sourced by the main dracut tool to install specific functionality into the initramfs. They live in the modules subdirectory, and use functionality provided by dracut-functions to do their work.

There is also a mailing list that is being used for the discussion -- initramfs <at> vger.kernel.org. It is a typical vger list, send mail to majordomo <at> vger.kernel.org with body of subscribe initramfs email <at> host.com

Use one of the inst family of functions to actually install files on to the initrd. They handle mangling the pathnames and (for binaries, scripts, and kernel modules) installing dependencies as appropriate so you do not have to.

Scripts that end up on the initrd should be POSIX compliant. dracut will try to use /bin/dash as /bin/sh for the initrd if it is available, so you should install it on your system -- dash aims for strict POSIX compliance to the extent possible.

Hooks MUST be POSIX compliant -- they are sourced by the init script, and having a bashism break your user's ability to boot really sucks.

Generator modules should have a two digit numeric prefix -- they run in ascending sort order. Anything in the 90-99 range is stuff that dracut relies on, so try not to break those hooks.

Generator modules and hooks must have a .sh extension.

We have some breakpoints for debugging your hooks. If you pass 'rd.break rd.shell' as a boot option on the kernel command line, the initramfs will drop to a shell just before switching to a new root. You can pass 'rd.break=hookpoint', and the initramfs will break just before hooks in that hookpoint run. [1][2]

Also, there is an attempt to keep things as distribution-agnostic as possible. Every distribution has their own tool here and it's not something which is really interesting to have separate across them. So contributions to help decrease the distro-dependencies are welcome.