Difference between revisions of "NFS"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(formatting; punctuation; VE->container)
Line 1: Line 1:
This page describes how to mount NFS partition inside container.
+
This page describes how to mount NFS partition inside a container.
  
 
== NFS server ==
 
== NFS server ==
Line 26: Line 26:
 
==== Prepare the HN ====
 
==== Prepare the HN ====
  
For NFS mounts to work in the containers with the RHEL5-based kernels you must enable kernel threads in the container by setting "kernel.ve_allow_kthreads=1" in /etc/sysctl.conf
+
For NFS mounts to work in the containers with the RHEL5-based kernels you must enable kernel threads in the container by setting <code>kernel.ve_allow_kthreads=1</code> in <code>/etc/sysctl.conf</code>.
  
<pre>
+
# modprobe nfs
# modprobe nfs
 
</pre>
 
  
 
==== Prepare the container ====
 
==== Prepare the container ====
To allow a container use NFS filesystem, you will need to start it with "nfs" feature enabled. If the container is running while you set the --features "nfs:on", you will need to reboot it.
+
To allow a container to use NFS filesystem, you will need to start it with "nfs" feature enabled. If the container is running while you set the <code>--features nfs:on</code>, you will need to reboot it.
<pre>
+
 
# vzctl set 101 --features "nfs:on" --save
+
# vzctl set 101 --features "nfs:on" --save
# vzctl start 101
+
# vzctl start 101
</pre>
 
  
 
After this you may see nfs in <code>/proc/filesystems</code>
 
After this you may see nfs in <code>/proc/filesystems</code>
Line 53: Line 50:
  
 
=== Mounting NFS ===
 
=== Mounting NFS ===
Make sure that packages nfs-utils and nfs-utils-lib or similar are installed in VE.
+
Make sure that packages <code>nfs-utils</code> and <code>nfs-utils-lib</code> or similar are installed in a container.
  
Assuming that you already have NFS server set up at <code>192.168.0.1:/nfs_pub</code> mounting will be simple
+
Assuming that you already have NFS server set up at <code>192.168.0.1:/nfs_pub</code>, mounting will be simple
 
<pre>
 
<pre>
 
# vzctl enter 100
 
# vzctl enter 100
Line 68: Line 65:
 
</pre>
 
</pre>
  
For more details on how to setup NFS mount see [http://nfs.sourceforge.net/nfs-howto/ar01s04.html NFS-client HOWTO]
+
For more details on how to setup NFS mount, see [http://nfs.sourceforge.net/nfs-howto/ar01s04.html NFS-client HOWTO]
  
 
=== Known issues ===
 
=== Known issues ===
 
There are quite a few parameters in NFS, so sometimes it doesn't work due to misconfiguration. We've created a separate
 
There are quite a few parameters in NFS, so sometimes it doesn't work due to misconfiguration. We've created a separate
page describing those situations: [[ NFS doesn't work ]]
+
page describing such situations: [[NFS doesn't work]].
  
 +
== See also ==
 +
* [http://nfs.sourceforge.net/nfs-howto/ar01s04.html NFS-client HOWTO]
 
[[Category: HOWTO]]
 
[[Category: HOWTO]]

Revision as of 19:50, 8 April 2008

This page describes how to mount NFS partition inside a container.

NFS server

Currently OpenVZ kernel doesn't include kernel NFS server support. However you are still able to use user space NFS server inside container.

NFS client

Preparations

Prerequisites

You will need the following software:

  1. vzctl version 3.0.13 or higher (do vzctl --version)
  2. kernel version 2.6.18-028test006 or higher (2.6.18-028stab* will do), or any recent RHEL5-based or 2.6.20-based kernel.

Note: In all the kernels earlier than 028stab038, kernel NFS support can be given to a container by setting:

     sunrpc.ve_allow_rpc = 1
     fs.nfs.ve_allow_nfs = 1
     kernel.ve_allow_kthreads = 1

This can be done by adding the above lines into /etc/sysctl.conf on the hardware node, and then running sysctl -p.

Debian Notes

Debian Etch still uses vzctl version 3.0.11 and so NFS client support is not yet available. Lenny presently has version 3.0.18.

Prepare the HN

For NFS mounts to work in the containers with the RHEL5-based kernels you must enable kernel threads in the container by setting kernel.ve_allow_kthreads=1 in /etc/sysctl.conf.

# modprobe nfs

Prepare the container

To allow a container to use NFS filesystem, you will need to start it with "nfs" feature enabled. If the container is running while you set the --features nfs:on, you will need to reboot it.

# vzctl set 101 --features "nfs:on" --save
# vzctl start 101

After this you may see nfs in /proc/filesystems

# vzctl exec 101 cat /proc/filesystems
        ext3
        ext2
nodev   rpc_pipefs
nodev   proc
nodev   nfs
nodev   sysfs
nodev   tmpfs
nodev   devpts

Mounting NFS

Make sure that packages nfs-utils and nfs-utils-lib or similar are installed in a container.

Assuming that you already have NFS server set up at 192.168.0.1:/nfs_pub, mounting will be simple

# vzctl enter 100
# mkdir /nfs
# mount -t nfs 192.168.0.1:/nfs_pub /nfs
# cat /proc/mounts 
simfs / simfs rw 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw 0 0
nfs /nfs nfs rw,vers=3,rsize=32768,wsize=32768,hard,proto=tcp,timeo=600,retrans=2,sec=sys,addr=192.168.0.1 0 0

For more details on how to setup NFS mount, see NFS-client HOWTO

Known issues

There are quite a few parameters in NFS, so sometimes it doesn't work due to misconfiguration. We've created a separate page describing such situations: NFS doesn't work.

See also