Tutorial: Share a Directory via QEMU Between Debian Host and Windows Guest
Tutorial: Share a Directory via QEMU Between Debian Host and Windows Guest
This guide explains how to share a directory between a Debian host and a Windows guest using QEMU with virtiofs.
Prerequisites
Debian Host: Running QEMU/KVM and virt-manager.
Windows Guest: Installed and operational within QEMU.
Virtiofsd Package: Installed on the host.
WinFSP: Installed on the Windows guest.
Steps to Share a Directory
Step 1: Install Required Tools on Host
Ensure virtiofsd
is installed on your Debian host. Run:
sudo apt update
sudo apt install virtiofsd qemu-system qemu-utils virt-manager
Step 2: Configure the Virtual Machine
Shut down the Windows Guest: Open virt-manager, select your VM, and power it off.
Edit Virtual Machine Settings:
Open virt-manager, right-click your Windows VM, and select "Open".
Click the "Show virtual hardware details" icon.
Scroll down and select Add Hardware > Filesystem.
Configure Filesystem Sharing:
Set the Driver to
virtiofs
.Set the Source Path to the directory you want to share (e.g.,
/media/backup_005_3/qemu.shared
).Set the Target Path to a tag name (e.g.,
shared_folder
).Click "Finish" and "Apply".
Step 3: Verify XML Configuration
Check and edit the VM's XML configuration to ensure virtiofs is properly configured.
In virt-manager, go to the "XML" tab for your VM.
Ensure the following snippet exists:
<filesystem type="mount" accessmode="passthrough">
<driver type="virtiofs"/>
<source dir="/media/backup_005_3/qemu.shared"/>
<target dir="shared_folder"/>
</filesystem>
- Save and close.
Step 4: Install Virtio Drivers on Windows Guest
Download Virtio Drivers:
- Obtain the virtio-win-guest-tools ISO from Fedora Project.
Mount ISO in Windows Guest:
Attach the ISO as a CD drive in virt-manager.
Boot the Windows VM and run the installer from the mounted ISO.
Install WinFSP:
Download the WinFSP installer in the Windows guest.
Install it with the "Core" feature enabled.
Step 5: Start Virtio-FS Service
Enable Virtio-FS in Device Manager:
Open "Device Manager" in Windows.
Verify the "VirtIO FS Device" is listed under "System Devices".
If not, reinstall the VirtIO drivers.
Start the Virtio-FS Service:
Open "Services" in Windows.
Locate "VirtIO-FS Service".
Start the service and set its startup type to "Automatic".
PS C:\WINDOWS\system32> Start-Process -FilePath sc.exe -ArgumentList 'config VirtioFsSvc start= auto' -NoNewWindow -Wait [SC] ChangeServiceConfig SUCCESS PS C:\WINDOWS\system32>
Step 6: Mount the Shared Directory in Windows
Open a Command Prompt or PowerShell in Windows.
Use the following command to map the shared folder to a drive letter (e.g.,
Z:
):
net use Z: \\127.0.0.1\shared_folder
- Replace
shared_folder
with the Target Path you set earlier.
- Verify the shared folder appears in "This PC" as drive
Z:
.
Troubleshooting
Driver Not Found: Ensure virtiofsd is installed on the Debian host and the VirtIO drivers are correctly installed in the guest.
Directory Not Mounted: Recheck the XML configuration and the shared folder path.
Permissions Issues: Verify permissions on the shared directory using
chmod
orchown
on the host.
Conclusion
By following these steps, you can seamlessly share a directory between your Debian host and a Windows guest using QEMU. This method leverages the high-performance virtiofs technology for efficient file sharing.
Subscribe to my newsletter
Read articles from user1272047 directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by