summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntonin Godard <antonin.godard@bootlin.com>2025-01-27 10:18:12 +0100
committerSteve Sakoman <steve@sakoman.com>2025-02-03 06:13:13 -0800
commit184adcbc322f040614bc0c080c25a64252fcd58b (patch)
tree810b95a6ab9d6288b43b03e704a20903a5c720dc
parent3669699eb30b7f5ea778ecd7403d82edb3602547 (diff)
downloadpoky-184adcbc322f040614bc0c080c25a64252fcd58b.tar.gz
dev-manual/building: document the initramfs-framework recipe
[ YOCTO #14747 ] Adding a initramfs is a common task, and the way oe-core offers to do so is by using the initramfs-framework recipe and companion modules. There was already documentation on adding an initramfs but the documentation was lacking details on this framework. Add it before the multiconfig section because it is a bit more important IMO. Reported-by: Alejandro <alejandro@enedino.org> Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de> (From yocto-docs rev: e1aa69d00e20a5d3c948c430ed10eb01e7baa574) Signed-off-by: Antonin Godard <antonin.godard@bootlin.com> (cherry picked from commit caedbca4eced4cf5bc74aaae64e4ad2887c2fc65) Signed-off-by: Antonin Godard <antonin.godard@bootlin.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--documentation/dev-manual/building.rst84
1 files changed, 83 insertions, 1 deletions
diff --git a/documentation/dev-manual/building.rst b/documentation/dev-manual/building.rst
index fe502690dd..4770a5a184 100644
--- a/documentation/dev-manual/building.rst
+++ b/documentation/dev-manual/building.rst
@@ -280,7 +280,9 @@ Follow these steps to create an :term:`Initramfs` image:
280#. *Create the Initramfs Image Recipe:* You can reference the 280#. *Create the Initramfs Image Recipe:* You can reference the
281 ``core-image-minimal-initramfs.bb`` recipe found in the 281 ``core-image-minimal-initramfs.bb`` recipe found in the
282 ``meta/recipes-core`` directory of the :term:`Source Directory` 282 ``meta/recipes-core`` directory of the :term:`Source Directory`
283 as an example from which to work. 283 as an example from which to work. The ``core-image-minimal-initramfs`` recipe
284 is based on the :ref:`initramfs-framework <dev-manual/building:Customizing an
285 Initramfs using \`\`initramfs-framework\`\`>` recipe described below.
284 286
285#. *Decide if You Need to Bundle the Initramfs Image Into the Kernel 287#. *Decide if You Need to Bundle the Initramfs Image Into the Kernel
286 Image:* If you want the :term:`Initramfs` image that is built to be bundled 288 Image:* If you want the :term:`Initramfs` image that is built to be bundled
@@ -308,6 +310,86 @@ Follow these steps to create an :term:`Initramfs` image:
308 and bundled with the kernel image if you used the 310 and bundled with the kernel image if you used the
309 :term:`INITRAMFS_IMAGE_BUNDLE` variable described earlier. 311 :term:`INITRAMFS_IMAGE_BUNDLE` variable described earlier.
310 312
313Customizing an Initramfs using ``initramfs-framework``
314------------------------------------------------------
315
316The ``core-image-minimal-initramfs.bb`` recipe found in
317:oe_git:`meta/recipes-core/images
318</openembedded-core/tree/meta/recipes-core/images>` uses the
319:oe_git:`initramfs-framework_1.0.bb
320</openembedded-core/tree/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb>`
321recipe as its base component. The goal of the ``initramfs-framework`` recipe is
322to provide the building blocks to build a customized :term:`Initramfs`.
323
324The ``initramfs-framework`` recipe relies on shell initialization scripts
325defined in :oe_git:`meta/recipes-core/initrdscripts/initramfs-framework
326</openembedded-core/tree/meta/recipes-core/initrdscripts/initramfs-framework>`. Since some of
327these scripts do not apply for all use cases, the ``initramfs-framework`` recipe
328defines different packages:
329
330- ``initramfs-framework-base``: this package installs the basic components of
331 an :term:`Initramfs`, such as the ``init`` script or the ``/dev/console``
332 character special file. As this package is a runtime dependency of all
333 modules listed below, it is automatically pulled in when one of the modules
334 is installed in the image.
335- ``initramfs-module-exec``: support for execution of applications.
336- ``initramfs-module-mdev``: support for `mdev
337 <https://wiki.gentoo.org/wiki/Mdev>`__.
338- ``initramfs-module-udev``: support for :wikipedia:`Udev <Udev>`.
339- ``initramfs-module-e2fs``: support for :wikipedia:`ext4/ext3/ext2
340 <Extended_file_system>` filesystems.
341- ``initramfs-module-nfsrootfs``: support for locating and mounting the root
342 partition via :wikipedia:`NFS <Network_File_System>`.
343- ``initramfs-module-rootfs``: support for locating and mounting the root
344 partition.
345- ``initramfs-module-debug``: dynamic debug support.
346- ``initramfs-module-lvm``: :wikipedia:`LVM <Logical_volume_management>` rootfs support.
347- ``initramfs-module-overlayroot``: support for mounting a read-write overlay
348 on top of a read-only root filesystem.
349
350In addition to the packages defined by the ``initramfs-framework`` recipe
351itself, the following packages are defined by the recipes present in
352:oe_git:`meta/recipes-core/initrdscripts </openembedded-core/tree/meta/recipes-core/initrdscripts>`:
353
354- ``initramfs-module-install``: module to create and install a partition layout
355 on a selected block device.
356- ``initramfs-module-install-efi``: module to create and install an EFI
357 partition layout on a selected block device.
358- ``initramfs-module-setup-live``: module to start a shell in the
359 :term:`Initramfs` if ``root=/dev/ram0`` in passed in the `Kernel command-line
360 <https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html>`__
361 or the ``root=`` parameter was not passed.
362
363To customize the :term:`Initramfs`, you can add or remove packages listed
364earlier from the :term:`PACKAGE_INSTALL` variable with a :ref:`bbappend
365<dev-manual/layers:Appending Other Layers Metadata With Your Layer>` on the
366``core-image-minimal-initramfs`` recipe, or create a custom recipe for the
367:term:`Initramfs` taking ``core-image-minimal-initramfs`` as example.
368
369Custom scripts can be added to the :term:`Initramfs` by writing your own
370recipes. The recipes are conventionally named ``initramfs-module-<module name>``
371where ``<module name>`` is the name of the module. The recipe should set its
372:term:`RDEPENDS` package-specific variables to include
373``initramfs-framework-base`` and the other packages on which the module depends
374at runtime.
375
376The recipe must install shell initialization scripts in :term:`${D} <D>`\
377``/init.d`` and must follow the ``<number>-<script name>`` naming scheme where:
378
379- ``<number>`` is a *two-digit* number that affects the execution order of the
380 script compared to others. For example, the script ``80-setup-live`` would be
381 executed after ``01-udev`` because 80 is greater than 01.
382
383 This number being two-digits is important here as the scripts are executed
384 alphabetically. For example, the script ``10-script`` would be executed
385 before the script ``8-script``, because ``1`` is inferior to ``8``.
386 Therefore, the script should be named ``08-script``.
387
388- ``<script name>`` is the script name which you can choose freely.
389
390 If two script use the same ``<number>``, they are sorted alphabetically based
391 on ``<script name>``.
392
311Bundling an Initramfs Image From a Separate Multiconfig 393Bundling an Initramfs Image From a Separate Multiconfig
312------------------------------------------------------- 394-------------------------------------------------------
313 395