Mounting filesystems

How to mount a host directory into the VM

9P Mounts

9P mounts are flexible and work across all hypervisors, but suffers from performance and reliability issues when used with large folders (>600 files). See Driver Mounts as an alternative.

To mount a directory from the host into the guest using the mount subcommand:

  1. minikube mount <source directory>:<target directory>

For example, this would mount your home directory to appear as /host within the minikube VM:

  1. minikube mount $HOME:/host

This directory may then be referenced from a Kubernetes manifest, for example:

  1. {
  2. "apiVersion": "v1",
  3. "kind": "Pod",
  4. "metadata": {
  5. "name": "ubuntu"
  6. },
  7. "spec": {
  8. "containers": [
  9. {
  10. "name": "ubuntu",
  11. "image": "ubuntu:18.04",
  12. "args": ["bash"],
  13. "stdin": true,
  14. "stdinOnce": true,
  15. "tty": true,
  16. "workingDir": "/host",
  17. "volumeMounts": [
  18. {
  19. "mountPath": "/host",
  20. "name": "host-mount"
  21. }
  22. ]
  23. }
  24. ],
  25. "volumes": [
  26. {
  27. "name": "host-mount",
  28. "hostPath": {
  29. "path": "/host"
  30. }
  31. }
  32. ]
  33. }
  34. }

Driver mounts

Some hypervisors, have built-in host folder sharing. Driver mounts are reliable with good performance, but the paths are not predictable across operating systems or hypervisors:

DriverOSHostFolderVM
VirtualBoxLinux/home/hosthome
VirtualBoxmacOS/Users/Users
VirtualBoxWindowsC://Users/c/Users
VMware FusionmacOS/Users/mnt/hgfs/Users
KVMLinuxUnsupported
HyperKitmacOSSupported

These mounts can be disabled by passing --disable-driver-mounts to minikube start.

HyperKit mounts can use the following flags: --nfs-share=[]: Local folders to share with Guest via NFS mounts --nfs-shares-root='/nfsshares': Where to root the NFS Shares, defaults to /nfsshares

File Sync

See File Sync

Last modified February 1, 2022: Added Network Policy page to handbook (51092e0e3)