Este contenido no está disponible en el idioma seleccionado.
Chapter 20. Sharing files between the host and its virtual machines
You might frequently require to share data between your host system and the virtual machines (VMs) it runs. To do so quickly and efficiently, you can use the virtio file system (virtiofs).
20.1. Sharing files between the host and its virtual machines by using virtiofs Copiar enlaceEnlace copiado en el portapapeles!
By using the virtio file system (virtiofs), you can share files between your host and your virtual machines (VM) as a directory tree that works the same as the local file system structure.
20.1.1. Sharing files between the host and Windows virtual machines by using the command line Copiar enlaceEnlace copiado en el portapapeles!
When using RHEL 10 as your hypervisor, you can efficiently share files between your host system and Windows virtual machines (VM) using the virtiofs feature along with the virtio-win package.
You can run the virtiofs service in case-insensitive mode on a Windows VM using the virtiofs.exe command and the -i parameter.
Prerequisites
A directory that you want to share with your VMs. If you do not want to share any of your existing directories, create a new one, for example named shared-files.
mkdir /root/shared-files
# mkdir /root/shared-filesCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
You have attached the
virtiodriver installation media to the VM. -
You have attached the
virtiodriver installation media to the VM. -
You have installed the
virtio-winpackage on your Windows VM. For more information, see Installing virtio drivers on a Windows guest.
Procedure
For each directory on the host that you want to share with your VM, set it as a virtiofs file system in the VM’s XML configuration.
Open the XML configuration of the intended VM.
virsh edit vm-name
# virsh edit vm-nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add an entry similar to the following to the
<devices>section of the VM’s XML configuration.Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example sets the
/root/shared-filesdirectory on the host to be visible ashost-file-shareto the VM.
Set up shared memory for the VM. To do so, add shared memory backing to the
<domain>section of the XML configuration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Boot up the VM.
virsh start vm-name
# virsh start vm-nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow On your Windows VM, install WinFsp. To do so, mount the
virtio-winISO image, start thewinfspMSI installer, and follow the prompts.In the Custom Setup window of the installation wizard, select the features you want to install on the VM.
Start the virtiofs service:
sc start VirtioFsSvc
# sc start VirtioFsSvcCopy to Clipboard Copied! Toggle word wrap Toggle overflow Navigate to This PC:
File Explorer
This PC If configured correctly,
virtiofsis available on the Windows VM as the first available drive letter starting withZ:and going backwards. For example,my_viofs (Z:).ImportantYou must restart the
virtiofsservice after each VM reboot to access the shared directory.Optional: To set up additional
virtiofsinstances:Stop the
virtiofsservice:sc stop VirtioFsSvc sc config VirtioFsSvc start=demand
# sc stop VirtioFsSvc # sc config VirtioFsSvc start=demandCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the WinFSP.Launcher service to set up multiple virtiofs instances:
"C:\Program Files (x86)\WinFsp\bin\fsreg.bat" virtiofs "<path to the binary>\virtiofs.exe" "-t %1 -m %2"
# "C:\Program Files (x86)\WinFsp\bin\fsreg.bat" virtiofs "<path to the binary>\virtiofs.exe" "-t %1 -m %2"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Mount
virtiofsinstances to drives.For example, to mount
virtiofswith the tagmount_tag0to theY:drive:"C:\Program Files (x86)\WinFsp\bin\launchctl-x64.exe" start virtiofs viofsY mount_tag0 Y:
"C:\Program Files (x86)\WinFsp\bin\launchctl-x64.exe" start virtiofs viofsY mount_tag0 Y:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Repeat the previous step to mount all of your
virtiofsinstances. To unmount the
virtiofsinstance:"C:\Program Files (x86)\WinFsp\bin\launchctl-x64.exe" stop virtiofs viofsY
"C:\Program Files (x86)\WinFsp\bin\launchctl-x64.exe" stop virtiofs viofsYCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
On your Windows VM, navigate to This PC:
File Explorer
This PC -
If you did not specify a mount point when setting up the
virtiofsservice, it will use the first available drive letter starting withz:and going backwards. -
If you have multiple
virtiofsinstances set up, they will appear as drives with the letters you had assigned to the instances.
-
If you did not specify a mount point when setting up the