Skip to content

baseosmgr: check rootfs size, not whole image#6044

Draft
eriknordmark wants to merge 2 commits into
lf-edge:masterfrom
eriknordmark:baseosmgr-rootfs-partition-size
Draft

baseosmgr: check rootfs size, not whole image#6044
eriknordmark wants to merge 2 commits into
lf-edge:masterfrom
eriknordmark:baseosmgr-rootfs-partition-size

Conversation

@eriknordmark

@eriknordmark eriknordmark commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Description

doBaseOsActivate rejected a base-OS update whenever the content tree's total
download size exceeded the rootfs partition. But that total is not what lands in
the partition — only the rootfs (the disk-root layer) is written there. An image
may carry additional disks beyond the rootfs (for example the split-rootfs
Extension, which is extracted to /persist), so a perfectly valid image was
wrongly rejected with doBaseOsActivate: Image size <N> bytes greater than partition size <M> bytes.

The whole-image pre-activation check is removed and replaced by a check against
what is actually written. Just before writing the partition, zboot looks up the
size of the image's disk-root layer from its manifest and fails fast if that
exceeds the partition capacity. Because the rootfs is a squashfs stored as a raw
(uncompressed) layer, the manifest descriptor size equals the bytes written, so
the bound is exact. The check is image-shape agnostic — monolithic, multi-disk
and split-rootfs images alike — because it only ever measures the rootfs. If the
image has no disk-root layer (an unexpected manifest shape) the check is skipped
rather than blocking the install.

Reading the disk-root layer size needs the image's manifest, so this also adds a
GetImageLayers accessor to the CAS interface — manifest parsing stays in the
CAS layer rather than leaking go-containerregistry into zboot.

Note: this check runs on the EVE instance performing the activation, so the fix
takes effect for devices already running an EVE that contains it.

How to test and validate this PR

  • A normal upgrade between two regular EVE images still succeeds.
  • Activating an image whose rootfs is larger than the IMGA/IMGB partition now
    fails fast, before the multi-gigabyte pull and write, with
    rootfs does not fit: rootfs <N> bytes exceeds partition <part> size <M> bytes.
  • For a split-rootfs image (Core + Extension disk), activation no longer fails the
    size check even though the whole-image size exceeds the partition, because only
    the Core (disk-root) is measured.

Changelog notes

Fixes base-OS updates being wrongly rejected with an "image size greater than
partition size" error when the downloaded image is larger than the rootfs
partition but the root filesystem itself fits within it.

PR Backports

Draft — backporting to LTS branches at maintainer discretion.

🤖 Generated with Claude Code

@eriknordmark eriknordmark force-pushed the baseosmgr-rootfs-partition-size branch from f2a6866 to 3b9f91d Compare June 12, 2026 22:00
@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 19.04762% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.13%. Comparing base (a68dfee) to head (4c38292).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
pkg/pillar/cas/containerd.go 0.00% 24 Missing ⚠️
pkg/pillar/zboot/zboot.go 44.44% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6044      +/-   ##
==========================================
+ Coverage   20.72%   21.13%   +0.40%     
==========================================
  Files         504      514      +10     
  Lines       92768    94492    +1724     
==========================================
+ Hits        19230    19970     +740     
- Misses      71916    72719     +803     
- Partials     1622     1803     +181     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eriknordmark eriknordmark force-pushed the baseosmgr-rootfs-partition-size branch from 3b9f91d to 2a2d346 Compare June 13, 2026 19:51
@eriknordmark eriknordmark force-pushed the baseosmgr-rootfs-partition-size branch 3 times, most recently from ef55013 to fb0f3ac Compare June 14, 2026 16:57
eriknordmark and others added 2 commits June 15, 2026 15:24
A caller that needs an image's layers — their sizes, media types and
annotations — should not reach into containerd or re-parse manifests
itself. Add GetImageLayers(reference), which resolves the reference to
its manifest (descending a platform index when needed) and returns the
layer descriptors, keeping OCI manifest parsing inside the cas package.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A base-OS update was rejected when the content tree's whole download
size exceeded the rootfs partition. That total is not what lands in the
partition: only the rootfs — the image's disk-root layer — is written
there, while a split-rootfs image also carries an Extension that is
extracted to /persist. A valid image was therefore wrongly rejected
with "Image size ... greater than partition size".

Drop that whole-image pre-activation check and instead, just before
writing, compare the disk-root layer size against the partition
capacity, failing fast with a clear error if it does not fit. The rootfs
is a squashfs stored as a raw (uncompressed) layer, so its manifest size
is exactly the bytes written. The layer size comes from the image
manifest via cas.GetImageLayers.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant