Home > Operation and Maintenance > Safety > Sharing folders between host and guest of virt-manager

Sharing folders between host and guest of virt-manager

王林
Release: 2023-06-09 21:10:16
forward
963 people have browsed it

在 virt-manager 的主机和客户机之间共享文件夹

​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.

在 virt-manager 的主机和客户机之间共享文件夹

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.

在 virt-manager 的主机和客户机之间共享文件夹

Enable the shared memory option

Then click "Add hardware" at the bottom.

在 virt-manager 的主机和客户机之间共享文件夹

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:

在 virt-manager 的主机和客户机之间共享文件夹

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>
Copy after login

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
Copy after login

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
Copy after login

Now you can browse folders and add/remove items seamlessly between host and guest in virt-manager.

在 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!

source:51cto.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template