{"record":{"id":"8dc9f3ac64d733a9","repo":"lima-vm/lima","slug":"failed-to-mount-q-on-q-w-output-q","errorCode":null,"errorMessage":"failed to mount %#q on %#q: %w (output=%#q)","messagePattern":"failed to mount %#q on %#q: %w \\(output=%#q\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/osutil/mount_darwin.go","lineNumber":26,"sourceCode":"\t\"fmt\"\n\t\"os/exec\"\n\t\"strings\"\n\n\t\"github.com/sirupsen/logrus\"\n)\n\n// Mount mounts the device.\n// Root privileges is not necessary.\nfunc Mount(ctx context.Context, fs, dev, mnt string, options []string) error {\n\targs := []string{\"-t\", fs}\n\tif len(options) > 0 {\n\t\targs = append(args, \"-o\", strings.Join(options, \",\"))\n\t}\n\targs = append(args, dev, mnt)\n\tcmd := exec.CommandContext(ctx, \"mount\", args...)\n\tlogrus.Debugf(\"Executing command: %v\", cmd.Args)\n\tif output, err := cmd.CombinedOutput(); err != nil {\n\t\treturn fmt.Errorf(\"failed to mount %#q on %#q: %w (output=%#q)\", dev, mnt, err, output)\n\t}\n\treturn nil\n}\n\nfunc Umount(ctx context.Context, mnt string) error {\n\tcmd := exec.CommandContext(ctx, \"umount\", mnt)\n\tlogrus.Debugf(\"Executing command: %v\", cmd.Args)\n\tif output, err := cmd.CombinedOutput(); err != nil {\n\t\treturn fmt.Errorf(\"failed to unmount %#q: %w (output=%#q)\", mnt, err, output)\n\t}\n\treturn nil\n}\n","sourceCodeStart":8,"sourceCodeEnd":39,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/osutil/mount_darwin.go#L8-L39","documentation":"Lima's macOS Mount() helper runs the external `mount` command with the given device, mountpoint, and options. This error wraps any non-zero exit of that command together with its combined stdout/stderr output, so the developer can see exactly why the kernel refused the mount.","triggerScenarios":"writeGuestFiles calls osutil.Mount on macOS and the `mount <flags> <dev> <mnt>` subprocess exits non-zero (bad device, missing mount point, permission denied, mount point already in use).","commonSituations":"Mounting a disk image before hdiutil attach completed; mount point directory missing; macOS SIP/permission prompts denying the operation; device already mounted elsewhere.","solutions":["Read the `output=` portion of the error — it contains mount(8)'s own diagnostic (e.g. 'Resource busy', 'no such file or directory').","Ensure the device is attached (hdiutil attach / diskutil list shows it) and the mount point directory exists.","Check the mount point isn't already mounted (diskutil info <mnt>).","Confirm the process has permission (sudo) if the filesystem requires elevated mount."],"exampleFix":"// before\nos.MkdirAll /tmp/lima missing -> mount fails\n// after\nif err := os.MkdirAll(mnt, 0o755); err != nil { return err }\nreturn osutil.Mount(ctx, dev, mnt, \"cd9660\")","handlingStrategy":"try-catch","validationCode":"// preflight before calling Mount\nif _, err := os.Stat(dev); err != nil { return fmt.Errorf(\"device missing: %w\", err) }\nif fi, err := os.Stat(mnt); err != nil || !fi.IsDir() { return fmt.Errorf(\"mount point missing: %s\", mnt) }","typeGuard":null,"tryCatchPattern":"if err := osutil.Mount(ctx, dev, mnt, \"cd9660\"); err != nil {\n    var exitErr *exec.ExitError\n    if errors.As(err, &exitErr) {\n        log.Errorf(\"mount failed: %s\", strings.TrimSpace(extractOutput(err)))\n    }\n    return err\n}","preventionTips":["Always create the mount point directory before mounting","Ensure the disk image is attached (hdiutil) before mounting its device","Check for existing mounts on the target path (diskutil info)","Parse the embedded `output=` field for the kernel's actual reason"],"tags":["macos","mount","filesystem","subprocess"],"backgroundTag":"mount-command-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}