{"record":{"id":"ee6b3e5633c55fc4","repo":"abiosoft/colima","slug":"error-creating-runtime-disk-w","errorCode":null,"errorMessage":"error creating runtime disk: %w","messagePattern":"error creating runtime disk: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/disk.go","lineNumber":40,"sourceCode":")\n\n//go:embed disk.sh\nvar diskScript string\n\nfunc (l *limaVM) createRuntimeDisk(conf config.Config) error {\n\tif environment.IsNoneRuntime(conf.Runtime) {\n\t\t// runtime disk is not required when no runtime is in use\n\t\treturn nil\n\t}\n\n\tdisk := dataDisk(conf.Runtime)\n\n\ts, _ := store.Load()\n\tformat := !s.DiskFormatted // only format if not previously formatted\n\n\tif !limautil.HasDisk() {\n\t\tif err := limautil.CreateDisk(conf.Disk); err != nil {\n\t\t\treturn fmt.Errorf(\"error creating runtime disk: %w\", err)\n\t\t}\n\t\tformat = true // new disk should be formated\n\t}\n\n\t// when disk is formatted for the wrong runtime, prevent use\n\tif s.DiskFormatted && s.DiskRuntime != \"\" && s.DiskRuntime != conf.Runtime {\n\t\treturn fmt.Errorf(\"runtime disk provisioned for %s runtime. Delete container data with 'colima delete --data' before using another runtime\", s.DiskRuntime)\n\t}\n\n\tl.limaConf.Disk = config.Disk(conf.RootDisk).GiB()\n\tl.limaConf.AdditionalDisks = append(l.limaConf.AdditionalDisks, limaconfig.Disk{\n\t\tName:   config.CurrentProfile().ID,\n\t\tFormat: format,\n\t\tFSType: disk.FSType,\n\t})\n\n\tl.mountRuntimeDisk(conf, format)\n\treturn nil","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/disk.go#L22-L58","documentation":"Returned by createRuntimeDisk when limautil.CreateDisk(conf.Disk) fails during 'colima start' provisioning: colima creates a dedicated Lima data disk (limactl disk create) to hold container runtime data (docker/containerd/incus) and attach it as an additional disk. The wrapped error comes from limactl and usually reflects host-side qemu-img/disk issues, insufficient space, or a leftover disk record.","triggerScenarios":"First start (or start after 'colima delete' without disk cleanup) where limactl disk create runs: host disk full at ~/Library/Containers/.../lima (or ~/.lima) so the qcow2 cannot be created; qemu-img missing/broken; a same-named disk already registered in lima in a bad state; permission problems in the lima data dir after brew/lima upgrades.","commonSituations":"Machines with nearly-full startup volumes; upgrading lima/colima changed the lima data directory leaving stale disks; running colima under different users so the lima dir is owned by someone else; interrupted previous delete leaving a half-registered disk.","solutions":["Check host free space ('df -h ~') and free tens of GB (the disk is created lazily but needs some headroom), then retry 'colima start'.","Inspect existing lima disks for stale/corrupt entries: 'limactl disk ls'; remove the colima profile's disk ('limactl disk delete <profile>') and retry colima start.","Fix ownership of the lima data dir if a sudo run owns it: 'sudo chown -R \"$(id -u):$(id -g)\" ~/.lima'.","Reinstall/repair qemu if limactl reports qemu-img errors (brew reinstall qemu lima).","Nuclear option: 'colima delete -f' (removes VM and disks) then 'colima start' to provision everything fresh."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// ensure host space and no stale disk before start\nif fi, err := os.Stat(limaDisksDir()); err == nil && !fi.IsDir() {\n    return fmt.Errorf(\"lima disks path unusable: %s\", limaDisksDir())\n}\nif limautil.HasDisk() {\n    // disk exists; skip creation entirely\n    return nil\n}","typeGuard":"func diskCreationSafe(freeBytes uint64, requestedGiB int) bool {\n    // qcow2 is sparse; require modest headroom, e.g. 1GiB + 10% of requested\n    return freeBytes > uint64(requestedGiB)*1024*1024*1024/10\n}","tryCatchPattern":"if err := limautil.CreateDisk(conf.Disk); err != nil {\n    // stale disk records are the most recoverable cause\n    if strings.Contains(err.Error(), \"already exists\") {\n        _ = limautil.DeleteDisk()\n        if err2 := limautil.CreateDisk(conf.Disk); err2 != nil {\n            return fmt.Errorf(\"error creating runtime disk: %w\", err2)\n        }\n    } else {\n        return fmt.Errorf(\"error creating runtime disk: %w\", err)\n    }\n}","preventionTips":["Keep >5GiB free on the host volume hosting lima data.","Use 'limactl disk ls' to spot stale disks after failed deletes.","Recreate cleanly with 'colima delete -f' rather than hand-editing lima state.","Never run colima as two different users — lima dirs get ownership-mismatched."],"tags":["disk","lima","storage","vm","provisioning"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}