Skip to content

Conversation

@ChengyuZhu6
Copy link
Member

@ChengyuZhu6 ChengyuZhu6 commented Nov 21, 2025

Add EROFS conversion support to ctr convert command with configurable options for mkfs parameters.

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

Depends-on: #12567

@ChengyuZhu6
Copy link
Member Author

cc @hsiangkao

@dmcgowan dmcgowan moved this from Needs Triage to Needs Reviewers in Pull Request Review Nov 22, 2025
@dmcgowan dmcgowan added this to the 2.3 milestone Nov 22, 2025
@hsiangkao
Copy link
Member

hsiangkao commented Nov 22, 2025

I think the main consideration here is still how to represent mediatype, which is similar to another PR: #12506.

-- We could use some non-OCI mediatypes if containerd allows them, much like the old application/vnd.docker. prefix layers.
I don't think OCI will standardize it immediately because it's just a chicken-and-egg problem: the reason is that after Docker images became popular, people could see it was useful to standardize in another way without docker tag.

Although there is already a PR related to this, I don't think EROFS's near-term roadmap has to be tied to OCI mediatypes, and I don't want to speak of SquashFS because whether EROFS succeeds or not in this area shouldn't be involved with other unrelated stuff (It took me a lot of time to develop several kernel features [file-backed mounts, fsmerge, external devices, etc.] in order to make EROFS suitable for both container/VM workloads).

@hsiangkao
Copy link
Member

I think the main consideration here is still how to represent mediatype, which is similar to another PR: #12506.

-- We could use some non-OCI mediatypes if containerd allows them, much like the old application/vnd.docker. prefix layers. I don't think OCI will standardize it immediately because it's just a chicken-and-egg problem: the reason is that after Docker images became popular, people could see it was useful to standardize in another way without docker tag.

Although there is already a PR related to this, I don't think EROFS's near-term roadmap has to be tied to OCI mediatypes, and I don't want to speak of SquashFS because whether EROFS succeeds or not in this area shouldn't be involved with other unrelated stuff.

Cc @dmcgowan. I think after EROFS native images become successful, it will be more convincing to standardize them in OCI or other organizations, rather than just having endless theoretical discussions in meetings.
(Also there are already non-OCI mediatypes already such as MediaTypeContainerd1Checkpoint, etc. in core/images/mediatypes.go)

@ChengyuZhu6
Copy link
Member Author

I have created a PR to define the erofs media type: #12567

}
log.G(ctx).Debugf("converted %s to EROFS using tar index mode", desc.Digest)
} else {
if err := erofsutils.ConvertTarErofs(ctx, sr, blobPath, "", convertOpts.mkfsExtraOpts); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to use erofs applier directly instead of calling erofsutils.ConvertTarErofs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Reusing erofsDiff.Apply is inconvenient:

  1. It forces output to layer.erofs inside a mount-resolved directory. Since the converter works with temp files/streams, we'd have to hack together a fake mount.Mount object just to make it work.
  2. It pulls in content.Store, which isn't strictly necessary for just converting streams.

Copy link
Member

@hsiangkao hsiangkao Jan 9, 2026

Choose a reason for hiding this comment

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

My real concern is that we should apply the differ's mkfs_options by default (unless users use an additional convertOpts.mkfsExtraOpts to overlap), and we should use the same UUID calculation: u := uuid.NewSHA1(uuid.NameSpaceURL, []byte("erofs:blobs/"+desc.Digest))

Copy link
Member

Choose a reason for hiding this comment

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

I think at least you'd better to align the UUID calculation, I'm fine with no differ tangle.

@ChengyuZhu6 ChengyuZhu6 force-pushed the ctr-erofs branch 3 times, most recently from b2ebabd to 95e8258 Compare January 9, 2026 07:28
@ChengyuZhu6 ChengyuZhu6 force-pushed the ctr-erofs branch 2 times, most recently from 428e32c to e6b6784 Compare January 9, 2026 08:00
@hsiangkao
Copy link
Member

ctr image convert --erofs --erofs-compression='lzma:lz4hc,12' src:tag dst:tag is not a good example

since there is no compress-hint files, I think you could just leave:
ctr image convert --erofs --erofs-compression='lz4hc,12' src:tag dst:tag

as an example.

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 <[email protected]>
},
&cli.StringFlag{
Name: "erofs-mkfs-opts",
Usage: "Extra options for mkfs.erofs (e.g., '-zlz4')",
Copy link
Member

Choose a reason for hiding this comment

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

erofs-mkfs-options: Extra mkfs options applied when converting EROFS layers. (e.g. '-Efragments,dedupe')

},
&cli.StringFlag{
Name: "erofs-compression",
Usage: "Compression algorithms for EROFS, separated by colon (e.g., 'lz4:lz4hc,12')",
Copy link
Member

Choose a reason for hiding this comment

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

just Specify compression algorithm list when converting EROFS layers,
no need to give an example since compress-hint file is unsupported for now.

e.g., 'ctr convert --uncompress --oci example.com/foo:orig example.com/foo:converted'
'ctr convert --erofs example.com/foo:orig example.com/foo:erofs'
'ctr convert --erofs --erofs-compression='lzma:lz4hc,12' example.com/foo:orig example.com/foo:erofs'
Copy link
Member

Choose a reason for hiding this comment

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

ctr convert --erofs --erofs-compression='lz4hc,12' example.com/foo:orig example.com/foo:erofs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/distribution Image Distribution size/L

Projects

Status: Needs Reviewers

Development

Successfully merging this pull request may close these issues.

4 participants