lima-vm/lima · error
failed to mount %#q on %#q: %w (output=%#q)
Error message
failed to mount %#q on %#q: %w (output=%#q)
What it means
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.
Source
Thrown at pkg/osutil/mount_darwin.go:26
"fmt"
"os/exec"
"strings"
"github.com/sirupsen/logrus"
)
// Mount mounts the device.
// Root privileges is not necessary.
func Mount(ctx context.Context, fs, dev, mnt string, options []string) error {
args := []string{"-t", fs}
if len(options) > 0 {
args = append(args, "-o", strings.Join(options, ","))
}
args = append(args, dev, mnt)
cmd := exec.CommandContext(ctx, "mount", args...)
logrus.Debugf("Executing command: %v", cmd.Args)
if output, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("failed to mount %#q on %#q: %w (output=%#q)", dev, mnt, err, output)
}
return nil
}
func Umount(ctx context.Context, mnt string) error {
cmd := exec.CommandContext(ctx, "umount", mnt)
logrus.Debugf("Executing command: %v", cmd.Args)
if output, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("failed to unmount %#q: %w (output=%#q)", mnt, err, output)
}
return nil
}
View on GitHub (pinned to dd909d0973)
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.
Example fix
// before
os.MkdirAll /tmp/lima missing -> mount fails
// after
if err := os.MkdirAll(mnt, 0o755); err != nil { return err }
return osutil.Mount(ctx, dev, mnt, "cd9660") Defensive patterns
Strategy: try-catch
Validate before calling
// preflight before calling Mount
if _, err := os.Stat(dev); err != nil { return fmt.Errorf("device missing: %w", err) }
if fi, err := os.Stat(mnt); err != nil || !fi.IsDir() { return fmt.Errorf("mount point missing: %s", mnt) } Try / catch
if err := osutil.Mount(ctx, dev, mnt, "cd9660"); err != nil {
var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
log.Errorf("mount failed: %s", strings.TrimSpace(extractOutput(err)))
}
return err
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: Mounting a disk image before hdiutil attach completed; mount point directory missing; macOS SIP/permission prompts denying the operation; device already mounted elsewhere.
Related errors
- failed to create mount point %#q: %w
- failed to unmount %#q: %w (output=%#q)
- failed to create temp file: %w
- failed to write temp plist: %w
- failed to create a temporary file for signing QEMU binary: %
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/8dc9f3ac64d733a9.
Report an issue: GitHub.