{"record":{"id":"6305e80da718ea0e","repo":"lima-vm/lima","slug":"failed-to-create-disk-q-w","errorCode":null,"errorMessage":"failed to create disk %#q: %w","messagePattern":"failed to create disk %#q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driverutil/disk.go","lineNumber":96,"sourceCode":"\tif isISO {\n\t\tisoPath := filepath.Join(instDir, filenames.ISO)\n\t\tif err := os.Rename(imagePath, isoPath); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tf, err := os.Create(diskPath)\n\t\tif err != nil {\n\t\t\t_ = os.Rename(isoPath, imagePath)\n\t\t\treturn err\n\t\t}\n\t\tif err := f.Close(); err != nil {\n\t\t\tos.Remove(diskPath)\n\t\t\t_ = os.Rename(isoPath, imagePath)\n\t\t\treturn err\n\t\t}\n\t\tif err := diskUtil.Convert(ctx, diskImageFormat, diskPath, diskPath, &diskSizeInBytes, false); err != nil {\n\t\t\tos.Remove(diskPath)\n\t\t\t_ = os.Rename(isoPath, imagePath)\n\t\t\treturn fmt.Errorf(\"failed to create disk %#q: %w\", diskPath, err)\n\t\t}\n\t} else {\n\t\tformat, err := nativeimgutil.DetectFormat(imagePath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Resize handled by prepareDisk() after CreateDisk()\n\t\tif format == string(diskImageFormat) {\n\t\t\tif err = os.Rename(imagePath, diskPath); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to rename %#q to %#q: %w\", imagePath, diskPath, err)\n\t\t\t}\n\t\t\tif err := os.Chmod(diskPath, 0o644); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to chmod %#q: %w\", diskPath, err)\n\t\t\t}\n\t\t} else {\n\t\t\tif err := diskUtil.Convert(ctx, diskImageFormat, imagePath, diskPath, &diskSizeInBytes, false); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to convert %#q to %#q: %w\", imagePath, diskPath, err)","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driverutil/disk.go#L78-L114","documentation":"EnsureDisk creates the instance's data disk by converting the base image to a qcow2 of the requested size. When diskUtil.Convert fails, the partially created disk is removed, the ISO/image is restored, and this wrapped error is returned. It surfaces the underlying conversion-tool failure (usually qemu-img).","triggerScenarios":"EnsureDisk (called by CreateDisk) has an ISO base image, converts iso->disk via diskUtil.Convert with the requested disk size, and Convert returns an error (bad ISO, unsupported format, qemu-img missing, insufficient space, invalid size).","commonSituations":"qemu-img not installed or not on PATH; corrupted base image download; disk size smaller than the image; out-of-disk-space on the host; permission issues in the instance dir.","solutions":["Read the wrapped cause; install/repair qemu-img (`qemu-img --version`) and ensure it is on PATH","Verify the base image integrity (checksum) and re-download if corrupt","Increase the instance's disk size or free space on the host volume","Retry instance creation after cleaning the partial files in the instance dir"],"exampleFix":"# before\n$ limactl create inst   # failed to create disk \"/home/u/.lima/inst/disk\": exit status 1\n# after\n$ which qemu-img || sudo apt install qemu-utils\n$ limactl delete -f inst && limactl create inst","handlingStrategy":"try-catch","validationCode":"func diskCreationPrecheck(imagePath string, diskSize int64) error {\n\tif _, err := exec.LookPath(\"qemu-img\"); err != nil {\n\t\treturn fmt.Errorf(\"qemu-img not installed: %w\", err)\n\t}\n\tfi, err := os.Stat(imagePath)\n\tif err != nil { return err }\n\tif diskSize < fi.Size() { return fmt.Errorf(\"disk size %d smaller than image %d\", diskSize, fi.Size()) }\n\treturn nil\n}","typeGuard":"func qemuImgAvailable() bool {\n\t_, err := exec.LookPath(\"qemu-img\")\n\treturn err == nil\n}","tryCatchPattern":"if err := driverutil.EnsureDisk(ctx, ...); err != nil {\n\tif strings.Contains(err.Error(), \"failed to create disk\") {\n\t\t// inspect wrapped cause: reinstall qemu-utils, verify image,\n\t\t// free space, then retry\n\t}\n\treturn err\n}","preventionTips":["Install qemu-utils and confirm qemu-img is on PATH","Verify base image checksums after download","Size the instance disk larger than the base image and keep free space on the host volume","Recreate the instance after a failed disk creation to clear partial files"],"tags":["disk","qemu-img","disk-creation","instance-storage"],"backgroundTag":"disk-image-conversion-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}