Module 4 · Lesson 113 of 156

Images and package groups

Define a custom Yocto image, select packages and image features, and verify the installed package set after a build.

  • Beginner to advanced
  • 7 min read
  • 30 min lab
What you will need

Ubuntu 24.04 in WSL2 or a VM, an initialized Yocto build environment, and a writable layer enabled in that build. No target board is required.

Your place in the module
By the end you can 4 objectives
  • Explain how IMAGE_INSTALL and IMAGE_FEATURES contribute to a Yocto image.
  • Define a package group with required runtime dependencies.
  • Build a custom image that includes the package group.
  • Verify installed packages in the resulting image manifest.
Video coming soonImages and package groups
The video for this lesson is being recorded. Read the lesson below in the meantime.
Recall first from Creating a BSP and distro layer
  • A machine name selects a file under conf/machine in an enabled layer.
  • A distro name selects a file under conf/distro in an enabled layer.
  • DISTRO_FEATURES supplies policy that recipes can use to configure software.
01

What an image recipe selects

3 min read

The machine and distro are set; the image decides what software actually ships. This lesson answers image recipes and IMAGE_INSTALL, and packagegroup recipes that pull in a whole set.

A Linux kernel can reach the point where it needs to start a user-space init program and still have no usable init available. The kernel documentation describes how it looks for /init in the unpacked initramfs and, if that file is absent, falls back to the older root-mount path. For a Yocto image, the corresponding build question is concrete. Which packages put the required programs, libraries, and configuration files into the root filesystem that the target will use? Linux kernel documentation on rootfs and initramfs

An describes a complete software selection for a purpose. You can build a minimal image and a diagnostics image with the same build configuration. Each has its own target name, so the image recipe lets you make the software selection repeatable and review it alongside the other metadata in your layer.

IMAGE_INSTALL is a space-separated list of runtime package names requested for the image. For example, the following line adds ethtool to the package selection after the base image recipe has been included. The leading space inside the quotes keeps ethtool separate from the previous entry because :append concatenates text without inserting a separator.

bitbake
IMAGE_INSTALL:append = " ethtool"

Use the name of the output package you need. A recipe can produce several packages, so an image can request a specific output package without requesting every other output from that recipe. For example, ethtool requests the main runtime package. Where a recipe also emits a -dev package, that package has its own name and typically contains development files. The same reasoning applies when reviewing a longer install list. Read each word as a request for an installable package.

During root filesystem construction, the package manager installs the requested packages and resolves their dependencies. If a requested package needs a shared library supplied by another package, that library package can appear in the installed set even though its name never appears in the image recipe. The image manifest records the resulting package set. Use the recipe to understand what the image asks for and the manifest to check what the build installed.

From requested packages to installed packagesImagerecipeNames thebuildtargetIMAGE_INSTALLRequestsruntimepackagesResolve dependenciesIncluderequiredpackagesAssemblerootfilesystemImagemanifestRecordsinstalledpackagesImagerecipeNames thebuildtargetIMAGE_INSTALLRequestsruntimepackagesResolve dependenciesIncluderequiredpackagesAssemblerootfilesystemImagemanifestRecordsinstalledpackages
The image requests runtime packages, and dependency resolution determines the installed set.

IMAGE_INSTALL is useful for a direct requirement. If exactly one image needs ethtool, an entry in that image recipe expresses the requirement clearly. If a diagnostics image and a factory image both need the same set of tools, maintaining a copy of the list in each recipe makes it possible for the lists to diverge. A package group defines the set in one place.

02

What an image feature changes

2 min read

IMAGE_FEATURES is a list of named capabilities understood by the image classes. An image feature can select packages, change how the root filesystem is configured, or do both. For example, ssh-server-dropbear selects the packages for a Dropbear SSH server in an image based on the core-image class. The read-only-rootfs feature configures the image for a read-only root filesystem. The latter is a useful example because the feature expresses behavior for the image as a whole.

bitbake
IMAGE_FEATURES:append = " ssh-server-dropbear"

The line above belongs in an image recipe when remote login is a deliberate requirement for that image. The class maps the feature name to the package selection. Writing ssh-server-dropbear in IMAGE_INSTALL would ask the package manager for a runtime package with that literal name. Writing ethtool in IMAGE_FEATURES would ask the image class for a feature named ethtool. The image class validates feature names, so an unsupported feature value can stop the build. If the requirement is simply to ship ethtool, use its package name in IMAGE_INSTALL or in a package group's dependencies.

For a build-local experiment, use EXTRA_IMAGE_FEATURES in conf/local.conf. Its values are added to IMAGE_FEATURES. A setting there can affect multiple image targets built with that configuration. For a capability that belongs to one maintained image, keep the setting in that image's recipe. When comparing two builds of the same image, check EXTRA_IMAGE_FEATURES as well as the recipe so you know which features each build used.

Packages and features in an image recipeIMAGE_INSTALLIMAGE_FEATURESEntry namesRuntimepackageImagecapabilityExampleethtoolssh-server-dropbearEffectRequestspackageinstallationSelectspackages orconfiguration
Package names and feature names are interpreted by different build logic.

