{"record":{"id":"411ffd3aed78b0cd","repo":"lima-vm/lima","slug":"failed-to-find-data-slice-in-attached-disk","errorCode":null,"errorMessage":"failed to find data slice in attached disk","messagePattern":"failed to find data slice in attached disk","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/guestpatch/macos/macos_darwin.go","lineNumber":58,"sourceCode":"// LaunchDaemon plist, init script, and setup markers via a noowners\n// mount, then fixes file ownership by patching APFS inode records\n// directly on the raw disk image. No sudo required.\nfunc Patch(ctx context.Context, disk string) error {\n\tif err := patchWriteGuestFiles(ctx, disk); err != nil {\n\t\treturn err\n\t}\n\treturn patchFixOwnership(ctx, disk)\n}\n\n// patchWriteGuestFiles attaches the disk image, mounts the Data\n// volume with noowners, writes guest files, then detaches.\nfunc patchWriteGuestFiles(ctx context.Context, disk string) error {\n\tattached, err := attachImageWithRetry(ctx, disk, 3)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to attach disk: %w\", err)\n\t}\n\tif attached == nil || attached.Data == \"\" {\n\t\treturn errors.New(\"failed to find data slice in attached disk\")\n\t}\n\tdataDevPath := \"/dev/\" + attached.Data\n\tdefer func() {\n\t\t// Detaching the data slice is enough to detach the whole ASIF.\n\t\tif err := asifutil.DetachASIF(dataDevPath); err != nil {\n\t\t\tlogrus.WithError(err).Warnf(\"failed to detach %#q (%#q)\", dataDevPath, disk)\n\t\t}\n\t}()\n\n\tinstDir := filepath.Dir(disk)\n\tmnt := filepath.Join(instDir, filenames.MntDir)\n\tif err := os.MkdirAll(mnt, 0o755); err != nil {\n\t\treturn fmt.Errorf(\"failed to create mount point %#q: %w\", mnt, err)\n\t}\n\tdefer func() {\n\t\tif err := os.Remove(mnt); err != nil {\n\t\t\tlogrus.WithError(err).Warnf(\"failed to remove mount point %#q\", mnt)\n\t\t}","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/guestpatch/macos/macos_darwin.go#L40-L76","documentation":"After attaching the disk image, patchWriteGuestFiles expects the attach result to expose a Data volume device. If the attach result is nil or its Data field is empty, the code cannot locate the data slice device path and returns this error instead of proceeding to mount.","triggerScenarios":"Patch -> patchWriteGuestFiles when attachImageWithRetry succeeds but returns no Data slice — e.g. an image without a data partition (cidata missing), a partial/legacy image layout, or the ASIF enumeration failing to map the data slice.","commonSituations":"Instance image created by an older Lima version without the expected data slice; disk image truncated or rebuilt without the cidata volume; macOS framework returning a result with no data volume mapping.","solutions":["Inspect the disk image's partition layout and confirm a data/cidata volume exists.","Recreate or repair the instance disk so it contains the expected data slice.","Upgrade/verify the attach code path returns the full slice mapping (all volumes).","Recreate the instance if its disk predates the current image format."],"exampleFix":"// before: attaching a legacy disk without a data slice\nattached, _ := attachImageWithRetry(ctx, disk, 3) // attached.Data == \"\"\n// after: validate image before patch\nif err := verifyDataSlicePresent(disk); err != nil {\n\treturn fmt.Errorf(\"disk %s has no data slice; recreate instance: %w\", disk, err)\n}","handlingStrategy":"validation","validationCode":"// check the attach result for a usable data slice before mounting\nif attached == nil || attached.Data == \"\" {\n\treturn fmt.Errorf(\"no data slice on %s; recreate the instance disk\", disk)\n}","typeGuard":null,"tryCatchPattern":"if err := patchWriteGuestFiles(ctx, disk); err != nil {\n\tif strings.Contains(err.Error(), \"failed to find data slice\") {\n\t\tlog.Errorf(\"disk %s lacks a data volume; recreate or upgrade the instance\", disk)\n\t\treturn errSkipPatch\n\t}\n\treturn err\n}","preventionTips":["Verify the image contains a cidata/data partition before patching.","Recreate instances whose disks use an obsolete image layout.","Assert the attach result includes all expected slices in tests.","Keep image-format migration steps in upgrade tooling."],"tags":["guestpatch","macos","disk","asif"],"backgroundTag":"missing-disk-data-slice","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}