I often transfer files between my Windows virtual machine (VM) and my Linux host. Up until now I used a Samba server on the Linux host, with the Windows guest connected via a network bridge. That worked great and never gave me any problems.
Recently I tried out the new virtio-fs shared file system that allows you to share a folder on the Linux host with a Windows or Linux guest. Before you rush and follow my tutorial below, check out the “Performance” and “Conclusion” sections at the end. Here is my tutorial:
virtiofs Tutorial for Windows Guest
The tutorial is divided into four sections:
- Host-side configuration using Virtual Machine Manager (virt-manager)
- WinFSP FUSE software installation in Windows guest
- Virtiofs device driver installation in Windows guest
- Virtiofs service activation in Windows guest
The entire process takes about 10-15 minutes.
Host-side configuration using Virtual Machine Manager (virt-manager)
- Open the Virtual Machine Manager (virt-manager) and select your Windows VM.
- Click “Open”, then click the symbol.
- Select “Memory” and tick the “Enable shared memory” box:
- Click “Add Hardware” and select “Filesystem”:
Make sure the selected “driver” is “virtiofs“.
Then fill in the fields as follows:
Source path: Path to the folder on your Linux host you wish to share with the Windows guest.
Target path: Descriptive name under Windows – Microsoft Windows will mount the source folder as a drive using this name. See example below.
 Export filesystem as readonly mount: You can choose to share your host folder as “read-only” by ticking the box.
In my example above, I shared my Dropbox folder residing on my Linux host to the Windows VM. Windows will create a drive letter with the descriptive name “Dropbox” that will be functionally equivalent to a local folder under Windows.
WinFSP FUSE software installation in Windows guest
- Boot the Windows VM.
- Once Windows has started, download the latest stable release of the WinFsp FUSE software for Windows. For more information on the WinFsp software, see winfsp.dev.
- Run the WinFsp installer and leave the default options as is. This will install the “Core”.
Virtiofs device driver installation in Windows guest
- Now we need to install the virtiofs PCI device driver. You have two options, and I’m showing you both:
- Option 1: Installing the virtiofs driver from the virtio-win drivers ISO. Here we will install only the specific virtiofs device driver.
- If you haven’t got it already, download the virtio-win ISO using the following download links:
Stable virtio-win ISO
Latest virtio-win ISO
Make sure you have enough disk space (~600 MB). As of this writing, the stable and latest driver ISOs are the same: virtio-win-0.1.240.iso.
- Double-click on the downloaded virtio-win-…iso file to mount it in Windows as a DVD drive (usually drive D:).
- Right-click the Windows Start button and select “Device Manager”.
- Open the “Other devices” tab.
- Right-click the “Mass Storage Controller” entry (the one with the yellow triangle) and select “Update driver”.
- Click “Browse my computer for drivers”.
- Select the drive where the virtio-win ISO is mounted.
Make sure to tick “
 Include subfolders“.
