{"record":{"id":"9ded5196f0d5a3ef","repo":"lima-vm/lima","slug":"failed-to-chmod-q-w-9ded51","errorCode":null,"errorMessage":"failed to chmod %#q: %w","messagePattern":"failed to chmod %#q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driverutil/disk.go","lineNumber":110,"sourceCode":"\t\t}\n\t\tif err := diskUtil.Convert(ctx, diskImageFormat, diskPath, diskPath, &diskSizeInBytes, false); err != nil {\n\t\t\tos.Remove(diskPath)\n\t\t\t_ = os.Rename(isoPath, imagePath)\n\t\t\treturn fmt.Errorf(\"failed to create disk %#q: %w\", diskPath, err)\n\t\t}\n\t} else {\n\t\tformat, err := nativeimgutil.DetectFormat(imagePath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Resize handled by prepareDisk() after CreateDisk()\n\t\tif format == string(diskImageFormat) {\n\t\t\tif err = os.Rename(imagePath, diskPath); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to rename %#q to %#q: %w\", imagePath, diskPath, err)\n\t\t\t}\n\t\t\tif err := os.Chmod(diskPath, 0o644); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to chmod %#q: %w\", diskPath, err)\n\t\t\t}\n\t\t} else {\n\t\t\tif err := diskUtil.Convert(ctx, diskImageFormat, imagePath, diskPath, &diskSizeInBytes, false); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to convert %#q to %#q: %w\", imagePath, diskPath, err)\n\t\t\t}\n\t\t\tos.Remove(imagePath)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":92,"sourceCodeEnd":121,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driverutil/disk.go#L92-L121","documentation":"EnsureDisk wraps an os.Chmod failure after successfully renaming the non-ISO image to the disk path. Lima normalizes the disk file to mode 0644 so QEMU/virtualization can read it; failing to set the mode is surfaced here. The wrapped errno (usually EPERM or ENOENT) identifies the cause.","triggerScenarios":"os.Chmod(diskPath, 0o644) fails right after a successful rename in EnsureDisk: diskPath owned by another user, filesystem disallows chmod (some network/NFS mounts), or the file was removed between rename and chmod by a concurrent process.","commonSituations":"Instance directory shared over NFS/SMB or in a container bind mount that ignores or rejects permission changes; limactl run under a different UID than the file owner; SELinux/AppArmor policies blocking chmod.","solutions":["Check the wrapped errno; for EPERM fix ownership of instDir files (chown to the lima user)","Move ${LIMA_HOME} to a local filesystem that supports POSIX permissions if on NFS/SMB","Ensure only one lima process manages the instance to avoid the file disappearing mid-setup","Re-run the create/start command after fixing permissions; the disk already exists check will let you continue or recreate"],"exampleFix":"// before: chmod fails on NFS share\n// LIMA_HOME=/mnt/nfs/lima\n// after: use a local directory\nexport LIMA_HOME=\"$HOME/.lima\"","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(instDir); err != nil || fi.Mode().Perm()&0o200 == 0 {\n    return fmt.Errorf(\"instDir not writable by current user\")\n}","typeGuard":"func chmodSupported(path string) bool {\n    return !isNetworkMount(path) // e.g. check /proc/mounts for nfs/cifs\n}","tryCatchPattern":"if err := driverutil.EnsureDisk(ctx, instDir, diskSize, format); err != nil {\n    if strings.Contains(err.Error(), \"chmod\") {\n        var perr *os.PathError\n        errors.As(err, &perr) // EPERM => ownership or FS limitation\n    }\n    return err\n}","preventionTips":["Avoid placing LIMA_HOME on NFS/SMB shares that restrict chmod","Keep one lima process per instance","Ensure consistent UID across limactl invocations (not mixed root/user)"],"tags":["filesystem","permissions","chmod"],"backgroundTag":"permission-denied","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}