lima-vm/lima · critical

reading container omap at %d: %w

Error message

reading container omap at %d: %w

What it means

findVolume read the container superblock, extracted the physical address of the container omap from nxOmapOIDOff, and then failed to read that block from the disk image with readBlock. The container omap is mandatory to resolve volume virtual OIDs to physical addresses, so the failure is fatal. The wrapped error carries the underlying I/O reason (EOF, permission, etc.).

Source

Thrown at pkg/apfs/chown.go:246

	}
	if bestBlock == nil {
		return nil, errors.New("no valid container superblock found in checkpoint area")
	}
	return bestBlock, nil
}

// findVolume locates the volume with the given role.
func (c *container) findVolume(role uint16) (*volumeInfo, error) {
	sb, err := c.latestSuperblock()
	if err != nil {
		return nil, fmt.Errorf("reading container superblock: %w", err)
	}

	// Read the container omap to resolve volume virtual OIDs.
	containerOmapAddr := le.Uint64(sb[nxOmapOIDOff:])
	containerOmap, err := c.readBlock(containerOmapAddr)
	if err != nil {
		return nil, fmt.Errorf("reading container omap at %d: %w", containerOmapAddr, err)
	}
	containerOmapTreeAddr := le.Uint64(containerOmap[omapTreeOIDOff:])

	containerXID := le.Uint64(sb[objXIDOff:])

	for i := range nxMaxFileSystems {
		off := nxFSOIDOff + i*8
		volOID := le.Uint64(sb[off:])
		if volOID == 0 {
			continue
		}
		// Resolve virtual OID through container omap.
		volPhysAddr, err := c.omapLookup(containerOmapTreeAddr, volOID, containerXID)
		if err != nil {
			continue // skip volumes we can't resolve
		}
		volBlock, err := c.readBlock(volPhysAddr)
		if err != nil {

View on GitHub (pinned to dd909d0973)

Solutions

  1. Check the image file size covers the omap address reported in the error; re-copy if truncated.
  2. Confirm you are opening the full container disk, not a single partition slice.
  3. Verify no other process has the image locked or mounted read-only in a way that blocks reads.
  4. Re-export the image from the hypervisor with a consistent snapshot.
  5. Run fsck_apfs on the image from a macOS host.
Defensive patterns

Strategy: validation

Validate before calling

info, err := os.Stat(diskPath)
if err != nil { return err }
if info.Size() < 64*1024*1024 { return errors.New("image too small to be an APFS container; likely truncated or wrong file") }

Try / catch

if err := apfs.Chown(diskPath, role, uid, gid, paths...); err != nil {
	if strings.Contains(err.Error(), "reading container omap at") {
		return fmt.Errorf("image %s appears truncated or corrupt at the omap block: %w", diskPath, err)
	}
	return err
}

Prevention

When it happens

Trigger: The omap physical address stored in the superblock points beyond the end of the image file, or the ReadAt fails due to I/O errors, truncated images, or a mismatched baseOffset when the image is partitioned.

Common situations: Truncated or partially copied disk images, images taken from a snapshot where the omap block is not yet flushed, or wrong disk image passed (e.g., an EFI or recovery partition image instead of the container).

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/8bb77c6e26c395e9. Report an issue: GitHub.