First one important information: NFSv4 is not supported in OpenVZ (mount.nfs4: Protocol not supported). More info here:
http://forum.openvz.org/index.php?t=msg&goto=46174&. NFSv3 is notorious for leaving hanging file locks and in my opinion NFSv3 should not be used in file intensive setups.
To activate NFS inside a container issue the command below:
Code:
vzctl set $CTID --feature nfsd:on --save
Remember to enter yes in the container in this file /etc/default/nfs-common
# Do you want to start the statd daemon? It is not needed for NFSv4.
NEED_STATD=yes
On the PVE host you need to ensure modules nfs and nfsd is loaded:
modprobe nfsd
modprobe nfs
After all this the OpenVZ container must be restarted.
sudo mount -vt nfs nfs1:/exports/distro /opt/tmp
mount.nfs: timeout set for Fri May 4 00:28:56 2012
mount.nfs: trying text-based options 'vers=4,addr=192.168.2.202,clientaddr=192.168.2.79'
mount.nfs: mount(2): Protocol not supported
mount.nfs: trying text-based options 'addr=192.168.2.202'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 192.168.2.202 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=17
mount.nfs: trying 192.168.2.202 prog 100005 vers 3 prot UDP port 41964
As can be read NFSv4 is tried but fails so NFSv3 is used instead.
If NFS is important I would use a VM instead which is capable of delivering NFSv4 which have proper support for file locks and wait until OpenVZ supports NFSv4.