lima-vm/lima · error
failed to create %s disk in %#q: %w
Error message
failed to create %s disk in %#q: %w
What it means
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.
Source
Thrown at cmd/limactl/disk.go:124
return fmt.Errorf("disk %#q already exists (%#q)", name, diskDir)
}
logrus.Infof("Creating %s disk %#q with size %s", format, name, units.BytesSize(float64(diskSize)))
if err := os.MkdirAll(diskDir, 0o700); err != nil {
return err
}
// qemu may not be available, use it only if needed.
dataDisk := filepath.Join(diskDir, filenames.DataDisk)
diskUtil := proxyimgutil.NewDiskUtil(ctx)
err = diskUtil.CreateDisk(ctx, dataDisk, diskSize)
if err != nil {
rerr := os.RemoveAll(diskDir)
if rerr != nil {
err = errors.Join(err, fmt.Errorf("failed to remove a directory %#q: %w", diskDir, rerr))
}
return fmt.Errorf("failed to create %s disk in %#q: %w", format, diskDir, err)
}
return nil
}
func newDiskListCommand() *cobra.Command {
diskListCommand := &cobra.Command{
Use: "list",
Example: `
To list existing disks:
$ limactl disk list
`,
Short: "List existing Lima disks",
Aliases: []string{"ls"},
Args: WrapArgsError(cobra.ArbitraryArgs),
RunE: diskListAction,
}
diskListCommand.Flags().Bool("json", false, "JSONify output")View on GitHub (pinned to dd909d0973)
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
Example fix
// before $ limactl disk create data --size 10GiB // failed to create qcow2 disk in "...": exec: "qemu-img": executable file not found // after $ brew install qemu # or apt install qemu-utils $ limactl disk create data --size 10GiB
Defensive patterns
Strategy: try-catch
Validate before calling
const { execFileSync } = require('child_process')
try { execFileSync('qemu-img', ['--version']) } catch { throw new Error('qemu-img is required for limactl disk create') } Type guard
function isCreateDiskErr(err: unknown): boolean {
return err instanceof Error && /failed to create .* disk/.test(err.message)
} Try / catch
try {
await createDisk(name, { size: '10GiB' })
} catch (err) {
if (isCreateDiskErr(err)) {
console.error('Check qemu-img install, free space, and size syntax:', err.cause ?? err)
} else throw err
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- failed to create disk %#q: %w
- disk format %#q not supported, use `qcow2` or `raw` instead
- disk %#q already exists (%#q)
- failed to remove a directory %#q: %w
- cannot delete disk %#q in use by instance %#q
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/0a2e575ac6487649.
Report an issue: GitHub.