Building OSTree-based images¶
OSTree is a Git-like tool that maintains and updates immutable system images. When you manage images with OSTree, each image is tracked as a branch in a repository with a history of commits. OSTree branches are also called refs. The active OS that runs on a device is the live system. The live system is deployed from a specific commit from a specific branch.
When you update an image, OSTree pulls the latest commit from the remote branch and checks it out locally next to the commit deployed in the live system. The system is then restarted and it uses the new commit as the active OS. The prior deployment is still available and you can manually boot into it or perform a rollback to reactivate the older commit. You can also remove older OS versions to avoid unnecessary disk use.
AutoSD manifests support the ostree
image type. Building images based on the ostree
image type happens in two stages:
- An OSTree commit is created with all of the content required for the image.
- A bootable system is created by pulling and deploying the new OSTree commit.
Prerequisites
- Automotive Image Builder installed, see Introducing automotive-image-builder
- A manifest file, such as the manifest file that you created in Embedding RPM packages from local storage into the AutoSD image and extended in the other sections in this guide
Procedure
-
Build the image and include the
--ostree-repo
option to use OSTree to update an existing OSTree repo or create a new one. The--ostree-repo
option grants access to the intermediate OSTree commit:$ automotive-image-builder build --target qemu --mode image --ostree-repo <ostree-repo-name> \ --export qcow2 <path>/<my-manifest>.aib.yml <my-image>.qcow2
The example command builds the
<image-name>.qcow2
image and extracts the OSTree commits generated during the build. It also pulls the commits into the localostree-repo-name
directory. If a pre-existing ref exists in the repo, the commit ID of the existing ref becomes the parent commit of the new image to create an unbroken history of commits for your OSTree images. Also notice that theversion
equals1
; in a later procedure, you will increment this value to distinguish one build from another. -
List the OSTree repo reference name:
The command output produces a reference name that includes the distro, architecture, target, and manifest name used to build the image, for example:
-
Use the reference name to inspect the OSTree repo commit history:
For example:
-
Run the image:
-
After the image boots, log in as
root
using the passwordpassword
. -
From the image console, verify the status of the OSTree repo:
# rpm-ostree status State: idle Deployments: ● auto-sig:autosd9-sig/x86_64/qemu-ostree_upgrade Version: 1 (2025-05-06T18:11:26Z) Commit: 8be6158fa1862950d8751663728bdb82d1c7d537770b1f0fc9b8eba4939480ae
In this example, there is only one ref installed,
autosd9-sig/x86_64/qemu-ostree_upgrade Version 1
. The dot symbol (●) indicates the active commit. Notice that the remote from which the ref was installed isauto-sig
. For more information about the remote, run the following command:The default URL is
http://10.0.2.100/
. You can override the URL by changing theostree_repo_url
, but keeping the default URL is beneficial. The default URL is significant, because it matches the URL used by theautomotive-image-runner --publish-dir
command. Keeping the default URL enables the VM that contains your image to receive updates from theauto-sig
remote.