Resolution
In Parallels Virtuozzo Containers 4.x one may mount NFS share from within a container.Let us assume we have the container #101 based on CentOS OS. The steps outlined below will allow to mount share named as '/share' from the NFS server nfs.domain.com as '/mnt' from within the container #101.
First, for NFS mounts to work in containers you must load the module 'nfs' on the Virtuozzo hardware server itself:
# modprobe nfsThen, to allow a container to use NFS filesystem, you will need to start it with "nfs" feature enabled:
# vzctl set 101 --features nfs:on --save
# vzctl start 101If the container is running while you set the 'nfs' feature, you will need to restart it:
# vzctl restart 101After it is done you should see 'nfs' in the list of available filesystems inside the container #101:
# vzctl exec 101 cat /proc/filesystems
ext2
ext3
nodev rpc_pipefs
nodev autofs
nodev proc
nodev sysfs
nodev tmpfs
nodev devpts
nodev nfsNext, you need to install the packages 'nfs-utils' and 'nfs-utils-lib' in the container, it may be done using the utility 'yum':
# yum install nfs-utils nfs-utils-libNote: if you have Debian- or Ubuntu-based container then you need to install the package 'nfs-common' instead of 'nfs-utils' and 'nfs-utils-lib'. Use the utility 'apt-get':
# apt-get install nfs-commonNow you may mount NFS share from within the container #101:
- start the service 'portmap':
# /etc/init.d/portmap start- mount NFS share:
# mount -t nfs nfs.domain.com:/share /mntIn case you see error like this:
mount: mount to NFS server 'nfs.domain.com' failed: RPC Error: Program not registered.
please make sure that nfs server is running on nfs source node:
# /etc/init.d/nfs statusYou may also want to make service 'portmap' to start automatically when the container is booting, use the utility 'chkconfig':
# chkconfig --level 3 portmap onAnd finally, you may add the feature 'nfs' to every new Container you will create, it may be done using scripts 'vps.create' or 'vps.clone'. Please refer to this article for more details - How do I automate actions after container creating/cloning.
Keywords: NFS inside container