{"record":{"id":"82e9f5e2ceb305b2","repo":"abiosoft/colima","slug":"invalid-disk-image-w","errorCode":null,"errorMessage":"invalid disk image: %w","messagePattern":"invalid disk image: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/disk.go","lineNumber":151,"sourceCode":"\t\t\t\"{mount_point}\", mountPoint,\n\t\t\t\"{name}\", dir.Name,\n\t\t\t\"{data_path}\", dir.Path,\n\t\t).Replace(\"[ -d {mount_point} ] && mkdir -p {mount_point}/{name} {data_path} && mount --bind {mount_point}/{name} {data_path}\")\n\n\t\tl.limaConf.Provision = append(l.limaConf.Provision, limaconfig.Provision{\n\t\t\tMode:   \"dependency\",\n\t\t\tScript: script,\n\t\t})\n\t}\n}\n\nfunc (l *limaVM) downloadDiskImage(ctx context.Context, conf config.Config) error {\n\tlog := l.Logger(ctx)\n\n\t// use a user specified disk image\n\tif conf.DiskImage != \"\" {\n\t\tif _, err := os.Stat(conf.DiskImage); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid disk image: %w\", err)\n\t\t}\n\n\t\timage, err := limautil.Image(l.limaConf.Arch, conf.Runtime)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error getting disk image details: %w\", err)\n\t\t}\n\n\t\tsha := downloader.SHA{Size: 512, Digest: image.Digest}\n\t\tif err := sha.ValidateFile(l.host, conf.DiskImage); err != nil {\n\t\t\tif conf.ForceDiskImage != nil && *conf.ForceDiskImage {\n\t\t\t\tlog.Warnln(\"unable to validate disk image, but continuing as requested...\")\n\t\t\t\timage.Digest = \"\" // clear so lima does not re-validate\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"disk image must be downloaded from '%s', hash failure: %w\", image.Location, err)\n\t\t\t}\n\t\t}\n\n\t\timage.Location = conf.DiskImage","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/disk.go#L133-L169","documentation":"While provisioning the VM image, Colima supports a user-supplied disk image via the DiskImage config. Before using it, the file is verified on the host with os.Stat; any stat failure (missing file, permission denied, dangling symlink, bad path) is wrapped as 'invalid disk image'. This is a host-side path check that happens before any digest validation.","triggerScenarios":"Setting the diskImage config key (colima start --disk-image flag / config file) to a path that does not exist, is not readable by the current user, is a directory, or contains typos/relative-path mistakes. Also when the file sits on an unmounted external volume at start time.","commonSituations":"Air-gapped machines pointing at a pre-downloaded qcow2 image whose path changed; shell quoting issues with spaces in the path; images on removable media not yet mounted; wrong ~ expansion in YAML config.","solutions":["Verify the path exists and is readable: `ls -la /path/to/image` run as the same user that starts Colima.","Use an absolute path in the config/flag to avoid cwd-dependent resolution.","If the image is missing, download the correct image for your architecture and runtime, or omit diskImage to let Colima fetch/cache it automatically.","Check for trailing quotes/spaces in YAML values (e.g. `disk-image: \"~/images/img.qcow2 \"`)."],"exampleFix":"# before\ncolima start --disk-image ./ubuntu.qcow2   # file absent or mistyped\n\n# after\nls -la /absolute/path/to/ubuntu.qcow2\ncolima start --disk-image /absolute/path/to/ubuntu.qcow2","handlingStrategy":"validation","validationCode":"// before colima start --disk-image\nif fi, err := os.Stat(diskImagePath); err != nil || fi.IsDir() {\n    log.Fatalf(\"disk image path invalid: %v\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass absolute paths for --disk-image","Verify the file exists and is readable before starting","Avoid trailing spaces/quotes in YAML config values"],"tags":["disk-image","filesystem","colima","path","qcow2"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}