{"record":{"id":"10933319185504eb","repo":"lima-vm/lima","slug":"reading-volume-omap-w","errorCode":null,"errorMessage":"reading volume omap: %w","messagePattern":"reading volume omap: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/apfs/chown.go","lineNumber":278,"sourceCode":"\t\tif err != nil {\n\t\t\tcontinue // skip volumes we can't resolve\n\t\t}\n\t\tvolBlock, err := c.readBlock(volPhysAddr)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif verifyChecksum(volBlock) != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif le.Uint32(volBlock[apfsMagicOff:]) != apfsMagic {\n\t\t\tcontinue\n\t\t}\n\t\tvolRole := le.Uint16(volBlock[apfsRoleOff:])\n\t\tif volRole == role {\n\t\t\tomapAddr := le.Uint64(volBlock[apfsOmapOIDOff:])\n\t\t\tomapBlock, err := c.readBlock(omapAddr)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"reading volume omap: %w\", err)\n\t\t\t}\n\t\t\treturn &volumeInfo{\n\t\t\t\tomapTreeAddr: le.Uint64(omapBlock[omapTreeOIDOff:]),\n\t\t\t\trootTreeOID:  le.Uint64(volBlock[apfsRootTreeOIDOff:]),\n\t\t\t\tlatestXID:    le.Uint64(volBlock[objXIDOff:]),\n\t\t\t}, nil\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"no volume with role %#x found\", role)\n}\n\n// omapLookup searches the omap B-tree for a virtual OID, returning\n// the physical address from the entry with the highest xid <= maxXID.\nfunc (c *container) omapLookup(omapTreeAddr, oid, maxXID uint64) (uint64, error) {\n\tblk, err := c.readBlock(omapTreeAddr)\n\tif err != nil {\n\t\treturn 0, err\n\t}","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/apfs/chown.go#L260-L296","documentation":"Once findVolume locates the volume superblock matching the requested role, it reads that volume's omap block (physical address from apfsOmapOIDOff) to obtain the omap B-tree root address. This error wraps the readBlock failure for that block. It indicates the volume superblock was found but its omap could not be read.","triggerScenarios":"The volume's omap physical address is out of range for the image file, the image is truncated, or an I/O error (bad sector, permission) occurs while reading that specific block.","commonSituations":"Incomplete disk image copies, corrupted volumes inside an otherwise readable container, or images where the target volume was deleted and its omap blocks were reused/trimmed.","solutions":["Check the image is complete (size matches the source disk capacity).","Try a different volumeRole if the wrong volume was targeted and its storage was trimmed.","Run fsck_apfs against the image from a macOS host to repair volume metadata.","Re-take the disk image from a cleanly shut-down VM.","Restore the image from backup if corruption is confirmed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := apfs.Chown(diskPath, role, uid, gid, paths...); err != nil {\n\tif strings.Contains(err.Error(), \"reading volume omap\") {\n\t\tlog.Warn(\"target volume omap unreadable; image may be truncated or volume removed\")\n\t\treturn err\n\t}\n\treturn err\n}","preventionTips":["Take images from cleanly shut-down VMs.","Do not delete or wipe the target volume before running Chown.","Verify the image file is complete (size and checksum).","Repair with fsck_apfs before programmatic edits."],"tags":["apfs","disk-image","corruption"],"backgroundTag":"apfs-metadata-read-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}