An initial RAM filesystem (initramfs) image provides a temporary root filesystem used for early system initialization (e.g. loading of modules needed to locate and mount the "real" root filesystem).
Follow these steps to create an initramfs image:
Create the initramfs Image Recipe:
You can reference the
core-image-minimal-initramfs.bb
recipe found in the meta/recipes-core
directory of the
Source Directory
as an example from which to work.
Decide if You Need to Bundle the initramfs Image
Into the Kernel Image:
If you want the initramfs image that is built to be
bundled in with the kernel image, set the
INITRAMFS_IMAGE_BUNDLE
variable to "1" in your local.conf
configuration file and set the
INITRAMFS_IMAGE
variable in the recipe that builds the kernel image.
Setting the INITRAMFS_IMAGE_BUNDLE
flag causes the initramfs image to be unpacked
into the ${B}/usr/
directory.
The unpacked initramfs image is then passed to the kernel's
Makefile
using the
CONFIG_INITRAMFS_SOURCE
variable, allowing the initramfs image to be built into
the kernel normally.
INITRD_IMAGE
,
INITRD_LIVE
, and
INITRD_IMAGE_LIVE
variables.
For more information, see the
image-live.bbclass
file.
Optionally Add Items to the initramfs Image
Through the initramfs Image Recipe:
If you add items to the initramfs image by way of its
recipe, you should use
PACKAGE_INSTALL
rather than
IMAGE_INSTALL
.
PACKAGE_INSTALL
gives more direct
control of what is added to the image as compared to
the defaults you might not necessarily want that are
set by the
image
or
core-image
classes.
Build the Kernel Image and the initramfs
Image:
Build your kernel image using BitBake.
Because the initramfs image recipe is a dependency of the
kernel image, the initramfs image is built as well and
bundled with the kernel image if you used the
INITRAMFS_IMAGE_BUNDLE
variable described earlier.