Skip to content

[Bug]: Files larger than 128 GiB cannot be unpacked into an ext4 image #921

Open

Description

@dkovba

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

  1. Create an image with a single file above 128 GiB.
  2. Run:
bin/container image load --input large-image.tar

Current behavior

Error: 137439084544 exceeds max file size (128 GiB)

Expected behavior

No error, but only if unpacking wouldn't run out of disk space.

Environment

OS: macOS

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added theissue type on Sep 10, 2026
  2. siddh34 commented on Oct 12, 2026

    @siddh34
    Contributor

    Hi @dkovba I'm investigating this I post my investigation here before actually starting a pull request for this issue

    could you please assign this issue to me?

  3. siddh34 commented on Oct 19, 2026

    @siddh34
    Contributor

    @dkovba I investigated the issue

    Container flow

    https://github.com/apple/container/blob/31e3a98e471e7626ec646618a149cb82bd0d7634/Sources/ContainerCommands/Image/ImageLoad.swift#L109 calls image.unpack(platform: nil, ...) after the load finishes.

    https://github.com/apple/container/blob/31e3a98e471e7626ec646618a149cb82bd0d7634/Sources/Services/ContainerAPIService/Client/ClientImage.swift#L419 sends this over XPC

    https://github.com/apple/container/blob/31e3a98e471e7626ec646618a149cb82bd0d7634/Sources/Services/ContainerImagesService/Server/ImagesService.swift#L359 calls snapshotStore.unpack(...)

    https://github.com/apple/container/blob/31e3a98e471e7626ec646618a149cb82bd0d7634/Sources/Services/ContainerImagesService/Server/SnapshotStore.swift#L49 picks the unpacker. For Linux images it builds an EXT4Unpacker with a capacity of 512 GiB, or 512 MiB for the init image

    https://github.com/apple/container/blob/31e3a98e471e7626ec646618a149cb82bd0d7634/Sources/Services/ContainerImagesService/Server/SnapshotStore.swift#L125 calls unpacker.unpack(image, for: platform, ...)

    Containerization flow

    creates the EXT4.Formatter and goes through each layer.

    try await self.unpackEntries(reader: reader, progress: progress)
    calls unpackEntries.

    If we read unpackEntries it calls create of EXT4Formatter

    Create has limit of 128Gib see:

    Even if we uplift the max file size error limit from 128Gib it could only go upto 170Gib

    The real limit lies in writeExtends see:

    func writeExtents(_ inode: Inode, _ blocks: (start: UInt32, end: UInt32)) throws -> Inode {

    writes extents in writeExtents. With 4 KiB blocks

    • MaxBlocksPerExtent is 0x8000, so one extent covers 32768 × 4 KiB = 128 MiB.
    • writeExtents supports an inline root of 4 extents, or one extent-tree level with 4 index entries.
    • Each leaf block holds 340 extents, so the maximum is 4 × 340 = 1360 extents.
    • 1360 extents × 128 MiB is about 170 GiB, and MaxFileSize is set lower, at 128 GiB.

    A proper fix would be adding a depth-2 extent tree to writeExtents or we could uplift the current limit from 128.Gib upto max 170 Gib. Let me know how I should proceed with it

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions