In this post, I’ll show you how to share files between the KVM host and Windows guest using Virtiofs.

To share files between the KVM host and Windows guest, you can use Samba, the standard Windows interoperability suite of programs for Linux and Unix. However, because Samba is not designed for virtualization, there will be some communication overhead.

As a result, a new file system called Virtiofs was created. Virtiofs is a shared file system that allows virtual machines to access the host's directory tree. Its purpose is to emulate the semantics and performance of the local filesystem.

To demonstrate this, I'll share the home directory of my host system with the Windows 11 guest virtual machine.

Before you begin, ensure that you have VirtIO Windows guest tools installed in your Windows 11 guest virtual machine. If not, see my other guide, 'How to Properly Install a Windows 11 Virtual Machine on KVM'. At the end of Section 2, I explain how to install the VirtIO Windows guest tools.

Set Up a Shared Directory on the Host

Launch the Virtual Machine Manager application.

Share Files Between the KVM Host and Windows Guest Using Virtiofs - KVM

Select the Windows guest on which you want to mount the shared directory of the host. Then, click the Open button. In the new window that appears, click the lightbulb icon in the toolbar to show virtual hardware details.

Share Files Between the KVM Host and Windows Guest Using Virtiofs - Open Windows Hardware

You must enable shared memory backing. Memory backing enables virtual memory pages to be backed by host pages.

On the left panel, select Memory, and on the right panel, check the Enable shared memory checkbox. Then press the Apply button.

Share Files Between the KVM Host and Windows Guest Using Virtiofs - VMM Check Shared Memory

Next, on the left bottom, click the Add Hardware button. In the new window that appears, select the Filesystem option from the left panel.

In the right panel, set the driver to virtiofs. Set the source path to the directory on the host that you want to share with the Windows 11 guest virtual machine. I’ll be sharing my home directory, so I’ll set the path to /home/madhu. Then, in the target path, enter any arbitrary string. This string will be used to identify the shared directory that will be mounted within the Windows 11 guest. I’ll set it to 'Host Home', but you can change it to whatever you want. Complete the process by hitting the Finish button.

Share Files Between the KVM Host and Windows Guest Using Virtiofs - VMM Add Filesystem

Finally, run the Windows-11 guest virtual machine by clicking the computer monitor icon and then the play icon in the toolbar.

Share Files Between the KVM Host and Windows Guest Using Virtiofs - VMM Run Windows Guest

Install Windows File System Proxy

WinFsp (Windows File System Proxy) is system software that provides runtime and development support for custom file systems on Windows computers. In this sense, it is similar to FUSE (Filesystem in Userspace), which provides the same functionality on UNIX-like computers.

But, before you install WinFsp, make sure your Windows 11 is up to date.

Share Files Between the KVM Host and Windows Guest Using Virtiofs - Update Windows 11

After you have updated your Windows 11, download and install the most recent stable version of the WinFsp MSI package.

Share Files Between the KVM Host and Windows Guest Using Virtiofs - Install WinFsp

Once the WinFsp package is installed, reboot your Windows 11 guest virtual machine.

Mount the Shared Directory on the Windows Guest Virtual Machine

Now that you have installed the WinFsp package, you have to enable the VirtIO-FS Service in the Windows 11 guest virtual machine in order to mount the shared directory.

To enable VirtIO-FS Service, type services into the search box and press [Enter] to open the Services window.

In the Services window, look for VirtIO-FS Service. Right-click it and select Properties. Then, enable the VirtIO-FS Service.

Share Files Between the KVM Host and Windows Guest Using Virtiofs - Enable VirtIO-FS Service

Then launch Windows Explorer, and you should see your shared directory mounted.

Share Files Between the KVM Host and Windows Guest Using Virtiofs - Shared Directory is Mounted

If you double-click on the mounted shared directory, you should now be able to access your host's home directory.

Share Files Between the KVM Host and Windows Guest Using Virtiofs - Open Shared Directory

The file sharing between the KVM host and Windows guest using Virtiofs is now complete.


Subscribe
Notify of
guest
2 Comments
Newest
Oldest
Inline Feedbacks
View all comments