The best way to share a host directory using virt-manager?

I’ve only successfully shared a host directory using using nfs, but I understand their are other methods available. When I did use nfs I had to shut down my firewall first. Is there a prefered method that works out of the box. My goal is to share a local repository with virtual machines.

You just have to create a rule who works with NFS.

The command firewall-config is a gui that allows easily setting the rules for firewalld. Once the nfs rules are working as desired then the options button at the top allows one to save the runtime settings to permanent so they remain with every boot.

Allow me to add a clarification! I’ve a small lab network of usually four Fedora nodes and NFS works across the network to each of the nodes when hosted on the node that is my production machine. (Occasionally, I bring nodes down nodes, allowing me to play with Win10, Win11, & other Linux variants!) The only failure of NFS I experience is using an NFS host on the same node running the virtual machines. Come to think of it, I have not tested putting the NFS server on seperaate node.

I need to continue making progress on my repo project, so I’ll need to continue bringing down firewalld while looking for a solution. Running the NFS server and having the repository on the vm works but seems a little backwards.

Thanks for help that is stimulating new ideas!

Option 1: If your VM machines are configured with NAT networking, the local machine sees the internal VM IP. You can mount the local NFS server by specifying the default route address 192.168.122.1, but the firewall could block it. In firewall-config/sources, add the VM IP address or subnet to zone “trusted”, then nfs to the local machine’s NFS server will work.

Option 2: Add hardware to the VM. Not really hardware, but a filesystem with virtio-9p driver. Source can be a physical directory, but a NFS mountpoint will work too. You can mount it in the VM with “mount -t 9p <destination> <mount point>” with “<destination>” the target path specified in virt-manager.

2 Likes

Option 1 worked and I’ll attempt Option 2 once I’m back on schedule.

Thanks!