- Click “OK” and let Windows search and install the appropriate driver. The “Mass Storage Controller” entry will disappear.
- Option 2: Installing the virtiofs driver using the virtio-win-guest-tools.exe installer. This will automatically install about everything but the kitchen sink.
- Download the stable version of the virtio-win-guest-tools.exe installer from fedorapeople.org. The installer includes the virtiofs and other Windows drivers. For more options, see here.
(Note: The tool is also available on the virtio-win-…iso image from option 1.)
- Run the virtio-win-guest-tools.exe installer.
Make sure “Viofs” is selected! Unless you run multiple VMs and know what you are doing, you can deselect the “Balloon” driver as memory ballooning may be problematic. You can mark the drivers as “install when needed”, like I did below (note the yellow “1”s on the drive icons):
- When done with the selection, click “Next”. You will be asked to agree to the terms and conditions. After a few more clicks the installer should do its work. Note that virtio-win-guest-tools.exe will also install the Spice guest agent and driver. See Virtio-win guest tools installer for more information.
- Either of the two options will install the virtiofs driver. The Device Manager should now show the “VirtIO FS Device” under “System devices”. If not, reboot the Windows VM.
Virtiofs service activation in Windows guest
- In the Windows search bar, type “services”. Select the “Services” App and choose “Run as administrator”.
This opens the Services App below.
- Scroll down and select the “VirtIO-FS Service“:
- Right-click on the VirtIO-FS Service and select “Properties” to open the following window:
- For startup type, use the pull-down menu to select “Automatic”.
- The virtio-win-guest-tools (option 2 in the previous section) should have already started the VirtIO-FS service. If not, click “Start” to start the VirtIO-FS service.
For more information on the virtiofs driver, see here.
- Open the Windows file explorer. If all went well, you should now see the shared host folder mounted as a drive, by default letter Z. In the example above, the host folder appears under “My PC” as “Dropbox (Z:)”.
As with most Microsoft Windows issues, if it doesn’t work, close the Windows and reboot.
For reference, there is another good tutorial over at Debugpoint.com: “Share Folder Between Windows Guest and Linux Host in KVM using virtiofs“.
The first thing I wanted to see is how well (or not so well) virtiofs performs versus the old and proven file sharing method using a Samba server on the host. Here are some bullet points of my Samba setup for sharing a Linux host folder to the Windows VM:
- Bridged network using the virtio interface in the Windows guest. A bridged network is so much faster compared to the default routed network. Caveat: Bridging is only available on wired connections, not on wireless networks.
Just to get an idea of the performance, the network speed between the VM and the host using a network bridge should be somewhere around 10 Gbit.
- Samba server on the Linux host.
- Network folder mounted on Windows.
- The shared folder is an ext4 partition residing on a LVM logical volume. Every partition on my PC – including the NTFS partitions of my Windows guest, uses LVM. The sole exception is the UEFI boot partition.
- All copy/move transactions were performed on partitions residing on NVME drives. The Windows guest partitions reside on a 1 TB NVME drive whereas the Linux host folders are on another 500 GB NVME drive.
The shared folder on the Linux host is a Dropbox folder that syncs to the cloud using the proprietary Dropbox application. The Dropbox application only runs on the Linux host.
I created a 2 GB random character file using the following command:
head -c 2G /dev/urandom > sample.txt
On the Linux host I timed the
mv commands copying/moving the sample.txt file between different host folders/partitions as well as between the host ext4 file system and the mounted guest NTFS partition. The guest NTFS partition was mounted using the ntfs-3g FUSE driver (not to be confused with the ntfs3 kernel driver). See screenshot below:
As you can see, it takes less than 2 seconds to copy or move a 2Gbyte file between different ext4 partitions on the host. However, copying or moving the same 2GByte from the ext4 host partition to a mounted NTFS partition took more than 14 seconds (using the NTFS-3G driver). Because of potential file corruption using the new NTFS3 kernel driver, I now avoid using the kernel driver and did not use it for this test.
The above results are for reference only, to get an idea on how fast a file can be copied or moved from one place to another on the Linux host. The following screenshot is taken within the Windows guest and shows the time it took to copy the 2GB file from the Windows VM to the Linux host using the virtiofs shared file system:
Robocopy measures 18 seconds for copying the 2GB file from Windows to the Linux folder. Not exactly earth-shattering.
The screenshot below shows the same file copy command, but this time the file is copied to the Samba share folder on the Linux host using the smb protocol over the bridged network interface:
With smb (Samba server) the Robocopy took only 2 seconds for copying the 2GB file from Windows to the Linux folder. That’s nine times as fast as using virtiofs!
Below is a graph taken during a copy action using the virtiofs driver:
Notice the speed of only 105 MB/s using virtiofs. Next is a graph showing the file transfer speed using the smb network protocol (Samba):
Using a Samba server on the Linux host and a bridged network connection to the guest, the copy speed rises to 955 MB/s. Again, nine times as fast as using virtiofs.
For the speed test in a Windows VM, Samba is the winner!
Update: I did the sample.txt file copy/move test from a Linux guest to the Linux host using virtiofs. This is a lot faster than under Windows! Below are the results:
The file was copied in 3 seconds, the move command took 3.4 seconds. The file transfer speed from/to a Linux guest is significantly higher than from/to a Windows guest.
Virtiofs is an easy way to share files between your host and your Windows VM. It also works with more than one VM, sharing data between multiple VMs and the host. Likewise you can share multiple folders/partitions on your host to your VMs.
Though Samba is no rocket science, virtiofs is easier to implement. If you do not transfer large files or large amounts of data, then virtiofs is perfectly adequate and there is no need to install a Samba server on your host.
Virtiofs was primarily developed to share files between the host and multiple containers running Linux. After you configured the shared folder on the host side (see tutorial above), all you need to do to enable virtiofs in a Linux VM or container is the following shell command:
mount -t virtiofs shared_host_folder /mnt/host
To automatically mount a host share in a Linux guest on boot, add the following line to your
/etc/fstab file (change as appropriate):
shared_host_folder /mnt/host virtiofs rw,relatime 0 0
So yes, virtiofs is easy to configure, even more so in Linux. But with a Windows guest and a bridged network, Samba is a lot faster.
There are other concerns that make virtiofs less ideal. Aside from slow speed (which is also mentioned by others), users reported memory leaks and other issues/bugs. While Samba isn’t perfect either, it has been quite reliable over the many years I used it.
By design, virtiofs should have some advantages, once performance has improved and the bugs are ironed out. Since I often copy large files or a large volume of data from the Windows guest to the host, I need a fast copy speed between the two. That makes virtiofs currently unsuitable for me.
With regard to Linux guests, virtiofs is far easier to configure and much more performant. As always, YMMV.