Skip to content

Erofs overlay patches - #3042

Merged
schaefi merged 2 commits into
OSInside:mainfrom
martinp26:erofs-overlay-patches
Aug 26, 2026
Merged

Erofs overlay patches#3042
schaefi merged 2 commits into
OSInside:mainfrom
martinp26:erofs-overlay-patches

Conversation

@martinp26

Copy link
Copy Markdown

disk: honor erofscompression and allow create options for the overlay read-only root fs

Issue#3038
Issue#3039

What

Two commits fixing/extending compression handling for the overlayroot
read-only filesystem:

  1. disk: honor erofscompression for overlay read-only root filesystem
    The overlay read-only fs can be squashfs or erofs
    (overlayroot_readonly_filesystem), but both overlay code paths in
    DiskBuilder hard-coded get_squashfscompression(), so
    erofscompression was ignored and an erofs overlay base was written
    uncompressed. Routes the read-only compression through a small helper
    (_get_root_readonly_compression) that returns get_erofscompression()
    for an erofs read-only type and get_squashfscompression() otherwise.
    Complements Add missing erofscompression validation #2648 (which fixed only the standalone erofs builder).

  2. disk: allow extra create options for the overlay read-only root fs
    Adds a new free-form overlayroot_readonly_createoptions attribute
    (whitespace-split, analogous to fscreateoptions) passed as
    create_options to both overlay read-only FileSystem builds. This
    lets a description request e.g.
    overlayroot_readonly_createoptions="-C 1048576" for a larger EROFS
    pcluster. Updates schema (rnc + rng), the generated xml_parse.py,
    XMLState.get_fs_readonly_create_option_list(), disk.py, docs and
    tests.

Why

Building an AL2023 overlayroot EROFS image, erofscompression had no
effect (uncompressed ~1.4 GB base). With these two changes the recipe can
use erofscompression="lz4hc,level=12" +
overlayroot_readonly_createoptions="-C 1048576" directly.

Testing

  • make check — flake8 clean (shell unchanged)
  • make testmypy kiwi clean; full unit suite passes at 100%
    coverage
    (new code covered; existing overlay test updated)
  • make docs — sphinx html builds, new attribute documented
  • schema regeneration verified: trang reproduces kiwi.rng
    byte-for-byte from the edited kiwi.rnc; the generated xml_parse.py
    additions match the generateDS output pattern

Assisted-by: Kiro:claude-opus-4.8

Martin Pohlack added 2 commits August 25, 2026 12:10
The read-only root filesystem of an overlayroot image can be either
squashfs or erofs, selected via overlayroot_readonly_filesystem. Both
overlay code paths in DiskBuilder (the read-only partition size
estimation and the actual root sync), however, hard-coded
get_squashfscompression() when constructing the FileSystem, so the
erofscompression attribute was silently ignored for an erofs overlay
root. As a consequence an erofs overlay base was always written
uncompressed regardless of erofscompression -- e.g. an Amazon Linux
2023 root grew to ~1.4G instead of a few hundred MB.

PR OSInside#2648 fixed the same class of bug (OSInside#2647) for the standalone erofs
filesystem builder, but the overlayroot disk-builder path was missed.

Route the read-only filesystem compression through a small helper
(_get_root_readonly_compression) that returns get_erofscompression()
for an erofs read-only type and get_squashfscompression() otherwise, so
both attributes are honored consistently. Since erofscompression is
free-form text this also allows requesting e.g. "lz4hc,level=12".

Refs: OSInside#2647, OSInside#2648

Assisted-by: Kiro:claude-opus-4.8
The tool that builds the overlay read-only root filesystem (mkfs.erofs
or mksquashfs) accepts options beyond the compressor that materially
affect image size -- most notably the erofs physical cluster size
(mkfs.erofs -C), which widens the compression window. There was no way
to pass such options from the image description: fscreateoptions targets
the read-write root filesystem, not the overlay read-only layer.

Add an overlayroot_readonly_createoptions attribute (free-form,
whitespace-split, mirroring fscreateoptions) and pass it as
create_options to both overlay read-only FileSystem builds. An image
description can then request e.g.
overlayroot_readonly_createoptions="-C 1048576" for a larger erofs
pcluster which, together with erofscompression="lz4hc,level=12" (see
previous commit), noticeably shrinks the read-only base without relying
on an external mkfs.erofs wrapper.

Updates the schema (rnc/rng), the generated xml_parse.py, a new
XMLState.get_fs_readonly_create_option_list() accessor, and a unit test.

Assisted-by: Kiro:claude-opus-4.8

@schaefi schaefi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks much for looking into this.

I don't think we need a new attribute to differentiate compression options for erofs between different image layouts. The schema already provides k.type.erofscompression.attribute. So it should be possible to utilize this in the same way as it was done for builder/live.py and builder/filesystem.py. Just add the missing part to builder/disk.py as you you did but without the need for a new attribute in the schema

Thoughts ?

@schaefi

schaefi commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

use erofscompression="lz4hc,level=12" + overlayroot_readonly_createoptions="-C 1048576" directly.

under which condition you would need to specify both for one image type ?

@schaefi

schaefi commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

From my perspective you only need to apply the code we have in the other builders

filesystem_custom_parameters.update( 
    {
        'compression':
            self.xml_state.build_type.get_squashfscompression()
    } if root_filesystem == 'squashfs' else {
        'compression':
            self.xml_state.build_type.get_erofscompression()
    }
)

to the builder/disk.py where we only have

custom_args={
    'compression':
        self.xml_state.build_type.get_squashfscompression()
}

at several places

@martinp26

Copy link
Copy Markdown
Author

use erofscompression="lz4hc,level=12" + overlayroot_readonly_createoptions="-C 1048576" directly.

under which condition you would need to specify both for one image type ?

mkfs.erofs carves out -C max-pcluster-size as a distinct setting from -z compression-algorithm[,#][:...] and there are potentially more options that one may want to pass to mkfs.*. fscreateoptions is used for the RW layer, overlayroot_readonly_createoptions would be the equivalent for the RO layer.

I am not seeing a way to express that with today's schema, am I missing it?

@schaefi

schaefi commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

@martinp26 ok, sorry I was on the wrong track. Yes makes perfect sense as we are using erofscompression specifically for compression settings and there is nothing that handles filesystem creation options for the read-only filesystem in an overlay build.

All good, sorry for the noise

@schaefi
schaefi self-requested a review August 26, 2026 09:52

@schaefi schaefi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@schaefi

schaefi commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

I will build Staging packages at

https://build.opensuse.org/project/show/Virtualization:Appliances:Staging

@schaefi
schaefi merged commit 3c24dd4 into OSInside:main Aug 26, 2026
12 checks passed
@martinp26

Copy link
Copy Markdown
Author

Thanks!

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.

2 participants