lima-vm/lima · error

invalid fstab entry: expected 6 fields, got %d: %v

Error message

invalid fstab entry: expected 6 fields, got %d: %v

What it means

Raised by mountFSTabEntry when a mounts entry parsed from the user-data does not contain exactly 6 whitespace-separated fields, mimicking the Linux fstab format (fs_spec, fs_file, fs_vfstype, fs_mntops, fs_dump, fs_passno). The actual field count and entry are printed in the message.

Source

Thrown at pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go:148

		if err = setResolvConf(ctx, userData.ResolvConf); err != nil {
			errs = append(errs, fmt.Errorf("failed to apply DNS configuration: %w", err))
		}
	}
	if userData.CACerts != nil {
		logrus.Warn("ca_certs is not implemented")
	}
	if len(userData.BootCmd) > 0 {
		logrus.Warn("bootcmd is not implemented")
	}
	return errors.Join(errs...)
}

// mountFSTabEntry mounts a filesystem based on the given fstab entry.
// The format mimics Linux's convention.
// The entries are not written to /etc/fstab.
func mountFSTabEntry(m []string) error {
	if len(m) != 6 {
		return fmt.Errorf("invalid fstab entry: expected 6 fields, got %d: %v", len(m), m)
	}
	src, dst, fsType := m[0], m[1], m[2]
	switch fsType {
	case "virtiofs":
		return mountVirtiofs(src, dst)
	default:
		return fmt.Errorf("unsupported filesystem type %#q for fstab entry: %v", fsType, m)
	}
}

// mountVirtiofs symlinks `/Volumes/My Shared Files/<pseudoTag>` (automatically mounted by macOS) to dir.
// dir must not exist, or, must be a symlink to the expected source.
func mountVirtiofs(pseudoTag, dir string) error {
	if strings.Contains(pseudoTag, string(filepath.Separator)) {
		return fmt.Errorf("invalid pseudo tag for virtiofs: %#q", pseudoTag)
	}
	lnSrc := filepath.Join("/Volumes/My Shared Files", pseudoTag)

View on GitHub (pinned to dd909d0973)

Solutions

  1. Count the fields in the failing entry shown in the error message; it must be exactly 6.
  2. Append the two trailing fstab columns (`0 0`) if you only wrote src/dst/fstype/options.
  3. Use the list form in YAML to avoid quoting/whitespace ambiguity: ["/src", "/dst", "virtiofs", "ro", "0", "0"].
  4. Re-run after fixing; this is a pure validation error, no state is changed.

Example fix

// before (user-data)
mounts:
  - ["/Users/foo/share", "/mnt/share", "virtiofs", "ro"]
// after
mounts:
  - ["/Users/foo/share", "/mnt/share", "virtiofs", "ro", "0", "0"]
Defensive patterns

Strategy: validation

Validate before calling

func validateFSTabFieldCount(mounts [][]string) error {
  for i, m := range mounts {
    if len(m) != 6 {
      return fmt.Errorf("mounts[%d]: expected 6 fields (src dst fstype opts dump passno), got %d: %v", i, len(m), m)
    }
  }
  return nil
}

Type guard

func hasSixFields(m []string) bool { return len(m) == 6 }

Try / catch

if err := mountFSTabEntry(m); err != nil {
  if strings.Contains(err.Error(), "invalid fstab entry") {
    log.Warnf("skipping malformed mounts entry %v", m)
    continue
  }
  return err
}

Prevention

When it happens

Trigger: A `mounts:` list item in user-data splits into != 6 fields, e.g. `["/src", "/dst", "virtiofs", "ro"]` (4 fields) or a malformed YAML string where quoting collapsed fields.

Common situations: Copying only the first 3 columns from a Linux /etc/fstab, omitting the dump and passno columns, or YAML indentation/quoting mistakes that merge or split tokens.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/74ef7ee3d4cce140. Report an issue: GitHub.