lima-vm/lima · error

images[%d].initrd has unexpected architecture %#q, must be %

Error message

images[%d].initrd has unexpected architecture %#q, must be %#q

What it means

The initrd accompanying an image entry is for a different architecture than the image's declared arch; Lima requires them to match so the kernel and initramfs boot correctly.

Source

Thrown at pkg/limayaml/validate.go:101

		if err != nil {
			errs = errors.Join(errs, err)
		}
		if f.Kernel != nil {
			err := validateFileObject(f.Kernel.File, fmt.Sprintf("images[%d].kernel", i))
			if err != nil {
				errs = errors.Join(errs, err)
			}
			if f.Kernel.Arch != f.Arch {
				errs = errors.Join(errs, fmt.Errorf("images[%d].kernel has unexpected architecture %#q, must be %#q", i, f.Kernel.Arch, f.Arch))
			}
		}
		if f.Initrd != nil {
			err := validateFileObject(*f.Initrd, fmt.Sprintf("images[%d].initrd", i))
			if err != nil {
				errs = errors.Join(errs, err)
			}
			if f.Initrd.Arch != f.Arch {
				errs = errors.Join(errs, fmt.Errorf("images[%d].initrd has unexpected architecture %#q, must be %#q", i, f.Initrd.Arch, f.Arch))
			}
		}
	}

	if *y.CPUs == 0 {
		errs = errors.Join(errs, errors.New("field `cpus` must be set"))
	}

	if _, err := units.RAMInBytes(*y.Memory); err != nil {
		errs = errors.Join(errs, fmt.Errorf("field `memory` has an invalid value: %w", err))
	}

	if _, err := units.RAMInBytes(*y.Disk); err != nil {
		errs = errors.Join(errs, fmt.Errorf("field `disk` has an invalid value: %w", err))
	}

	for i, disk := range y.AdditionalDisks {
		if err := identifiers.Validate(disk.Name); err != nil {

View on GitHub (pinned to dd909d0973)

Solutions

  1. Set `initrd.arch` to match the image entry's arch
  2. Remove the `initrd` block if not needed
  3. Move the initrd under the image entry whose arch it matches

Example fix

// before
images:
- arch: x86_64
  initrd:
    arch: aarch64
// after
images:
- arch: x86_64
  initrd:
    arch: x86_64
Defensive patterns

Strategy: validation

Validate before calling

func initrdArchMatches(imgs []limatype.Image) bool {
	for _, f := range imgs {
		if f.Initrd != nil && f.Initrd.Arch != f.Arch {
			return false
		}
	}
	return true
}

Type guard

func initrdArchOk(f limatype.Image) bool {
	return f.Initrd == nil || f.Initrd.Arch == f.Arch
}

Try / catch

if err := limayaml.Validate(y, false); err != nil {
	if strings.Contains(err.Error(), "initrd has unexpected architecture") {
		return fmt.Errorf("initrd arch must match image arch: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: images[i] entry where `initrd.arch` differs from the entry's `arch`, typically after hand-editing a multi-arch template or copying an initrd block between entries.

Common situations: Assembling kernel+initrd for custom images and copying arch lines incorrectly; splitting a single-arch entry into two arch entries without updating initrd.

Related errors


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