Repository navigation
NewFeature
Features serve to extend the functionality of the make-initrd.
Features are located in the features directory.
Let's assume the feature name is mdadm. In this case, the directory structure
will be:
features/<NAME>
`- README.md
`- config.mk
`- rules.mk
`- pack.mk
`- data/
`- tests/
`- guess/
- README.md - this file contains the documentation of the feature that describes the functionality and parameters.
- config.mk - this file is always read. It should only contain the definition of feature-specific variables. In this file, the kernel is checked (if necessary).
- rules.mk - this file will be used if the
mdadmfeature is used. In this file that the real actions should be described. - data/ - this directory contains a piece of initramfs image that you want to put into the image "as is" (Optional).
- tests/ - the directory contains unit tests for the feature (Optional).
- guess/ - the directory contains a part of the guess subsystem (Optional).
Let's say in the image you need to put a mdadm utility, its configuration file and the data that the utility needs. To do this, we need to create a description of its resources:
MDAMD_RULES = \
/lib/udev/rules.d/63-md-raid-arrays.rules \
/lib/udev/rules.d/64-md-raid-assembly.rules
MDADM_CONF ?= $(SYSCONFDIR)/mdadm.conf
MDADM_PROGS = mdadm
MDADM_FILES = $(wildcard $(MDAMD_RULES) $(MDADM_CONF))
MDADM_DATADIR = $(FEATURESDIR)/mdadm/dataVariables do not need to be prefixed like this (MDADM_). It must be unique
among other features. Usually a prefix based on the feature name.
The MDADM_CONF variable is marked as overridden so that at the time of
initramfs image creation, you can specify a different configuration file.
The MDADM_DATADIR contains a path to data/ directory. In this directory we
will put additional files needed for this feature.
This file adds files to those required in the initramfs image. There are several special variables to do this.
-
PUT_FEATURE_DIRScontains a list of directories whose contents should be copied as is. -
PUT_FEATURE_FILEScontains a list of files that are copied to the image with the full path to the file. If a directory is placed in this list, then the directory will be copied with all the contents in it. -
PUT_FEATURE_PROGScontains a list of program names. These programs will be found in the PATH and copied to the image. -
PUT_FEATURE_PROGS_WILDCARDcontains a list of glob patterns for the full path to utilities in thePATH. -
PUT_FEATURE_LIBScontains a list of libraries that are copied to the image. The library will be copied with all linked dependencies. -
PUT_FEATURE_OPTIONAL_LIBSthis is the same asPUT_FEATURE_LIBSbut only if the library is not found the error does not happen.
PUT_FEATURE_DIRS += $(MDADM_DATADIR)
PUT_FEATURE_FILES += $(MDADM_FILES)
PUT_FEATURE_PROGS += $(MDADM_PROGS)All binary utilities will be copied along with a libraries with which they are linked.
The guess/ directory contains autodetection logic for the feature. A feature can
provide up to four types of detection scripts:
-
guess/action- The primary autodetection module. It is executed byguess-runnerwhen scheduled byAUTODETECT(or triggered by dependencies). -
guess/device- Invoked byrootfswhile traversing parent block devices in/sys(for example, to detect stacked storage like LVM, LUKS, RAID, or bcache). Features can optionally provide a lightweightguess/device.filtershell script containing adevice_filterfunction to skip invoking the hook script for non-matching sysfs devices. -
guess/fstype- Invoked byrootfsto identify filesystem types and propose the necessary filesystem kernel modules. -
guess/common- Unconditional detection hook executed during thecommondetection pass (for example, to detect system locales or compression tools).
Detection scripts use helper functions provided by guess-functions:
# Propose enabling another feature
guess_feature lvm
# Propose adding a kernel module
guess_module scsi_mod
guess_module rescue hid-generic
# Propose a modalias to resolve to kernel drivers
guess_modalias "pci:v000015B7d00005009sv*"
# Propose a configuration variable
guess_variable MOUNTPOINTS "/boot"If a feature requires additional guess modules to be run when this feature is
activated, declare it in config.mk:
$(call guess-requires, lvm luks)When guess-runner activates the feature, any required detection modules are
automatically enqueued into subsequent detection passes.
This file contains the targets and variables used to package the generated
image. The pre-pack and post-pack targets are used to perform any actions
before or after the image is packed.
- Get Started
- Initramfs Runtime
- Image Generation
- Contributing
- FAQ
- Presentations