lima-vm/lima · error

failed to convert extra disk %#q to a raw disk: %w

Error message

failed to convert extra disk %#q to a raw disk: %w

What it means

attachDisks converts the extra disk's data image to raw via DiskUtil.Convert before vz can attach it; failure of the conversion step is wrapped here. Convert is a NOP when the image is already raw, so the error indicates the actual conversion (or its I/O) failed.

Source

Thrown at pkg/driver/vz/vm_darwin.go:600

	diskUtil := proxyimgutil.NewDiskUtil(ctx)

	for _, d := range inst.Config.AdditionalDisks {
		diskName := d.Name
		disk, err := store.InspectDisk(diskName, d.FSType)
		if err != nil {
			return fmt.Errorf("failed to run load disk %#q: %w", diskName, err)
		}

		logrus.Infof("Mounting disk %#q on %#q", diskName, disk.MountPoint)
		if err = disk.LockForInstance(inst.Dir); err != nil {
			return fmt.Errorf("failed to attach disk %#q: %w", diskName, err)
		}
		extraDiskPath := filepath.Join(disk.Dir, filenames.DataDisk)
		// ConvertToRaw is a NOP if no conversion is needed
		logrus.Debugf("Converting extra disk %#q to a raw disk (if it is not a raw)", extraDiskPath)

		if err = diskUtil.Convert(ctx, raw.Type, extraDiskPath, extraDiskPath, nil, true); err != nil {
			return fmt.Errorf("failed to convert extra disk %#q to a raw disk: %w", extraDiskPath, err)
		}
		extraDiskPathAttachment, err := vz.NewDiskImageStorageDeviceAttachmentWithCacheAndSync(extraDiskPath, false, diskImageCachingMode, vz.DiskImageSynchronizationModeFsync)
		if err != nil {
			return fmt.Errorf("failed to create disk attachment for extra disk %#q: %w", extraDiskPath, err)
		}
		extraDisk, err := vz.NewVirtioBlockDeviceConfiguration(extraDiskPathAttachment)
		if err != nil {
			return fmt.Errorf("failed to create new virtio block device config for extra disk %#q: %w", extraDiskPath, err)
		}
		configurations = append(configurations, extraDisk)
	}

	if err := validateDiskFormat(ciDataPath); err != nil {
		return err
	}
	ciDataAttachment, err := vz.NewDiskImageStorageDeviceAttachment(ciDataPath, true)
	if err != nil {
		return err

View on GitHub (pinned to dd909d0973)

Solutions

  1. Free disk space on the volume containing the instance/disk directories and retry
  2. Manually convert/inspect the image (`qemu-img convert -O raw`) to reveal the underlying problem
  3. Delete and recreate the disk (`limactl disk delete` / `create`) if the data disk is corrupt
Defensive patterns

Strategy: try-catch

Validate before calling

st, _ := os.Stat(diskPath)
if st.Size() > availableSpaceOnVolume(diskDir) {
    return fmt.Errorf("insufficient space to convert %s to raw", diskPath)
}

Try / catch

if err := startInstance(cfg); err != nil {
    if strings.Contains(err.Error(), "to a raw disk") {
        // free space or manually convert the image, then retry
    }
}

Prevention

When it happens

Trigger: diskUtil.Convert(ctx, raw.Type, extraDiskPath, extraDiskPath, nil, true) returns an error — corrupt source image, insufficient free space for the raw conversion, or I/O error writing in place.

Common situations: Disk full on the host volume holding ${LIMA_HOME}; source data disk corrupted after a crash; a very large qcow2 disk exhausting space during in-place conversion.

Related errors


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