Creating static deltas¶
OSTree downloads updates from a remote OSTree repository. OSTree repositories contain all the files that compose some version of an image. When you create and manage images with OSTree, you can also create static deltas. Static deltas are a collection of updates generated between two OSTree commits. Static deltas optimize updates by fetching only objects from the new commit that do not already exist in the image. If a static delta is available for a specific transaction, OSTree will automatically use it.
Prerequisites
- Two or more OSTree-based images, such as the versions you created in Creating an OSTree-based image and Updating OSTree-based images
Procedure
-
Run
ostree log
to get the commit IDs of the available versions:$ ostree log --repo=ostree-repo cs9/x86_64/<repo> commit 81edee454fec85e3973539a3ce3e343615e07f88238ceb42754151e93f6f6e70 Parent: dfc718b4b44d26a607032b0a76066bb844a12b00659770a63ab42179d0c91682 ContentChecksum: 8c97f932600f97058e9a8e8f225b72a87e03eebf3f4c909eada96475b49a3f71 Date: 2024-11-04 18:18:09 +0000 Version: 1.1 (no subject) commit dfc718b4b44d26a607032b0a76066bb844a12b00659770a63ab42179d0c91682 ContentChecksum: fdee7dd3d3fbbeada8ccd6941a81a58a96f8b53f38e31721ea659d703ee82671 Date: 2024-11-04 17:38:04 +0000 Version: 1 (no subject)
There are two commits. Version 1.1, the most recent commit, has the ID
81edee45
. Its parent commit,dfc718b4
, matches the commit ID for Version 1. -
Generate a static delta using the following syntax:
Where the
REV
values are the commit IDs of the versions for which you want to create a static delta. You can use a partial commit ID, for example:
Making offline updates¶
When you use a static delta to make offline updates, you deliver updates to the target system and apply them manually. A static delta is a single file, which makes the offline updates easy and efficient. Offline updates are useful in systems with preexisting update mechanisms, because a networked OSTree repository is not required.
Procedure
-
Update your image. In the example, the
build
command passes the--define
variable to add extra RPMs and change thedistro_version
: -
Generate static deltas and store them in a target directory:
Use the
generate-deltas
script in thetools/
directory to generate update files. When you run the script against an OSTree repository, it generates update files that contain per-commit deltas for each of the last three image parent commits and a larger update file that contains the full delta for all changes applied to the image between the latestHEAD
commit and up to three prior parent commits. -
Display the disk usage of the files in the
updates
directory:$ du -h ostree-repo/updates/* 9.9M ostree-repo/updates/cs9-x86_64-qemu-developer-0eb6b68144e8a66a6e324b2dcc9597a2c6da3733ab7e4ed55ae559b41904fd65-410b97c4ca59df58f33fce3d1e389a3eb8f7c1367c1afacb7c8842576d8daeed.update 571M ostree-repo/updates/cs9-x86_64-qemu-developer-410b97c4ca59df58f33fce3d1e389a3eb8f7c1367c1afacb7c8842576d8daeed.update 9.9M ostree-repo/updates/cs9-x86_64-qemu-developer-f56f6573b5f5d2a1bf990c9030ee8fefcdd35c6fd5db106e4e7236806483e6d2-410b97c4ca59df58f33fce3d1e389a3eb8f7c1367c1afacb7c8842576d8daeed.update
Notice the three delta updates:
Notice the size of the three delta update files:
- The 9.9M delta file,
cs9-x86_64-qemu-developer-0eb6b681<...>-410b97c4<...>.update
, contains the deltas to update a system running commit0eb6b681
to commit410b97c4
. - At 571M,
cs9-x86_64-qemu-developer-410b97c4<...>.update
is the largest update file and contains the delta between the first and last commits in the repository. - Another 9.9M delta update file,
cs9-x86_64-qemu-developer-f56f6573<...>-410b97c4c<...>.update
contains the deltas to update a system running commitf56f6573
to commit410b97c4
.
- The 9.9M delta file,
-
Run the image:
-
After the image boots, log in as
root
using the passwordpassword
. -
From the VM, run
rpm-ostree status
to get the metadata of the delta update that you want to install. -
Download the delta update:
For example:
-
Install the delta update by using
ostree static-delta apply-offline
:# ostree static-delta apply-offline cs9-x86_64-qemu-developer-f56f6573b5f5d2a1bf990c9030ee8fefcdd35c6fd5db106e4e7236806483e6d2-410b97c4ca59df58f33fce3d1e389a3eb8f7c1367c1afacb7c8842576d8daeed.update # rpm-ostree rebase 410b97c4ca59df58f33fce3d1e389a3eb8f7c1367c1afacb7c8842576d8daeed Staging deployment... done Changes queued for next boot. Run "systemctl reboot" to start a reboot # rpm-ostree status State: idle Deployments: auto-sig:410b97c4ca59df58f33fce3d1e389a3eb8f7c1367c1afacb7c8842576d8daeed Version: 1.2 (2024-11-11T22:21:43Z) Commit: 410b97c4ca59df58f33fce3d1e389a3eb8f7c1367c1afacb7c8842576d8daeed ● auto-sig:cs9/x86_64/qemu-developer Version: 1.1 (2024-11-11T21:51:37Z) Commit: f56f6573b5f5d2a1bf990c9030ee8fefcdd35c6fd5db106e4e7236806483e6d2 auto-sig:cs9/x86_64/qemu-developer Version: 1 (2024-11-11T21:38:47Z) Commit: 0eb6b68144e8a66a6e324b2dcc9597a2c6da3733ab7e4ed55ae559b41904fd65
The
rpm-ostree status
command is optional, but it is used here to show that the system has multiple versions of the image. Therpm-ostree rebase
command configures the system to reboot to the next version (Version 1.2, commit410b97c4ca59df58f33f
). If you unintentionally install the wrong delta, you will receive an error similar to,Commit XYZ, which is the delta source, is not in repository
. If this occurs, repeat this step using the correct delta. -
Reboot the VM:
-
After the image boots, log in as
root
using the passwordpassword
. -
From the VM, run
rpm-ostree status
to confirm that you successfully installed the update:# rpm-ostree status State: idle Deployments: ● auto-sig:410b97c4ca59df58f33fce3d1e389a3eb8f7c1367c1afacb7c8842576d8daeed Version: 1.2 (2024-11-11T22:21:43Z) Commit: 410b97c4ca59df58f33fce3d1e389a3eb8f7c1367c1afacb7c8842576d8daeed auto-sig:cs9/x86_64/qemu-developer Version: 1.1 (2024-11-11T21:51:37Z) Commit: f56f6573b5f5d2a1bf990c9030ee8fefcdd35c6fd5db106e4e7236806483e6d2