<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dsafonov</id>
	<title>OpenVZ Virtuozzo Containers Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dsafonov"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Dsafonov"/>
	<updated>2026-06-11T00:14:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=NFS&amp;diff=19728</id>
		<title>NFS</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=NFS&amp;diff=19728"/>
		<updated>2016-06-17T12:58:31Z</updated>

		<summary type="html">&lt;p&gt;Dsafonov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes how to use '''NFS client''' inside a container.&lt;br /&gt;
&lt;br /&gt;
{{Note|see [[NFS server inside container]] for info about nfsd.&lt;br /&gt;
&lt;br /&gt;
Mounting filesystems from the '''hardware node''' can be performed more elegantly using [[Bind mounts]].}}&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
You will need the following software:&lt;br /&gt;
&lt;br /&gt;
# vzctl version 3.0.13 or higher (do &amp;lt;code&amp;gt;vzctl --version&amp;lt;/code&amp;gt;)&lt;br /&gt;
# 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.&lt;br /&gt;
&lt;br /&gt;
Note: In all the kernels earlier than 028stab038, kernel NFS support can be given to a container by setting:&lt;br /&gt;
&lt;br /&gt;
      sunrpc.ve_allow_rpc = 1&lt;br /&gt;
      fs.nfs.ve_allow_nfs = 1&lt;br /&gt;
      kernel.ve_allow_kthreads = 1&lt;br /&gt;
&lt;br /&gt;
This can be done by adding the above lines into /etc/sysctl.conf on the hardware node, and then running &amp;lt;code&amp;gt;sysctl -p&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the HN ===&lt;br /&gt;
&lt;br /&gt;
For NFS mounts to work in the containers with the RHEL5-based kernels you must enable kernel threads in the container by setting &amp;lt;code&amp;gt;kernel.ve_allow_kthreads=1&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;/etc/sysctl.conf&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
RHEL7-based kernels support [https://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-nfs.html three different NFS protocol versions]:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NFS version 2 (NFSv2) is older and is widely supported.&lt;br /&gt;
NFS version 3 (NFSv3) has more features, including 64bit file handles, Safe Async writes and more robust error handling.&lt;br /&gt;
NFS version 4 (NFSv4) works through firewalls and on the Internet, no longer requires portmapper, supports ACLs, and utilizes stateful operations.&lt;br /&gt;
Red Hat Enterprise Linux supports NFSv2, NFSv3, and NFSv4 clients, and when mounting a file system via NFS, Red Hat Enterprise Linux uses NFSv3 by default, if the server supports it.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
There are three kernel modules accordingly: &amp;lt;code&amp;gt;nfs&amp;lt;/code&amp;gt; (for NFSv2), &amp;lt;code&amp;gt;nfsv3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;nfsv4&amp;lt;/code&amp;gt;. As [[NFS server inside container]] by this moment supports only NFSv3, it's very likely that you'll need to load &amp;lt;code&amp;gt;nfsv3&amp;lt;/code&amp;gt; module for clients.&lt;br /&gt;
&lt;br /&gt;
 # modprobe nfs&lt;br /&gt;
&lt;br /&gt;
You will probably want the nfs module to load automatically on reboots.  One way to do this is to put the modprobe  command in your /etc/rc.d/rc.local file:&lt;br /&gt;
&lt;br /&gt;
  modprobe nfs&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can add a new line with &amp;lt;code&amp;gt;nfs&amp;lt;/code&amp;gt; to your /etc/modules or /etc/modules.conf file.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the container ===&lt;br /&gt;
To allow a container to use NFS filesystem, you will need to start it with &amp;quot;nfs&amp;quot; feature enabled. If the container is running while you set the &amp;lt;code&amp;gt;--features nfs:on&amp;lt;/code&amp;gt;, you will need to reboot it.&lt;br /&gt;
&lt;br /&gt;
 # vzctl set 101 --features &amp;quot;nfs:on&amp;quot; --save&lt;br /&gt;
 # vzctl start 101&lt;br /&gt;
&lt;br /&gt;
After this you may see nfs in &amp;lt;code&amp;gt;/proc/filesystems&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl exec 101 cat /proc/filesystems&lt;br /&gt;
        ext3&lt;br /&gt;
        ext2&lt;br /&gt;
nodev   rpc_pipefs&lt;br /&gt;
nodev   proc&lt;br /&gt;
nodev   nfs&lt;br /&gt;
nodev   sysfs&lt;br /&gt;
nodev   tmpfs&lt;br /&gt;
nodev   devpts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mounting NFS ==&lt;br /&gt;
Make sure that packages &amp;lt;code&amp;gt;nfs-utils&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;nfs-utils-lib&amp;lt;/code&amp;gt; or similar are installed in a container.  Also make sure that the &amp;lt;code&amp;gt;portmap&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;rpcbind&amp;lt;/code&amp;gt;) service is started, otherwise the mount with default options will fail and require the &amp;lt;code&amp;gt;-nolock&amp;lt;/code&amp;gt; option.  See the [[NFS#Known issues|known issues]] for more information.&lt;br /&gt;
&lt;br /&gt;
Assuming that you already have NFS server set up at &amp;lt;code&amp;gt;192.168.0.1:/nfs_pub&amp;lt;/code&amp;gt;, mounting will be simple&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl enter 100&lt;br /&gt;
# mkdir /nfs&lt;br /&gt;
# mount -t nfs 192.168.0.1:/nfs_pub /nfs&lt;br /&gt;
# cat /proc/mounts &lt;br /&gt;
simfs / simfs rw 0 0&lt;br /&gt;
proc /proc proc rw 0 0&lt;br /&gt;
sysfs /sys sysfs rw 0 0&lt;br /&gt;
devpts /dev/pts devpts rw 0 0&lt;br /&gt;
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&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more details on how to setup NFS mount, see [http://nfs.sourceforge.net/nfs-howto/ar01s04.html NFS-client HOWTO]&lt;br /&gt;
&lt;br /&gt;
== Known issues ==&lt;br /&gt;
* 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]].&lt;br /&gt;
* Package nfs-common can not be installed. Make sure you start &amp;lt;code&amp;gt;portmap&amp;lt;/code&amp;gt; before trying to install nfs-common.&lt;br /&gt;
** For Ubuntu/Debian OpenVZ containers, the &amp;lt;code&amp;gt;portmap/rpcbind&amp;lt;/code&amp;gt; service may not start automatically. However, you can enable it by editing the &amp;lt;code&amp;gt;/etc/default/nfs-common&amp;lt;/code&amp;gt; configuration file.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://nfs.sourceforge.net/nfs-howto/ar01s04.html NFS-client HOWTO]&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;/div&gt;</summary>
		<author><name>Dsafonov</name></author>
		
	</entry>
</feed>