How do I enable NFS support in Virtuozzo?

Article ID: 873 
Last Review: Oct,6 2008
Author: Vitaly Filatov
Last updated by: system APPLIES TO:
  • Virtuozzo for Linux 3.x

Resolution

Since kernel 2.4.20-021stab028.18 (released in September, 2005) all versions of Virtuozzo kernel support NFS client. This means that you can mount NFS shares on a Virtuozzo hardware server.

NFS server is not supported by Virtuozzo kernel, you may use user-level NFS server software instead.

NFS client is not available from within a container, you may mount NFS share to the hardware node and then mount it into a container using so called 'bind' mount. This behavior will be changed in Virtuozzo 4.0, it will be possible to mount NFS shares from within a container directly.

Starting from Virtuozzo 3.0 SP1 you can manage bind mounts inside containers using the '--bindmount_add' option of the 'vzctl set' command.

Here is a basic examples on how one can map a resource from the host (actually any directory, including NFS mount point) to a container in Virtuozzo 3.x:

- mount a NFS share to the Virtuozzo server first:
# mount -t nfs nfsserver.test.com:/data /mnt/nfs/data


- map the share to the container #101 as /mnt/data:
# mkdir /vz/root/101/mnt/data
# mount --bind /mnt/nfs/data /vz/root/101/mnt/data


To simplify and automate the external mappings management, Virtuozzo action scripts can be used, so that the mounts are restored automatically on a container startup. Below are the sample scripts which map /mnt/data from the host to /mnt/data of the container #101. Please note the location of the scripts (/etc/sysconfig/vz-scripts) and script filenames.

- mount script, executed on the container #101 start (/etc/sysconfig/vz-scripts/101.mount):
#!/bin/sh

# Check if global Virtuozzo configuration and container configuration files exist
[ -f /etc/sysconfig/vz ] || exit 1
[ -f $VE_CONFFILE ] || exit 1

# Source both files. Note the order, it is important
source /etc/sysconfig/vz
source $VE_CONFFILE

mkdir -p $VE_ROOT/mnt/data && mount --bind /mnt/data $VE_ROOT/mnt/data
exit 0


- unmount script, executed on the container #101 stop (/etc/sysconfig/vz-scripts/101.umount):
#!/bin/sh

# Check if global Virtuozzo configuration and container configuration files exist
[ -f /etc/sysconfig/vz ] || exit 1
[ -f $VE_CONFFILE ] || exit 1

# Source both files. Note the order, it is important
source /etc/sysconfig/vz
source $VE_CONFFILE

umount $VE_ROOT/mnt/data
exit 0


To use the script for other container, say the container #102, just copy the action scripts and edit the directories you want to mount, if needed:
# cp /etc/sysconfig/vz-scripts/101.mount /etc/sysconfig/vz-scripts/102.mount
# cp /etc/sysconfig/vz-scripts/101.umount /etc/sysconfig/vz-scripts/102.umount
Keywords: nfs,enterprise,kernel, bind mount, bindmount_add


Subscription for this article changesSubscription for this article changes

Please provide feedback on this article

Did this article help you solve your issue?
Yes
No
Partially
I do not know yet
 
Strongly Agree   Strongly Disagree
  9 8 7 6 5 4 3 2 1
The article is easy to understand
The article is accurate
Additional Comments:
*Please provide us with your email address in case we need to contact you.
* - required fields