19 Commits

Author SHA1 Message Date
Maksym Pavlenko
82a47efe92 Support dmverity
Add a --dmverity flag to `ctr images build-erofs-cache`. When set, each cached
erofs blob is dm-verity formatted (the hash tree is appended in place) and a
.dmverity sidecar is written alongside it. This is required when the erofs
snapshotter runs with dmverity_mode=on, which rejects cache hits that lack a
sidecar; without it such layers would have to be formatted out-of-band.

Extract the differ's dm-verity formatting into a shared dmverity.FormatLayer so
the differ and the cache builder share one implementation; the differ's
formatDmverityLayer now delegates to it.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-07-21 10:07:08 -07:00
ChengyuZhu6
b320d3c855 ctr: add EROFS image conversion support
Add EROFS conversion support to ctr convert command with configurable
options for tar-index mode and mkfs parameters.

Usage:
  ctr image convert --erofs src:tag dst:tag
  ctr image convert --erofs --erofs-compression='lz4hc,12' src:tag dst:tag

Signed-off-by: ChengyuZhu6 <hudson@cyzhu.com>
2026-04-15 10:28:47 +08:00
Gao Xiang
b9445fb9ef erofs-differ: support zstd-wrapped EROFS layers
Although EROFS has native compression support (and each filesystem can
contain multiple compression algorithms), in many cases, people only
consider using zstd compression when transporting on the wire in order
to reduce the pulling time but maintain the optimal runtime performance.

Only `+zstd` is considered: it has skippable frames which will be used
for the seekable EROFS implementation in future containerd versions.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2026-04-13 01:38:45 +08:00
Gao Xiang
cb93966b9f transfer: Default to the EROFS snapshotter and differ for EROFS images
If no snapshotter is specified and `os.features` contains "erofs",
unpacking should use the EROFS snapshotter and differ.

This enhances the usability of native EROFS container images.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2026-04-01 13:18:23 +08:00
Aadhar Agarwal
50f5461fb7 Add dmverity support to the erofs snapshotter using veritysetup-go
Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
2026-03-31 20:21:39 +00:00
Sebastiaan van Stijn
4b6cc97c4d plugins: modernize: any
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest
    modernize -any -fix ./...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-15 18:24:15 +01:00
Aadhar Agarwal
52a92e83f0 erofs-differ: use same UUID append style in tar index mode as tar conversion mode
Use the same approach for appending UUID arguments in GenerateTarIndexAndAppendTar
as done in ConvertTarErofs for consistency between the two modes.

Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
2026-01-14 05:29:13 +00:00
ChengyuZhu6
36f8999b94 images: add EROFS layer media type
Signed-off-by: ChengyuZhu6 <hudson@cyzhu.com>
2025-12-23 23:19:50 +08:00
Derek McGowan
01b4c8102b Update default erofs block size on macOS during erofs diff
Use the Linux default rather than the block size from the local macOS
system. The local macOS block size is not relevant as the erofs file
will not be mounted directly on macOS.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-11-17 16:34:28 -08:00
Derek McGowan
1adaf27c1e Update erofs to compile on Darwin
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-13 19:33:44 -07:00
Aadhar Agarwal
b641933cfa erofs snapshotter: Add tar index mode
Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>

Minor style updates to erofs.md and differ_linux.go

Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>

Add use case for tar index in erofs.md

Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
2025-07-08 21:44:49 +00:00
Gao Xiang
a0ed14fd48 erofs-differ: fix filesystem UUID for tar-converted layers
Derive filesystem UUIDs (`lsblk -o +UUID`) from the OCI layer digests
(although diffIDs are better in principle, but they're unavailable by
differs in advance) rather than generating a random one.  This allows
EROFS to uniquely identify each layer using the content-addressable
filesystem UUID.

It can also be used for reproducible builds. To achieve this, configure
`mkfs_options` with `-T0 --mkfs-time` (However, `--mkfs-time` requires
erofs-utils 1.8+; Otherwise, all inode timestamps will be reset w/o it):

``` toml
  [plugins."io.containerd.differ.v1.erofs"]
    mkfs_options = ["-T0 --mkfs-time"]
```

Fixes: c73c8e5d52 ("Introduce EROFS differ")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2025-07-02 08:25:50 +08:00
Gao Xiang
5f2200b2c7 erofs-differ: fix EROFS native image support
A dumb bug was just found after I worked out a usable native
converter [1], instead of relying on some prebuilt image..

[1] https://github.com/erofs/erofs-container-toolkit
Signed-off-by: Gao Xiang <xiang@kernel.org>
2025-05-14 07:31:56 +08:00
Maksym Pavlenko
d983c186f5 Merge pull request #11733 from erofs/erofs-layers
erofs-differ: support EROFS native image layers
2025-04-23 23:33:23 +00:00
Gao Xiang
2f9734fa59 erofs-differ: support EROFS native image layers
If the layer media type is expected as an EROFS native layer (ending
with `.erofs`), copy the content as the layer blob.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2025-04-24 00:26:37 +08:00
Derek McGowan
98eded24b8 Move erofsutils to internal
Avoid introducing utils package outside of internal. This package
should not be imported by other modules.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-22 09:03:49 -07:00
Gao Xiang
09f34d18b7 erofs-differ: implement fast differ with DiffDirChanges()
Unlike the walking differ, which implements a generic method to
accommodate all kinds of snapshotters, the EROFS differ is just
implemented for EROFS and EROFS snapshotter so it can utilize the
recent DiffDirChanges() [1] to avoid traversing the entire rootfs
directory in order to improve `nerdctl commit` performance.

Additionally, I think `baseDir` is unnecessary too (in principle,
only `upperdir` is useful for OCI format convention).  However,
addressing this requires more work, so left as is for now.

It's also useful to implement a customized Compare() method for
EROFS differ so that we can dump the native EROFS-formatted blob
to the content store later.

[1] https://github.com/containerd/continuity/pull/145
Signed-off-by: Gao Xiang <xiang@kernel.org>
2025-04-19 11:30:48 +08:00
Gao Xiang
2486d542a5 Introduce EROFS Snapshotter
It allows us to mount each EROFS blob layer (generated by the EROFS
differ) independently, or use the "unpacked" fs/ directories (if
some other differ is used.)

Currently, it's somewhat like the overlay snapshotter, but I tend
to separate the new EROFS logic into a self-contained component,
rather than keeping it tangled in the very beginning.

Existing users who use the overlay snapshotter won't be impacted
at all but they have a chance to use this new snapshotter to
leverage the EROFS filesystem.

Signed-off-by: cardy.tang <zuniorone@gmail.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2025-01-13 16:31:11 +08:00
Gao Xiang
c73c8e5d52 Introduce EROFS differ
The EROFS differ only applies to EROFS layers which are marked by
a special file `.erofslayer` generated by the EROFS snapshotter.

Why it's needed?  Since we'd like to parse []mount.Mount directly
without actual mounting and convert OCI layers into EROFS blobs,
`.erofslayer` gives a hint that the active snapshotter supports
the output blob generated by the EROFS differ.

I'd suggest it could be read together with the next commit.

Signed-off-by: cardy.tang <zuniorone@gmail.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2025-01-13 16:16:54 +08:00