{"record":{"id":"68f7776cc6ca1e7b","repo":"lima-vm/lima","slug":"failed-to-create-disk-attachment-for-extra-disk","errorCode":null,"errorMessage":"failed to create disk attachment for extra disk %#q: %w","messagePattern":"failed to create disk attachment for extra disk %#q: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driver/vz/vm_darwin.go","lineNumber":604,"sourceCode":"\t\tdisk, err := store.InspectDisk(diskName, d.FSType)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to run load disk %#q: %w\", diskName, err)\n\t\t}\n\n\t\tlogrus.Infof(\"Mounting disk %#q on %#q\", diskName, disk.MountPoint)\n\t\tif err = disk.LockForInstance(inst.Dir); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to attach disk %#q: %w\", diskName, err)\n\t\t}\n\t\textraDiskPath := filepath.Join(disk.Dir, filenames.DataDisk)\n\t\t// ConvertToRaw is a NOP if no conversion is needed\n\t\tlogrus.Debugf(\"Converting extra disk %#q to a raw disk (if it is not a raw)\", extraDiskPath)\n\n\t\tif err = diskUtil.Convert(ctx, raw.Type, extraDiskPath, extraDiskPath, nil, true); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to convert extra disk %#q to a raw disk: %w\", extraDiskPath, err)\n\t\t}\n\t\textraDiskPathAttachment, err := vz.NewDiskImageStorageDeviceAttachmentWithCacheAndSync(extraDiskPath, false, diskImageCachingMode, vz.DiskImageSynchronizationModeFsync)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create disk attachment for extra disk %#q: %w\", extraDiskPath, err)\n\t\t}\n\t\textraDisk, err := vz.NewVirtioBlockDeviceConfiguration(extraDiskPathAttachment)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create new virtio block device config for extra disk %#q: %w\", extraDiskPath, err)\n\t\t}\n\t\tconfigurations = append(configurations, extraDisk)\n\t}\n\n\tif err := validateDiskFormat(ciDataPath); err != nil {\n\t\treturn err\n\t}\n\tciDataAttachment, err := vz.NewDiskImageStorageDeviceAttachment(ciDataPath, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\tciData, err := vz.NewVirtioBlockDeviceConfiguration(ciDataAttachment)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":586,"sourceCodeEnd":622,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/vz/vm_darwin.go#L586-L622","documentation":"After conversion, Lima creates a VZ disk attachment with vz.NewDiskImageStorageDeviceAttachmentWithCacheAndSync (read-only=false, fsync sync mode); if the Virtualization framework rejects the attachment (unusable image, unsupported caching mode, path problems), the error is wrapped here.","triggerScenarios":"vz.NewDiskImageStorageDeviceAttachmentWithCacheAndSync(extraDiskPath, false, diskImageCachingMode, DiskImageSynchronizationModeFsync) fails — e.g. the raw image has a size/alignment the framework rejects, the file is unreadable, or the caching mode is invalid on this macOS version.","commonSituations":"Running on a macOS version where the chosen diskImageCachingMode is unsupported; disk file permissions block the VM process; zero-size or sparse-weird raw image.","solutions":["Verify the raw image is valid and readable (`file`, `qemu-img check`), and resize if 0 bytes","Update macOS/Lima so the disk image caching mode is supported; avoid custom cache-mode overrides","Recreate the disk and reattach"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"st, err := os.Stat(extraDiskPath)\nif err != nil || st.Size() == 0 {\n    return fmt.Errorf(\"extra disk %s is missing or empty\", extraDiskPath)\n}","typeGuard":null,"tryCatchPattern":"if err := startInstance(cfg); err != nil {\n    if strings.Contains(err.Error(), \"failed to create disk attachment\") {\n        // validate image, update macOS, or recreate the disk\n    }\n}","preventionTips":["Keep macOS and Lima current for caching-mode compatibility","Verify raw images (`qemu-img check`) before attach","Avoid hand-editing disk cache settings"],"tags":["vz-driver","disk-attachment","virtualization-framework"],"backgroundTag":"disk-attachment-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}