lima-vm/lima · error

failed to load disk %#q: %w

Error message

failed to load disk %#q: %w

What it means

When building the krunkit command line, each additional disk named in the instance config is looked up via store.InspectDisk. If that lookup fails (the disk does not exist in the Lima store, its metadata is corrupt, or its backing file is missing), Cmdline wraps the underlying error in `failed to load disk %#q: %w` and aborts instance start. This is a pre-boot validation failure inside Cmdline, called by Start.

Source

Thrown at pkg/driver/krunkit/krunkit_darwin_arm64.go:66

		// First virtio-blk device is the boot disk
		"--device", fmt.Sprintf("virtio-blk,path=%s,format=raw", filepath.Join(inst.Dir, filenames.Disk)),
		"--device", fmt.Sprintf("virtio-blk,path=%s", filepath.Join(inst.Dir, filenames.CIDataISO)),
		"--device", fmt.Sprintf("virtio-vsock,port=%d,socketURL=%s,connect", vSockPort, filepath.Join(inst.Dir, filenames.GuestAgentSock)),
	}

	if inst.Config.SSH.OverVsock != nil && *inst.Config.SSH.OverVsock {
		sshVsockPath := filepath.Join(inst.Dir, sshVsockSock)
		args = append(args, "--device", fmt.Sprintf("virtio-vsock,port=22,socketURL=%s,connect", sshVsockPath))
	}

	// Add additional disks
	if len(inst.Config.AdditionalDisks) > 0 {
		ctx := context.Background()
		diskUtil := proxyimgutil.NewDiskUtil(ctx)
		for _, d := range inst.Config.AdditionalDisks {
			disk, derr := store.InspectDisk(d.Name, d.FSType)
			if derr != nil {
				return nil, fmt.Errorf("failed to load disk %#q: %w", d.Name, derr)
			}
			if disk.Instance != "" {
				return nil, fmt.Errorf("failed to run attach disk %#q, in use by instance %#q", disk.Name, disk.Instance)
			}
			if lerr := disk.Lock(inst.Dir); lerr != nil {
				return nil, fmt.Errorf("failed to lock disk %#q: %w", d.Name, lerr)
			}
			extraDiskPath := filepath.Join(disk.Dir, filenames.DataDisk)
			logrus.Infof("Mounting disk %#q on %#q", disk.Name, disk.MountPoint)
			if cerr := diskUtil.Convert(ctx, raw.Type, extraDiskPath, extraDiskPath, nil, true); cerr != nil {
				return nil, fmt.Errorf("failed to convert extra disk %#q to raw: %w", extraDiskPath, cerr)
			}
			args = append(args, "--device", fmt.Sprintf("virtio-blk,path=%s,format=raw", extraDiskPath))
		}
	}

	// Network commands
	networkArgs, err := buildNetworkArgs(inst)

View on GitHub (pinned to dd909d0973)

Solutions

  1. Create the missing disk: `limactl disk create <name> --size <size>` with the FSType your config expects.
  2. Fix the disk name in the instance's lima.yaml `additionalDisks` entry to match an existing disk (`limactl disk list`).
  3. Inspect the wrapped `%w` error for the root cause; if metadata is corrupt, delete and recreate the disk.
  4. Ensure LIMA_HOME points to the same location where the disks were created.

Example fix

# before (lima.yaml)
additionalDisks:
  - name: "datadisk1"   # does not exist
# after
additionalDisks:
  - name: "data"        # created with: limactl disk create data --size 50G
Defensive patterns

Strategy: validation

Validate before calling

// Go: ensure all additional disks exist before starting
out, err := exec.Command("limactl", "disk", "list").Output()
if err != nil { return err }
for _, d := range cfg.AdditionalDisks {
    if !strings.Contains(string(out), d.Name) {
        return fmt.Errorf("disk %q missing; run: limactl disk create %s --size <size>", d.Name, d.Name)
    }
}

Try / catch

if _, err := inst.Start(ctx); err != nil {
    var se *exec.ExitError
    if errors.As(err, &se) && strings.Contains(err.Error(), "failed to load disk") {
        // recover: create the disk, then retry
    }
    return err
}

Prevention

When it happens

Trigger: Calling limactl start (which invokes Cmdline via Start) on an instance whose `additionalDisks` references a disk name that was never created with `limactl disk create`, was deleted, or whose store metadata cannot be inspected.

Common situations: Typos in the `additionalDisks` name in lima.yaml; the disk was deleted manually from ~/.lima/disks; `limactl disk create` was skipped; FSType mismatch with how the disk was created; shared machine where the disk lives under another LIMA_HOME.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/16a29a8c46d2a329. Report an issue: GitHub.