MKINITRAMFS.HOOKS(7) | Miscellaneous Information Manual | MKINITRAMFS.HOOKS(7) |
mkinitramfs.hooks
—
mkinitramfs hooks and related stuff
mkinitramfs hooks provides a way to extend initramfs' build and init process. Hooks must be written in POSIX shell. Bashisms and other non-portable extensions are prohibited.
Hooks can be located in
/usr/share/mkinitramfs/hooks (system path) and
/etc/mkinitramfs/hooks (user path). It is also
allowed to specify custom location via
mkinitramfs(8)'
-H
hooksdir option.
In order to write hooks you must know about hook structure. Example:
hooks/ `‐‐ <hook>/ ← Directory of hook scripts |‐‐ <hook> ← Invoked in build process |‐‐ <hook>.init ← Invoked in init process `‐‐ <hook>.init.late ← Invoked after root filesystem was mounted
The following functions can be used by hooks in build process:
If NAME was specified, the mkinitramfs will try to find command by name in “PATH”. If success, command will be copied to /bin location of mkinitramfs working directory. Otherwise error message will appear.
The following functions can be used by hooks in init process:
The following functions can be used by hooks in both processes (build and init):
The following variables can be used by hooks in build process:
The following variables can be used by hooks in init process:
The following variables can be used by hooks in both processes (build and init):
See mkinitramfs.config(5) for additional information about available hooks.
This example will show how to handle soft dependencies of ext4 module. Create /etc/mkinitramfs/hooks/ext4 directory and copy below scripts with appropriate names to that directory. After that, prepend ext4 to hooks option in mkinitramfs' config (/etc/mkinitramfs/config).
mkinitramfs.config(5), mkinitramfs.cmdline(7), mkinitramfs(8)
May 22, 2024 | Zeppe-Lin |