<?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=Wizzy</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=Wizzy"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Wizzy"/>
	<updated>2026-06-10T04:39:42Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=NFS&amp;diff=10514</id>
		<title>NFS</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=NFS&amp;diff=10514"/>
		<updated>2011-06-07T13:29:51Z</updated>

		<summary type="html">&lt;p&gt;Wizzy: Bind mounts&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;
 # 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;
=== 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.&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;
&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>Wizzy</name></author>
		
	</entry>
</feed>