virt-manager Applications or software packages use the libvirt library to provide virtual machine management services. It has a desktop interface that helps create, delete and manage multiple virtual machines.
virt-manager desktop interface and its components provide flexible virtual machine management services for a variety of personal and business scenarios. It is a free and open source application mainly used for KVM virtual machines. However, it can also support other hypervisors such as Xen and LXC.
In the previous article, I explained How to use virt-manager to create a virtual machine. This article explains how to seamlessly access files and folders between the client and host.
Instructions about virtiofs
Shared files and folders are provided by the libvirt shared file system named virtiofs. It provides all functions and parameters for accessing the directory tree on the host machine. Since most virt-manager virtual machine configurations are translated into XML, shared files/folders can also be specified via XML files.
Sharing folders in virt-manager
First, make sure your client is powered off. In the virt-manager GUI, select the virtual machine and click "Open" to pop up the console settings.
Open Settings
Click the icon on the toolbar that displays virtual hardware details. Then click "Memory" on the left panel.
Select the option "Enable shared memory". Click Apply.
Enable the shared memory option
Then click "Add hardware" at the bottom.
Click to add hardware
In the window to add new hardware, select "File system" from the left panel .
Then select "Driver" as "virtiofs" in the "Details" tab. Click "Browse > browse local browse local", select the host path you want to access in the client .
In Destination Path, enter any name you want. This is just a file label that will be used when mounting.
So, if I want to access the Pictures/Screenshots
folder (/home/debugpoint/Pictures/Screenshots
), example setup It could look like this:
Add a new file system hardware
The following are the XML settings for the above configuration. You can find it in XML tags.
<filesystem type="mount" accessmode="passthrough"><driver type="virtiofs"/><binary path="/usr/libexec/virtiofsd"/><source dir="/home/debugpoint/Pictures/Screenshots"/><target dir="mount_tag_pictures"/><alias name="fs1"/><address type="pci" domain="0x0000" bus="0x08" slot="0x00" function="0x0"/></filesystem>
Click "Finish". In the main window of virt-manager, right-click the virtual machine and click Run to start the virtual machine. Make sure to click "show the graphical console" (if the virtual machine does not show up, click the monitor icon on the toolbar).
In the guest machine, create a folder where you want to mount the host folder. In this example, I used /mnt/pictures
.
sudo mkdir /mnt/pictures
Finally, mount the hosts folder to this new folder using the label you created in the above step. Use the following command to do this in the terminal. Make sure to change the labels and folder names in the commands below according to your system.
sudo mount -t virtiofs mount_tag_pictures /mnt/pictures
Now you can browse folders and add/remove items seamlessly between host and guest in virt-manager.
Accessing host files from the virt-manager client
Summary
I hope this solution can help you access host files and folders from the client. Remember, your user ID, which is the user used to launch the virt-manager application, should have the same permissions to access the hosts folder.
The above is the detailed content of Sharing folders between host and guest of virt-manager. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Linux new version
SublimeText3 Linux latest version

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
