Nfs – Mounting to external NFS from a KVM VM

kvm-virtualizationnfs

I've got a machine acting as a KVM host and another machine that NFS exports to that KVM host. I'd like for one of the internal VMs on the KVM host to be able to mount the NFS share. I can export to the KVM host IP fine and do a mount, but it doesn't work for the internal VM; I just get a failed error with "reason given by server: Permission denied".

I've already tried to re-export the NFS from host to VM, but apparently doing two levels of NFS is not a Good Idea. Anyone know how I might get this working?

Best Answer

How is networking setup for your VM?
Is it bridged, meaning the VM has an IP directly reachable from your network?
Or is it behind NAT, which is what libvirt does by default? If it is NAT, your export line should look like:

<directory> <IP of the KVM Host>(rw,insecure)

The first change is that, instead of allowing access from the virtual machine's IP, you allow access from the IP of the physical machine hosting the virtual machine. This is necessary because with NAT the IP addresses of your virtual machines are translated to the IP address of the KVM host.
The second change is adding the insecure option, which is necessary for your NFS server to accept connections from a port number higher than 1024. This is necessary because when the KVM host does NAT it will use a port higher than 1024 for the connection.

Related Topic