search
HomeOperation and MaintenanceSafetySharing folders between host and guest of virt-manager

Sharing folders between host and guest of virt-manager

Jun 09, 2023 pm 09:10 PM
System operation and maintenance

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

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.

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

Statement
This article is reproduced at:51CTO.COM. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.