Sometimes a VM needs files from the host: source code in a dev lab, media for a server, or shared data between VMs on one host. virtiofs is a shared filesystem designed for VMs that is much faster and more POSIX-compliant than older 9p sharing or NFS over a virtual network.
Before you start
- A KVM host with recent libvirt and QEMU, and the
virtiofsddaemon (packaged asvirtiofsdon many distributions). - A Linux guest with kernel 5.4 or newer, or Windows with virtio-win drivers and WinFsp.
- For sharing between hosts, use NFS or Ceph instead; see NFS shared storage.
Enable shared memory for the VM
virtiofs requires the VM's memory to be shareable with the daemon. In the VM XML (virsh edit vmname):
<memoryBacking>
<source type='memfd'/>
<access mode='shared'/>
</memoryBacking>Add the filesystem device
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs'/>
<source dir='/srv/shared/projects'/>
<target dir='projects'/>
</filesystem>target dir is a tag, not a path. Shut down and start the VM. virt-manager can add this under Add Hardware → Filesystem with driver virtiofs.
Mount in a Linux guest
sudo mkdir -p /mnt/projects && sudo mount -t virtiofs projects /mnt/projectsPersist it in /etc/fstab:
projects /mnt/projects virtiofs defaults,nofail 0 0Windows guests
- Install virtio-win drivers (including the virtiofs driver) and WinFsp.
- Start the VirtIO-FS service; the share appears as a drive letter.
See Windows VMs on KVM for virtio-win.
Security notes
- The guest can read and write the shared directory with the daemon's permissions; share only what is needed.
- Do not share sensitive host paths (like
/or/etc). - For untrusted guests, prefer network file sharing with authentication or no sharing at all.
Limitations
- Live migration of VMs using virtiofs has limited support depending on versions.
- Shared memory backing prevents some memory features such as ballooning in certain setups.
Troubleshooting
- VM fails to start, "virtiofs requires shared memory": add the memoryBacking block.
- "virtiofsd not found": install the package or set the binary path in the driver element.
- Permission denied in guest: host directory ownership or SELinux label; check with
ls -Z.
Frequently asked questions
virtiofs or 9p?
virtiofs is faster and more compatible; 9p is older and simpler.
Can two VMs share the same folder?
Yes, each with its own virtiofs device, but concurrent writes need application-level care.
Does Proxmox support virtiofs?
Recent Proxmox versions offer virtiofs directory mappings for VMs.
