How to set up shared folders in virt-manager

Do you need to set up a shared folder between your host OS and guests running in virt-manager? I will show you how to do it on your Fedora system which involves a SELinux policy change.

First of all, if you don’t have it already, install virt-manager and create a virtualized guest which should be pretty straightforward. Afterwards create a future share folder on your host and set up the permissions (for the purpose of this article I will grand all permissions):

Afterwards shut down the guest if it’s running and attach the new filesystem in virt-manager:

  1. Switch the view to detail hardware view: View > Details
  2. Go to Attach hardware > Filesystem
  3. Fill in the name of the source path (/share in our case) and virtual target path (anything you like, I will go with /sharepoint)
  4. Switch mode to Mapped if you need to have write access from the guest
  5. Confirm and start the VM again

virt_manager_add_shared_folder

Now you can mount your shared folder from the VM:

Or permanently add it to /etc/fstab file:

If you don’t have SELinux enabled everything should work now. If you do (which I recommend), you will need to add a policy for files under your /share folder on your host. SELinux won’t allow you to share this folder until it’s labeled svirt_image_t. Here is how to add this policy on your host using semanage:

That should be it. If not, check the logs :).

Join the Conversation

2 Comments

  1. Hi. Great Info, that’ what I wass looking for, however while mounting the external share my Centos guest claims: “Unknown filesystem type 9p”. What do you suggest?

Leave a comment

Your email address will not be published. Required fields are marked *