{"record":{"id":"0a2e575ac6487649","repo":"lima-vm/lima","slug":"failed-to-create-s-disk-in-q-w","errorCode":null,"errorMessage":"failed to create %s disk in %#q: %w","messagePattern":"failed to create (.+?) disk in %#q: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/disk.go","lineNumber":124,"sourceCode":"\t\treturn fmt.Errorf(\"disk %#q already exists (%#q)\", name, diskDir)\n\t}\n\n\tlogrus.Infof(\"Creating %s disk %#q with size %s\", format, name, units.BytesSize(float64(diskSize)))\n\n\tif err := os.MkdirAll(diskDir, 0o700); err != nil {\n\t\treturn err\n\t}\n\n\t// qemu may not be available, use it only if needed.\n\tdataDisk := filepath.Join(diskDir, filenames.DataDisk)\n\tdiskUtil := proxyimgutil.NewDiskUtil(ctx)\n\terr = diskUtil.CreateDisk(ctx, dataDisk, diskSize)\n\tif err != nil {\n\t\trerr := os.RemoveAll(diskDir)\n\t\tif rerr != nil {\n\t\t\terr = errors.Join(err, fmt.Errorf(\"failed to remove a directory %#q: %w\", diskDir, rerr))\n\t\t}\n\t\treturn fmt.Errorf(\"failed to create %s disk in %#q: %w\", format, diskDir, err)\n\t}\n\n\treturn nil\n}\n\nfunc newDiskListCommand() *cobra.Command {\n\tdiskListCommand := &cobra.Command{\n\t\tUse: \"list\",\n\t\tExample: `\nTo list existing disks:\n$ limactl disk list\n`,\n\t\tShort:   \"List existing Lima disks\",\n\t\tAliases: []string{\"ls\"},\n\t\tArgs:    WrapArgsError(cobra.ArbitraryArgs),\n\t\tRunE:    diskListAction,\n\t}\n\tdiskListCommand.Flags().Bool(\"json\", false, \"JSONify output\")","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/disk.go#L106-L142","documentation":"The underlying disk image creation failed. diskUtil.CreateDisk (which shells out to qemu-img via proxyimgutil) returned an error while creating the data disk inside the new disk directory; Lima wraps it with the format and directory, having already attempted (and joined, if it failed) directory cleanup.","triggerScenarios":"`limactl disk create` when qemu-img is unavailable/misbehaving: qemu-img not installed, unsupported size syntax, full disk, or qemu-img exiting nonzero on the target filesystem.","commonSituations":"Missing qemu-img in PATH on the host; specifying size like 10GB vs 10GiB issues; no space left on device; read-only or incompatible filesystem for qcow2.","solutions":["Install/verify qemu-img: qemu-img --version (part of qemu-utils)","Check free space on the filesystem holding ~/.lima/disks","Validate the --size value (e.g. 10GiB) and the --format (qcow2/raw)","Inspect the wrapped %w error for the exact qemu-img failure and fix accordingly"],"exampleFix":"// before\n$ limactl disk create data --size 10GiB\n// failed to create qcow2 disk in \"...\": exec: \"qemu-img\": executable file not found\n// after\n$ brew install qemu   # or apt install qemu-utils\n$ limactl disk create data --size 10GiB","handlingStrategy":"try-catch","validationCode":"const { execFileSync } = require('child_process')\ntry { execFileSync('qemu-img', ['--version']) } catch { throw new Error('qemu-img is required for limactl disk create') }","typeGuard":"function isCreateDiskErr(err: unknown): boolean {\n  return err instanceof Error && /failed to create .* disk/.test(err.message)\n}","tryCatchPattern":"try {\n  await createDisk(name, { size: '10GiB' })\n} catch (err) {\n  if (isCreateDiskErr(err)) {\n    console.error('Check qemu-img install, free space, and size syntax:', err.cause ?? err)\n  } else throw err\n}","preventionTips":["Install qemu-utils (apt) or qemu (brew) before using limactl disks","Check free disk space for the requested size","Use unit-suffixed sizes like 10GiB","Confirm the target filesystem supports sparse/qcow2 files"],"tags":["disk","qemu-img","creation"],"backgroundTag":"disk-create-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}