How do I enable NFS support in Virtuozzo?
Article ID: 873
Last Review: May,05 2008
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 VE, you may mount NFS share to the hardware node and then mount it into VE using so called 'bind' mount. This behavior will be changed in Virtuozzo 4.0, it will be possible to mount NFS shares from within VE directly.
Starting from Virtuozzo 3.0 SP1 you can manage bind mounts inside VEs 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 VE 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 VE #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 VE startup. Below are the sample scripts which map /mnt/data from the host to /mnt/data of VE #101. Please note the location of the scripts (/etc/sysconfig/vz-scripts) and script filenames.
- mount script, executed on VE #101 start (/etc/sysconfig/vz-scripts/101.mount):
#!/bin/sh
# Check if global Virtuozzo configuration and VE 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 VE #101 stop (/etc/sysconfig/vz-scripts/101.umount):
#!/bin/sh
# Check if global Virtuozzo configuration and VE 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 VE, say VE #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