lima-vm/lima · error

invalid disk size %#q: %w

Error message

invalid disk size %#q: %w

What it means

When creating the disk for a macOS (DARWIN OS) guest under the VZ driver, Lima parses `Config.Disk` (a size string like '60GiB') with `units.RAMInBytes`. If the string is not a valid byte-size expression, parsing fails and the error is wrapped as `invalid disk size %#q`.

Source

Thrown at pkg/driver/vz/vz_driver_darwin.go:407

		}
	}
	return driverutil.EnsureDisk(ctx, l.Instance.Dir, *l.Instance.Config.Disk, l.diskImageFormat)
}

// createDiskMacOSGuest creates `disk` and installs macOS from `image` on it.
// The function must not be called if `disk` already exists.
//
// The function creates the following files:
// - `image.ipsw`: hardlink to `image` (".ipsw" suffix is required by VZMacOSInstaller)
// - `disk`: raw or ASIF disk (ASIF requires macOS 26+)
//
// After successful installation, `image.ipsw` and `image` are removed.
func (l *LimaVzDriver) createDiskMacOSGuest(ctx context.Context) error {
	disk := filepath.Join(l.Instance.Dir, filenames.Disk)

	diskSize, err := units.RAMInBytes(*l.Instance.Config.Disk)
	if err != nil {
		return fmt.Errorf("invalid disk size %#q: %w", *l.Instance.Config.Disk, err)
	}

	switch l.diskImageFormat {
	case asif.Type:
		if err := asifutil.NewASIF(disk, diskSize); err != nil {
			return err
		}
	case raw.Type:
		logrus.Debugf("Using %s disk image for macOS guest", l.diskImageFormat)
		diskUtil := &nativeimgutil.NativeImageUtil{}
		if err := diskUtil.CreateDisk(ctx, disk, diskSize); err != nil {
			return fmt.Errorf("failed to create %s disk %#q: %w", l.diskImageFormat, disk, err)
		}
	default:
		return fmt.Errorf("unsupported disk format for macOS guest: %s", l.diskImageFormat)
	}

	if err = ensureIPSW(l.Instance.Dir); err != nil {

View on GitHub (pinned to dd909d0973)

Solutions

  1. Fix the `disk:` value to a valid size string like `60GiB` or `100GB`
  2. Remove the disk field to restore the default size
  3. Run `limactl validate ./lima.yaml` to confirm the value parses

Example fix

# before
disk: 60 Gigs
# after
disk: 60GiB
Defensive patterns

Strategy: validation

Validate before calling

import "github.com/alecthomas/units"
if _, err := units.RAMInBytes(cfg.Disk); err != nil {
    // reject/fix the disk value (e.g. "60GiB") before create
}

Type guard

func validDiskSize(s string) bool {
    _, err := units.RAMInBytes(s)
    return err == nil
}

Try / catch

if _, err := units.RAMInBytes(cfg.Disk); err != nil {
    return fmt.Errorf("invalid disk size %q: %w", cfg.Disk, err)
}

Prevention

When it happens

Trigger: `limactl create`/`start` of a macOS guest on VZ where the `disk:` field is missing, empty, or not parseable by go-units RAMInBytes (e.g. `disk: "60GB "` with odd chars, or an unset nil-safe default being corrupted).

Common situations: Hand-edited lima.yaml with a malformed disk size; scripts interpolating empty values into `disk:`; copy-paste that dropped units (e.g. `disk: "60"` without unit may also fail depending on parser behavior).

Related errors


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