mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge pull request #28433 from lkxed/20230113-2-Share-Folder-Between-Guest-and-Host-in-virt-manager--KVMQemulibvirt-
[手动选题][tech]: 20230113.2 ⭐️ Share Folder Between Guest and Host in virt-manager (KVMQemulibvirt).md
This commit is contained in:
commit
5fe5278022
@ -0,0 +1,110 @@
|
||||
[#]: subject: "Share Folder Between Guest and Host in virt-manager (KVM/Qemu/libvirt)"
|
||||
[#]: via: "https://www.debugpoint.com/share-folder-virt-manager/"
|
||||
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
Share Folder Between Guest and Host in virt-manager (KVM/Qemu/libvirt)
|
||||
======
|
||||
|
||||
**In this guide, you will learn how to share a folder between host and guest in virt-manager using KVM, QEMU and libvirt.**
|
||||
|
||||
The [virt-manager][1] application or package uses the [libvirt][2] library to provide virtual machine management services. It has a desktop interface that helps to create, delete, and manage multiple virtual machines.
|
||||
|
||||
The virt-manager desktop interface and its components provide flexible virtual machine management services for various personal and business use cases. it is a free and open-source application primarily used for KVM virtual machines. However, it can also support other hypervisors such as Xen and LXC.
|
||||
|
||||
In the earlier article, I explained [how to create a virtual machine using virt-manager][3]. This article covers how you can seamlessly access files and folders between guest and host virtual machines.
|
||||
|
||||
### A note about virtiofs
|
||||
|
||||
The sharing files and folders are powered by the libvirt shared file system called virtiofs. It provides all the features and parameters to access the directory tree on the host machine. Since most of the virt-manager virtual machine configurations are translated to XML, the share files/folders can also be specified by the XML file.
|
||||
|
||||
### Share folder in virt-manager
|
||||
|
||||
- First, make sure your guest virtual machine is powered off. From the virt-manager GUI, select the virtual machine and click on Open to pull up the console settings.
|
||||
|
||||
![Open the settings][4]
|
||||
|
||||
- Click on the icon which says show virtual hardware details in the toolbar. And then click on **Memory** on the left panel.
|
||||
- Select the option “**Enable shared memory**“. Click Apply.
|
||||
|
||||
![Enable the shared memory option][5]
|
||||
|
||||
- And then click “Add hardware” at the bottom.
|
||||
|
||||
![Click on add hardware][6]
|
||||
|
||||
- Select **File system** from the left panel in the add new hardware window.
|
||||
- Then select **Driver=virtiofs** in the details tab. Click on `browse > browse local` and **select the host path** you want to access inside the guest VM.
|
||||
- In the target path, mention any name you want. It’s just a file tag which will be used during mount.
|
||||
- So, if I want to access the Pictures/Screenshots folder (`/home/debugpoint/Pictures/Screenshots`), sample settings could be the following:
|
||||
|
||||
![Add a new file system hardware][7]
|
||||
|
||||
The XML settings are below for the above configuration. You can find it in the XML tab.
|
||||
|
||||
```
|
||||
<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 on Finish. In the main virt-manager window, right-click on the VM and click Run to start the virtual machine. Make sure to click on the “show the graphical console” (monitor icon in the toolbar – if the VM is not showing.
|
||||
|
||||
In the guest machine, create a folder where you want to mount the host folder. For this example, I have used /mnt/pictures.
|
||||
|
||||
```
|
||||
sudo mkdir /mnt/pictures
|
||||
```
|
||||
|
||||
And finally, mount the host folder using the tag you created in the above step to this new folder. Use the following command to do that from the terminal. Ensure to change the tag and folder name in the below command as your system.
|
||||
|
||||
```
|
||||
sudo mount -t virtiofs mount_tag_pictures /mnt/pictures
|
||||
```
|
||||
|
||||
Now you can browse the folders and add/delete items seamlessly in virt-manager between host and guest.
|
||||
|
||||
![Access host files from virt-manager guest][8]
|
||||
|
||||
### Wrapping Up
|
||||
|
||||
I hope this solution helps you to access host files and folders from the guest machine. Remember, your user Id, which is used to launch the virt-manager app, should have the same access to the host folder.
|
||||
|
||||
If you run into any errors, the above guide helped you drop a note below.
|
||||
|
||||
_[Reference][9]_
|
||||
|
||||
[_Using Mastodon? Follow us at floss.social/@debugpoint_][10]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.debugpoint.com/share-folder-virt-manager/
|
||||
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.debugpoint.com/author/admin1/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://virt-manager.org/
|
||||
[2]: https://libvirt.org/manpages/libvirtd.html
|
||||
[3]: https://www.debugpoint.com/virt-manager/
|
||||
[4]: https://www.debugpoint.com/wp-content/uploads/2023/01/Open-the-settings.jpg
|
||||
[5]: https://www.debugpoint.com/wp-content/uploads/2023/01/Enable-the-shared-memory-option.jpg
|
||||
[6]: https://www.debugpoint.com/wp-content/uploads/2023/01/Click-on-add-hardware.jpg
|
||||
[7]: https://www.debugpoint.com/wp-content/uploads/2023/01/Add-a-new-file-system-hardware.jpg
|
||||
[8]: https://www.debugpoint.com/wp-content/uploads/2023/01/Access-host-files-from-virt-manager-guest.jpg
|
||||
[9]: https://libvirt.org/kbase/virtiofs.html
|
||||
[10]: https://floss.social/@debugpoint
|
Loading…
Reference in New Issue
Block a user