apko can emit image layers as EROFS filesystem images instead of the default gzip-compressed tar.
The format tracks erofs/erofs-image-spec; section numbers below refer to spec.md on main.
The spec is still in its draft phase — there is no tagged release, and it says media-type strings, annotation keys, and the binary chunk-index layout are subject to change until the first stable one.
So the media types, annotations, and layer layout used here may change too.
- Mount, don't unpack. A layer blob is a complete, kernel-mountable read-only filesystem.
You can
mount -t erofsthe layer directly and look at it, without extracting a tarball. - Random access. Container runtimes that consume EROFS images can seek into a layer rather than streaming the whole tar.
- Designed for sharing. The spec defines
overlay-lowerandoverlay-dataroles that compose via the kernel'soverlayfsexactly the way OCI tar layers do.
This document focuses on producing EROFS images and verifying they look legit using widely available tools.
To build and inspect EROFS images you need:
- apko built from a revision that contains EROFS support.
- The
erofs-utilspackage, which providesmkfs.erofs,fsck.erofs, anddump.erofs. apko ships a pure-Go writer (no CGO), somkfs.erofsis not required for producing images — butfsck.erofsanddump.erofsare the easiest way to inspect what apko produced. - To mount an EROFS layer: either the kernel
erofsmodule (present in modern Linux distros) plus root formount(8), or the unprivilegederofsfusebinary fromerofs-utils-fuse.
Install on Wolfi / Chainguard / Alpine:
sudo apk add erofs-utils # fsck.erofs, dump.erofs, mkfs.erofs
sudo apk add erofs-utils-fuse # erofsfuse (optional, for unprivileged mount)Install on Debian / Ubuntu:
sudo apt install erofs-utils # ships mkfs.erofs, fsck.erofs, dump.erofs, and erofsfuseThe simplest case: opt into EROFS via the --format=erofs flag or format: erofs in apko.yaml.
erofs-demo.yaml:
contents:
keyring:
- https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
repositories:
- https://packages.wolfi.dev/os
packages:
- wolfi-base
cmd: /bin/sh -l
archs:
- hostBuild into an OCI image layout directory:
mkdir -p out
apko build erofs-demo.yaml apko-erofs-demo:latest out/ --format=erofs --arch=hostThe OCI layout under out/ is a regular OCI image directory — the layer blob just happens to be an EROFS filesystem:
out/
├── blobs/sha256/
│ ├── <config-digest> # JSON image config
│ ├── <manifest-digest> # JSON image manifest
│ └── <layer-digest> # raw EROFS filesystem image
├── index.json
└── oci-layout
MANIFEST=$(jq -r '.manifests[0].digest | split(":")[1]' out/index.json)
jq . out/blobs/sha256/$MANIFESTExpected (excerpt):
{
"layers": [
{
"mediaType": "application/vnd.erofs",
"size": 16207872,
"digest": "sha256:8a2205cc..."
}
]
}The image config records erofs in os.features per spec §5.4, signalling to tools that don't implement the spec that they should not attempt to apply the layer as a tar:
CONFIG=$(jq -r '.config.digest | split(":")[1]' out/blobs/sha256/$MANIFEST)
jq '.["os.features"]' out/blobs/sha256/$CONFIG
# → ["erofs"]The layer blob is a complete EROFS filesystem. You can validate and inspect it without mounting anything.
LAYER=$(jq -r '.layers[0].digest | split(":")[1]' out/blobs/sha256/$MANIFEST)
file out/blobs/sha256/$LAYER
# → out/blobs/sha256/...: EROFS filesystem, blocksize=12, exslots=0, ...fsck.erofs -d3 out/blobs/sha256/$LAYER
# <I> erofs: No errors founddump.erofs out/blobs/sha256/$LAYER | head -15This prints the on-disk metadata: block size, inode count, build time, UUID, feature flags.
fsck.erofs --extract reads every inode and writes the resulting tree to a directory.
This is the strongest unprivileged validation you can run: if the image is malformed, extraction fails; if it succeeds, the file tree on disk is exactly what a kernel mount would expose.
mkdir extracted
fsck.erofs --extract=extracted --force out/blobs/sha256/$LAYER
ls extracted/
# bin dev etc home lib ...
cat extracted/etc/os-releaseFlag availability varies between erofs-utils releases — --xattrs, for instance, is not in the version Debian and Ubuntu ship — so check fsck.erofs --help on your machine before reaching for anything beyond the above.
For a quick tar tvf-style listing of any EROFS source (raw blob or OCI image directory), use apko erofs ls. It opens the EROFS blobs directly, walks the merged view in user space, and prints one line per entry — no mounts, no root or FUSE required, works on Linux/macOS/Windows.
Each line is mode, uid/gid, size, mtime and path; setuid/setgid/sticky show up in the mode string as ls -l renders them, devices print major,minor in place of a size, and directories print 0 as they do in tar tv.
apko erofs ls out/blobs/sha256/$LAYER | head
# lrwxrwxrwx 0/0 7 2026-04-17 19:17 bin -> usr/bin
# drwxr-xr-x 0/0 0 2026-04-17 19:17 dev
# crw-rw-rw- 0/0 1,3 2026-04-17 19:17 dev/null
# drwxrwxrwt 0/0 0 2026-04-17 19:17 tmp
# -rwsr-xr-x 0/0 178528 2026-04-17 19:17 usr/bin/sudo
# -rw-r--r-- 13/15 1183 2026-04-17 19:17 usr/share/man/whatis
# ...
apko erofs ls out/ # works against the whole OCI image tooFor multi-layer images, ls applies overlay semantics in user space. It uses the overlayfs-native deletion encoding the spec mandates (§3.6) — a whiteout is a character device with rdev 0, an opaque directory sets trusted.overlay.opaque="y" — not the .wh. filename convention of tar layers, which §8.1 forbids in EROFS images. A single-layer image is listed as-is: the kernel would mount it directly, applying no overlay semantics, so neither does ls.
The merge approximates what the kernel would assemble, and diverges in two corners (see #2408), both of which need two or more layers:
- A whiteout — or a plain file — at a directory's own name in a middle layer does not cut off lower layers when a higher layer recreates that directory.
lsshows the union of the recreated directory and the layers below the whiteout; the kernel shows only the recreated directory. - Opacity is not inherited by descendant directories. Marking
aopaque hides lower layers' children ofa, but not lower layers' children ofa/b; the kernel's cut covers the whole subtree.
apko erofs mount SOURCE DEST mounts a raw EROFS blob or an OCI image directory at DEST. It chooses between a kernel mount (root) and erofsfuse (unprivileged) based on the effective UID; use --mode=kernel|fuse|auto to force a choice. apko erofs umount DEST tears it back down.
The mount is read-only unless you pass --rw. Read-only is what inspecting an image wants, and it lets a single-layer image skip overlayfs entirely — the lone layer is mounted straight at DEST/merged. With --rw you get an overlayfs upperdir at DEST/upper; umount removes it only if nothing was written through the mount, and otherwise leaves it where it is and logs the path. A later --rw mount at the same DEST then refuses to start until you move or remove it, rather than quietly stacking two sessions' writes — possibly from different images — on top of each other.
mkdir -p /mnt/apko-erofs
apko erofs mount out/blobs/sha256/$LAYER /mnt/apko-erofs
ls /mnt/apko-erofs/
file /mnt/apko-erofs/bin/sh
apko erofs umount /mnt/apko-erofsIf the kernel mount mode complains "unknown filesystem type 'erofs'", the kernel module is missing on your system; install it (e.g. linux-modules-extra-$(uname -r) on Ubuntu) or pass --mode=fuse to use erofsfuse, which does not require root and works inside CI containers that lack the kernel module.
For an OCI source, umount works from DEST/.apko-erofs-mount.json, which mount wrote; a raw blob has no enclosing directory to hold one, so umount falls back to unmounting DEST itself. It only accepts mountpoints that a mount creates under DEST — DEST/merged and DEST/layers/NN — so a tampered file cannot name a path outside DEST. Because that is a check on the path string, a symlink at DEST/merged would otherwise redirect it anyway; kernel mode unmounts with umount(2) and UMOUNT_NOFOLLOW, which refuses that in the same syscall, with no window. A symlinked parent (DEST/layers itself) is caught by a separate check, and there the check and the unmount are two steps — so use a DEST only you can write to: anywhere else, another user can race them and choose what your umount takes down.
If a mountpoint is busy, umount stops there and rewrites the state file to list only what is still mounted, so rerunning it once the mount is free finishes the teardown.
A layer blob is a complete filesystem image, so mounting it needs no apko-specific tooling. For reference, apko erofs mount is equivalent to one of:
# Kernel (root):
sudo mount -t erofs -o ro out/blobs/sha256/$LAYER /mnt/apko-erofs
# ...later:
sudo umount /mnt/apko-erofs
# FUSE (unprivileged):
erofsfuse out/blobs/sha256/$LAYER /mnt/apko-erofs
# ...later:
fusermount3 -u /mnt/apko-erofs # or `fusermount -u`hack/test-erofs.sh runs everything above in one go — build, fsck.erofs, kernel mount, a comparison of apko erofs ls against the mounted tree, and a round trip through apko erofs mount and apko erofs umount (read-only, --rw, a raw blob, and a tampered state file) — and is what the EROFS CI workflow executes.
If you push the image with apko publish or crane push, the registry stores each blob unchanged — including the EROFS layer blob.
Most registry clients can extract layers by digest:
# Read the manifest and pull layer blobs.
crane manifest registry.example.com/apko-erofs-demo:latest > manifest.json
LAYER_DIGEST=$(jq -r '.layers[0].digest' manifest.json)
crane blob registry.example.com/apko-erofs-demo:latest@$LAYER_DIGEST > layer.erofs
file layer.erofs # EROFS filesystem...
fsck.erofs -d3 layer.erofs # <I> erofs: No errors foundOnce you have the blob on disk you can inspect or mount it exactly as in the previous sections.
Combine format: erofs with apko's layering configuration to get one EROFS layer per package group plus a top layer for unowned files.
erofs-layered.yaml:
contents:
keyring:
- https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
repositories:
- https://packages.wolfi.dev/os
packages:
- wolfi-base
cmd: /bin/sh -l
archs:
- host
layering:
strategy: origin
budget: 4
format: erofsmkdir -p out-layered
apko build erofs-layered.yaml apko-erofs-layered:latest out-layered/ --arch=hostInspect the manifest:
MANIFEST=$(jq -r '.manifests[0].digest | split(":")[1]' out-layered/index.json)
jq '.layers[] | {mediaType, role: .annotations["org.erofs.role"]}' out-layered/blobs/sha256/$MANIFESTExpected (last layer carries no role per spec §3.8 rule 1):
{ "mediaType": "application/vnd.erofs", "role": "overlay-lower" }
{ "mediaType": "application/vnd.erofs", "role": "overlay-lower" }
{ "mediaType": "application/vnd.erofs", "role": "overlay-lower" }
{ "mediaType": "application/vnd.erofs", "role": "overlay-lower" }
{ "mediaType": "application/vnd.erofs", "role": null }Each layer is independently mountable as an EROFS filesystem, and each carries its own partial usr/lib/apk/db/installed so per-layer scanners (Trivy, Snyk, Grype) can identify the packages it contributes.
The OCI spec composes layers with overlayfs-style semantics; for EROFS layers the composition is straightforward — mount each layer read-only, then stack them as lowerdirs:
# Pull each layer blob out of the OCI layout.
BLOBS=$(pwd)/out-layered/blobs/sha256
MANIFEST=$(jq -r '.manifests[0].digest | split(":")[1]' out-layered/index.json)
mkdir -p mnt/{merged,work,upper}
# Mount every layer; build the overlay lowerdir as we go. overlayfs lists
# lowerdirs top-down (highest priority first), while OCI orders layers
# bottom-up (index 0 is the base), so prepend each new layer.
LOWERS=
i=0
for d in $(jq -r '.layers[].digest | split(":")[1]' "$BLOBS/$MANIFEST"); do
mp=mnt/lower$(printf %02d $i)
mkdir -p "$mp"
sudo mount -t erofs -o ro "$BLOBS/$d" "$mp" 2>/dev/null || \
erofsfuse "$BLOBS/$d" "$mp"
LOWERS="$mp${LOWERS:+:$LOWERS}"
i=$((i+1))
done
sudo mount -t overlay overlay \
-o "lowerdir=$LOWERS,upperdir=mnt/upper,workdir=mnt/work" \
mnt/merged
ls mnt/merged/ # full rootfsClean up:
sudo umount mnt/merged
for d in mnt/lower*; do sudo umount "$d" 2>/dev/null || fusermount -u "$d"; doneProduction runtimes (containerd's erofs snapshotter, podman/CRI-O with the erofs-aware plugin, etc.) automate this assembly; the steps above are for verifying that an apko-built EROFS image really does compose into a valid rootfs.
If you're already building apko images programmatically (apko_build.New(ctx, fsys, opts...).BuildImage(...)), EROFS is just a configuration choice — set the layer format on your ImageConfiguration and apko handles the rest:
import (
apko_build "chainguard.dev/apko/pkg/build"
apko_types "chainguard.dev/apko/pkg/build/types"
)
imgConfig := apko_types.ImageConfiguration{
// ... your existing fields ...
Format: apko_types.LayerFormatErofs,
}
bc, err := apko_build.New(ctx, fsys, apko_build.WithImageConfiguration(imgConfig), ...)
if err != nil { /* ... */ }
if err := bc.BuildImage(ctx); err != nil { /* ... */ }
_, layer, err := bc.ImageLayoutToLayer(ctx)If you have a plain fs.FS and want an EROFS image, use go-erofs directly — apko doesn't expose its EROFS writer as a standalone library (and wrapping go-erofs wouldn't add meaningful value over its existing Writer.CopyFrom(fs.FS) API).
For inspection, apko does expose a focused leaf library — see chainguard.dev/apko/pkg/erofsmount — which provides Stack (layered fs.FS with overlay/whiteout semantics), OpenLayers (open an OCI EROFS image's blobs), ReadOCILayers (parse an OCI manifest with EROFS layers), and Mount/Unmount/Ls (the CLI subcommand helpers, Linux-only for mount/umount; Ls is cross-platform).
- No compression. apko emits raw
application/vnd.erofslayers only. The draft spec definesapplication/vnd.erofs+zstdbut neither apko's writer nor the underlying go-erofs library writes compressed images yet. - No dm-verity. The spec's verified-mount path (§3.5) is not produced.
- No chunk index. Lazy-loading runtimes (per spec §3.4) won't get an index; reads are sequential.
- No
overlay-dataordeviceroles. Onlyoverlay-lower(and unannotated final) layers are emitted. - Hardlinks are shared in single-layer builds. Names pointing at one inode in the source rootfs point at one inode in the image, so the data is stored once and
st_nlink/st_inoidentity survives. A link name binds to whatever sits at the target path in the image, which is whatlink(2)does when the same rootfs is replayed from a tar layer. A link whose target the writer cannot find under the Linkname it was handed — removed by apathsdirective, reached through a symlinked directory component, which its flat path lookup does not follow, or itself another link not yet written — is materialized as an independent copy instead, the materialize-or-fail choice spec §3.7 leaves to the producer. A layered build materializes every hardlink as a copy, in every layer. apko can only recognize a hardlink when the rootfs was assembled from unpacked apks; one read back off disk reports the two names as unrelated files, and each gets a copy. - Spec is draft. Media-type strings and annotation keys may change before the spec stabilizes. Treat any image built today as experimental.
If you need any of the above, please open an issue.
- erofs/erofs-image-spec
spec.md— the layer format spec apko tracks. - EROFS kernel documentation — on-disk format reference.
- Layering in apko — how the multi-layer strategy partitions packages into groups.