If an image gains SSH support after a feature change, the manifest can confirm whether the Dropbear package was installed. Feature effects that change configuration need evidence appropriate to the behavior. A package list alone cannot tell you whether the running system mounts its root filesystem read-only. Choose the evidence based on what the feature is supposed to change.

03

Reuse a package set and verify the image

3 min read

A gives an image a single name for a capability defined by your project. A packagegroup-* recipe inherits packagegroup and declares the runtime packages it requires. The group can be empty of files because its job is to express dependencies. Whenever an image installs the group, the package manager must also satisfy those dependencies.

In your enabled layer, save the following as recipes-core/packagegroups/packagegroup-course-diagnostics.bb. The group requires ethtool for inspecting network interfaces and strace for tracing system calls. Both are available from OpenEmbedded-Core.

bitbake
SUMMARY = "Diagnostics tools for the course image"
LICENSE = "MIT"

inherit packagegroup

RDEPENDS:${PN} = "ethtool strace"

${PN} expands to the recipe name, packagegroup-course-diagnostics here. The RDEPENDS:${PN} assignment attaches the required runtime dependencies to the output package with that name. DEPENDS expresses build-time recipe dependencies, so it would fail to express the installation requirement. RRECOMMENDS:${PN} expresses optional runtime recommendations that image policy can omit. Use RDEPENDS:${PN} when the group promises that the tools will be present.

Save the image recipe below as recipes-core/images/course-diagnostics-image.bb in the same layer. The require line includes the OpenEmbedded-Core minimal image recipe and its base package selection. The append adds the group without replacing that selection. This gives you a separate BitBake target while keeping the base image recipe in its original layer.

bitbake
require recipes-core/images/core-image-minimal.bb

SUMMARY = "Minimal image with course diagnostics"
IMAGE_INSTALL:append = " packagegroup-course-diagnostics"

Build the image from the initialized build environment. BitBake will schedule the work needed to produce the group and its member packages as dependencies of the image build.

bash
bitbake course-diagnostics-image
Package requests for the diagnostics imagecourse-diagnostics-imagepackagegroup-course-diagnosticsRequested via IMAGE_INSTALLethtoolRequired via RDEPENDSstraceRequired via RDEPENDScourse-diagnostics-imagepackagegroup-course-diagnosticsRequested via IMAGE_INSTALLethtoolRequired via RDEPENDSstraceRequired via RDEPENDS
The image requests one group package, which requires both diagnostics tools.

After a successful build, look under tmp/deploy/images/ in a standard build directory. Open the subdirectory for the selected machine and locate the .manifest for course-diagnostics-image. Use the manifest from the completed build if several builds are present. To check the relevant entries, run the following from the manifest's directory, replacing IMAGE.manifest with its actual filename. The regular expression matches a package name followed by whitespace at the start of a line, so entries such as strace-dbg do not count as strace.

bash
grep -E '^(packagegroup-course-diagnostics|ethtool|strace)[[:space:]]' IMAGE.manifest

The manifest name follows IMAGE_NAME: a real bitbake -e course-diagnostics-image run on Poky scarthgap, with the machine course-qemu from the previous lesson, printed IMAGE_NAME="course-diagnostics-image-course-qemu.rootfs-20261202161010" (the number is a build timestamp) and IMAGE_LINK_NAME="course-diagnostics-image-course-qemu.rootfs", so look for a file such as course-diagnostics-image-<machine>.rootfs.manifest or its timestamped twin. The same run, with the recipes of this section in a layer, printed IMAGE_INSTALL="packagegroup-core-boot packagegroup-course-diagnostics" (the group was added after the one from core-image-minimal) and IMAGE_FEATURES="debug-tweaks", which the Poky local.conf template adds through EXTRA_IMAGE_FEATURES. bitbake-layers show-recipes found ethtool and strace (both version 6.7) in the meta layer, so OpenEmbedded-Core supplies them. The image itself was not built in this review (a full image build was out of scope), so the manifest content is not shown. Look for one entry for each of the three names. A match for the group alone would be insufficient evidence that both tools were included. If BitBake reports that it cannot find the image target, check whether the layer is enabled and its recipe paths are covered by its recipe file patterns. If the image is found but a required package cannot be supplied, check the package name in RDEPENDS:${PN} and whether an enabled recipe produces that package for your build.

Before moving on, consider where you would make a change if a second image needed the same tools. Both image recipes can request packagegroup-course-diagnostics, and a change to the required tool set then belongs in the group recipe. If the second image also needs SSH access, its image recipe can request that feature independently.

The next lesson, Image types and wic layouts, explains how Yocto turns the selected filesystem contents into image files and arranges them for deployment.

Key takeaways

  • An image recipe defines a build target and requests the packages and features for its root filesystem.
  • IMAGE_INSTALL contains runtime package names, and required dependencies can add more packages.
  • IMAGE_FEATURES selects named image capabilities that can add packages or change image configuration.
  • A packagegroup recipe gives a reusable set of runtime dependencies a package name.
Reflect
  1. Explain to a colleague, in two sentences: explain how IMAGE_INSTALL and IMAGE_FEATURES contribute to a Yocto image.
  2. Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
  3. What surprised you when you ran the commands yourself?
On a real board

Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.

References and further reading

Find your next step

↑ ↓ to move · Enter to open · Esc to close