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

5 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?

  2. Thanks for sharing. In the fstab example file, the source “/sharepoint” and target “/share” paths are inverted.

    1. Yep, this caused me to FUBAR my Fedora install, had to fix it from recovery. Oh well! Teaches me to double-check before copy’n’pasting next time. :)

Leave a comment

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