| <!-- |
| Documentation/_templates/layout.html |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. The |
| ASF licenses this file to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance with the |
| License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| License for the specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| |
| |
| <!DOCTYPE html> |
| <html class="writer-html5" lang="en" > |
| <head> |
| <meta charset="utf-8" /> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| |
| <title>NFS Client How-To — NuttX latest documentation</title> |
| |
| |
| |
| <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/tabs.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/custom.css" type="text/css" /> |
| |
| |
| |
| <link rel="shortcut icon" href="../_static/favicon.ico"/> |
| |
| |
| |
| |
| |
| |
| |
| |
| <!--[if lt IE 9]> |
| <script src="../_static/js/html5shiv.min.js"></script> |
| <![endif]--> |
| |
| |
| <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> |
| <script src="../_static/jquery.js"></script> |
| <script src="../_static/underscore.js"></script> |
| <script src="../_static/doctools.js"></script> |
| |
| <script type="text/javascript" src="../_static/js/theme.js"></script> |
| |
| |
| <link rel="index" title="Index" href="../genindex.html" /> |
| <link rel="search" title="Search" href="../search.html" /> |
| <link rel="next" title="USB Device Trace" href="usbtrace.html" /> |
| <link rel="prev" title="Guides" href="index.html" /> |
| </head> |
| |
| <body class="wy-body-for-nav"> |
| |
| |
| <div class="wy-grid-for-nav"> |
| |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-scroll"> |
| <div class="wy-side-nav-search" > |
| |
| |
| <a href="../index.html" class="icon icon-home"> NuttX |
| |
| |
| |
| |
| <img src="../_static/NuttX.png" class="logo" alt="Logo"/> |
| |
| </a> |
| |
| <!-- this version selector is quite ugly, should be probably replaced by something |
| more modern --> |
| |
| <div class="version-selector"> |
| <select onchange="javascript:location.href = this.value;"> |
| |
| <option value="../../latest" selected="selected">latest</option> |
| |
| <option value="../../10.0.0" >10.0.0</option> |
| |
| <option value="../../10.0.1" >10.0.1</option> |
| |
| <option value="../../10.1.0" >10.1.0</option> |
| |
| <option value="../../10.2.0" >10.2.0</option> |
| |
| <option value="../../10.3.0" >10.3.0</option> |
| |
| <option value="../../11.0.0" >11.0.0</option> |
| |
| <option value="../../12.0.0" >12.0.0</option> |
| |
| <option value="../../12.1.0" >12.1.0</option> |
| |
| <option value="../../12.2.0" >12.2.0</option> |
| |
| <option value="../../12.2.1" >12.2.1</option> |
| |
| <option value="../../12.3.0" >12.3.0</option> |
| |
| <option value="../../12.4.0" >12.4.0</option> |
| |
| <option value="../../12.5.0" >12.5.0</option> |
| |
| <option value="../../12.5.1" >12.5.1</option> |
| |
| <option value="../../12.6.0" >12.6.0</option> |
| |
| <option value="../../12.7.0" >12.7.0</option> |
| |
| <option value="../../12.8.0" >12.8.0</option> |
| |
| <option value="../../12.9.0" >12.9.0</option> |
| |
| <option value="../../12.10.0" >12.10.0</option> |
| |
| <option value="../../12.11.0" >12.11.0</option> |
| |
| </select> |
| </div> |
| |
| |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| |
| </div> |
| |
| |
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| |
| |
| |
| |
| |
| |
| <p class="caption"><span class="caption-text">Table of Contents</span></p> |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="../index.html">Home</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/index.html">Introduction</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../quickstart/index.html">Getting Started</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/inviolables.html">The Inviolable Principles of NuttX</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../platforms/index.html">Supported Platforms</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../components/index.html">OS Components</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../applications/index.html">Applications</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../reference/index.html">API Reference</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../faq/index.html">FAQ</a></li> |
| <li class="toctree-l1 current"><a class="reference internal" href="index.html">Guides</a><ul class="current"> |
| <li class="toctree-l2 current"><a class="current reference internal" href="#">NFS Client How-To</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#adding-nfs-to-the-nuttx-configuration">Adding NFS to the NuttX Configuration</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#mount-interface">Mount Interface</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#nfs-mount-command">NFS Mount Command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="#configuring-the-nfs-server-ubuntu">Configuring the NFS server (Ubuntu)</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="usbtrace.html">USB Device Trace</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="simulator.html">Simulator</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="drivers.html">Drivers</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="tasktrace.html">Task Trace</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="cpp_cmake.html">C++ Example using CMake</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="pysimcoder.html">pysimCoder integration with NuttX</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| |
| </div> |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| |
| |
| <nav class="wy-nav-top" aria-label="top navigation"> |
| |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="../index.html">NuttX</a> |
| |
| </nav> |
| |
| |
| <div class="wy-nav-content"> |
| |
| <div class="rst-content"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <div role="navigation" aria-label="breadcrumbs navigation"> |
| |
| <ul class="wy-breadcrumbs"> |
| |
| <li><a href="../index.html" class="icon icon-home"></a> »</li> |
| |
| <li><a href="index.html">Guides</a> »</li> |
| |
| <li>NFS Client How-To</li> |
| |
| |
| <li class="wy-breadcrumbs-aside"> |
| |
| |
| <a href="../_sources/guides/nfs.rst.txt" rel="nofollow"> View page source</a> |
| |
| |
| </li> |
| |
| </ul> |
| |
| |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <div class="section" id="nfs-client-how-to"> |
| <h1>NFS Client How-To<a class="headerlink" href="#nfs-client-how-to" title="Permalink to this headline">¶</a></h1> |
| <div class="section" id="adding-nfs-to-the-nuttx-configuration"> |
| <h2>Adding NFS to the NuttX Configuration<a class="headerlink" href="#adding-nfs-to-the-nuttx-configuration" title="Permalink to this headline">¶</a></h2> |
| <p>The NFS client is easily added to your configuration: You simply need to |
| add <code class="docutils literal notranslate"><span class="pre">CONFIG_NFS</span></code> to your <code class="docutils literal notranslate"><span class="pre">nuttx/.config</span></code> file. There are, however, a |
| few dependencies on other system settings:</p> |
| <p>First, there are things that you must configure in order to be able to |
| use any file system:</p> |
| <blockquote> |
| <div><ul class="simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_DISABLE_MOUNTPOINT=n</span></code>. You must include support for mount |
| points in the pseudo-file system.</p></li> |
| </ul> |
| </div></blockquote> |
| <p>And there are several dependencies on the networking configuration. At a |
| minimum, you need to have the following selections:</p> |
| <blockquote> |
| <div><ul class="simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_NET=y</span></code>. General networking support.</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_NET_UDP=y</span></code>. Support for UDP.</p></li> |
| </ul> |
| </div></blockquote> |
| </div> |
| <div class="section" id="mount-interface"> |
| <h2>Mount Interface<a class="headerlink" href="#mount-interface" title="Permalink to this headline">¶</a></h2> |
| <p>A low-level, C-callable interface is provided to mount a file system. |
| That interface is called <code class="docutils literal notranslate"><span class="pre">mount()</span></code> and is mentioned in the |
| porting guide and is prototyped in the header file <code class="docutils literal notranslate"><span class="pre">include/sys/mount.h</span></code>:</p> |
| <dl class="c function"> |
| <dt id="c.mount"> |
| <span class="pre">int</span> <code class="sig-name descname"><span class="pre">mount</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">const</span></em> <span class="pre">char</span> <span class="pre">*</span><em><span class="pre">source</span></em>, <em class="property"><span class="pre">const</span></em> <span class="pre">char</span> <span class="pre">*</span><em><span class="pre">target</span></em>, <em class="property"><span class="pre">const</span></em> <span class="pre">char</span> <span class="pre">*</span><em><span class="pre">filesystemtype</span></em>, <span class="pre">unsigned</span> <span class="pre">long</span> <em><span class="pre">mountflags</span></em>, <em class="property"><span class="pre">const</span></em> <span class="pre">void</span> <span class="pre">*</span><em><span class="pre">data</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.mount" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p><code class="docutils literal notranslate"><span class="pre">mount()</span></code> attaches the filesystem specified by the |
| <code class="docutils literal notranslate"><span class="pre">source</span></code> block device name into the root file system at the path |
| specified by <code class="docutils literal notranslate"><span class="pre">target</span></code>.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>source</strong> – A null-terminated string providing the fill path to a |
| block driver in the NuttX pseudo-file system.</p></li> |
| <li><p><strong>target</strong> – The location in the NuttX pseudo-file system where the |
| volume will be mounted.</p></li> |
| <li><p><strong>filesystemtype</strong> – A string identifying the type of file system to |
| use.</p></li> |
| <li><p><strong>mountflags</strong> – Various flags that can be used to qualify how the |
| file system is mounted.</p></li> |
| <li><p><strong>data</strong> – Opaque data that is passed to the file system with the |
| mount occurs.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p><p>Zero is returned on success; -1 is returned on an |
| error and <code class="docutils literal notranslate"><span class="pre">errno</span></code> is set appropriately:</p> |
| <ul class="simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">EACCES</span></code>. A component of a path was not searchable or mounting a |
| read-only filesystem was attempted without giving the <code class="docutils literal notranslate"><span class="pre">MS_RDONLY</span></code> |
| flag.</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">EBUSY</span></code>. <code class="docutils literal notranslate"><span class="pre">source</span></code> is already mounted.</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">EFAULT</span></code>. One of the pointer arguments points outside the user |
| address space.</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">EINVAL</span></code>. <code class="docutils literal notranslate"><span class="pre">source</span></code> had an invalid superblock.</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">ENODEV</span></code>. <code class="docutils literal notranslate"><span class="pre">filesystemtype</span></code> not configured</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">ENOENT</span></code>. A pathname was empty or had a nonexistent component.</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">ENOMEM</span></code>. Could not allocate a memory to copy filenames or data |
| into.</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">ENOTBLK</span></code>. <code class="docutils literal notranslate"><span class="pre">source</span></code> is not a block device</p></li> |
| </ul> |
| </p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <p>This same interface can be used to mount a remote, NFS file system using |
| some special parameters. The NFS mount differs from the <em>normal</em> file |
| system mount in that: (1) there is no block driver for the NFS file |
| system, and (2) special parameters must be passed as <code class="docutils literal notranslate"><span class="pre">data</span></code> to |
| describe the remote NFS server. Thus the following code snippet might |
| represent how an NFS file system is mounted:</p> |
| <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf"><sys/mount.h></span><span class="cp"></span> |
| <span class="cp">#include</span> <span class="cpf"><nuttx/fs/nfs.h></span><span class="cp"></span> |
| |
| <span class="k">struct</span> <span class="nc">nfs_args</span> <span class="n">data</span><span class="p">;</span> |
| <span class="kt">char</span> <span class="o">*</span><span class="n">mountpoint</span><span class="p">;</span> |
| |
| <span class="n">ret</span> <span class="o">=</span> <span class="n">mount</span><span class="p">(</span><span class="nb">NULL</span><span class="p">,</span> <span class="n">mountpoint</span><span class="p">,</span> <span class="n">string</span> <span class="s">"nfs"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="p">(</span><span class="n">FAR</span> <span class="kt">void</span> <span class="o">*</span><span class="p">)</span><span class="o">&</span><span class="n">data</span><span class="p">);</span> |
| </pre></div> |
| </div> |
| <p>NOTE that: (1) the block driver parameter is <code class="docutils literal notranslate"><span class="pre">NULL</span></code>. The <code class="docutils literal notranslate"><span class="pre">mount()</span></code> |
| is smart enough to know that no block driver is needed with the NFS file |
| system. (2) The NFS file system is identified with the simple string |
| “nfs” (3) A reference to <code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">nfs_args</span></code> is passed as an |
| NFS-specific argument.</p> |
| <p>The NFS-specific interface is described in the file |
| <code class="docutils literal notranslate"><span class="pre">include/nuttx/fs/nfs.h</span></code>. There you can see that <code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">nfs_args</span></code> |
| is defined as:</p> |
| <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="nc">nfs_args</span> |
| <span class="p">{</span> |
| <span class="kt">uint8_t</span> <span class="n">addrlen</span><span class="p">;</span> <span class="cm">/* Length of address */</span> |
| <span class="kt">uint8_t</span> <span class="n">sotype</span><span class="p">;</span> <span class="cm">/* Socket type */</span> |
| <span class="kt">uint8_t</span> <span class="n">flags</span><span class="p">;</span> <span class="cm">/* Flags, determines if following are valid: */</span> |
| <span class="kt">uint8_t</span> <span class="n">timeo</span><span class="p">;</span> <span class="cm">/* Time value in deciseconds (with NFSMNT_TIMEO) */</span> |
| <span class="kt">uint8_t</span> <span class="n">retrans</span><span class="p">;</span> <span class="cm">/* Times to retry send (with NFSMNT_RETRANS) */</span> |
| <span class="kt">uint16_t</span> <span class="n">wsize</span><span class="p">;</span> <span class="cm">/* Write size in bytes (with NFSMNT_WSIZE) */</span> |
| <span class="kt">uint16_t</span> <span class="n">rsize</span><span class="p">;</span> <span class="cm">/* Read size in bytes (with NFSMNT_RSIZE) */</span> |
| <span class="kt">uint16_t</span> <span class="n">readdirsize</span><span class="p">;</span> <span class="cm">/* readdir size in bytes (with NFSMNT_READDIRSIZE) */</span> |
| <span class="kt">char</span> <span class="o">*</span><span class="n">path</span><span class="p">;</span> <span class="cm">/* Server's path of the directory being mount */</span> |
| <span class="k">struct</span> <span class="nc">sockaddr_storage</span> <span class="n">addr</span><span class="p">;</span> <span class="cm">/* File server address (requires 32-bit alignment) */</span> |
| <span class="p">};</span> |
| </pre></div> |
| </div> |
| </div> |
| <div class="section" id="nfs-mount-command"> |
| <h2>NFS Mount Command<a class="headerlink" href="#nfs-mount-command" title="Permalink to this headline">¶</a></h2> |
| <p>The <a class="reference internal" href="../applications/nsh/nsh.html#nsh"><span class="std std-ref">NuttShell (NSH)</span></a> also supports a command called |
| <code class="docutils literal notranslate"><span class="pre">nfsmount</span></code> that can be used to mount a remote file system via the NSH |
| command line.</p> |
| <p><strong>Command Syntax:</strong></p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>fsmount <server-address> <mount-point> <remote-path> |
| </pre></div> |
| </div> |
| <p><strong>Synopsis</strong>. The <code class="docutils literal notranslate"><span class="pre">nfsmount</span></code> command mounts a network file system in |
| the NuttX pseudo filesystem. The <code class="docutils literal notranslate"><span class="pre">nfsmount</span></code> will use NFSv3 UDP |
| protocol to mount the remote file system.</p> |
| <p><strong>Command Line Arguments</strong>. The <code class="docutils literal notranslate"><span class="pre">nfsmount</span></code> takes three arguments:</p> |
| <blockquote> |
| <div><ol class="arabic simple"> |
| <li><p>The <code class="docutils literal notranslate"><span class="pre"><server-address></span></code> is the IP address of the server exporting |
| the file system you wish to mount. This implementation of NFS for the |
| NuttX RTOS is only for a local area network, so the server and client |
| must be in the same network.</p></li> |
| <li><p>The <code class="docutils literal notranslate"><span class="pre"><mount-point</span> <span class="pre">></span></code> is the location in the NuttX pseudo filesystem |
| where the mounted volume will appear. This mount point can only |
| reside in the NuttX pseudo filesystem. By convention, this mount |
| point is a subdirectory under <code class="docutils literal notranslate"><span class="pre">/mnt</span></code>. The mount command will create |
| whatever pseudo directories that may be needed to complete the full |
| path (but the full path must not already exist).</p></li> |
| <li><p>The <code class="docutils literal notranslate"><span class="pre"><remote-path></span></code> is the file system <code class="docutils literal notranslate"><span class="pre">/</span></code> directory being |
| exported from server. This <code class="docutils literal notranslate"><span class="pre">/</span></code> directory must have been configured |
| for exportation on the server before when the NFS server was set up.</p></li> |
| </ol> |
| </div></blockquote> |
| <p>After the volume has been mounted in the NuttX pseudo filesystem, it may |
| be access in the same way as other objects in the file system.</p> |
| <p><strong>Example</strong>. Suppose that the NFS server has been configured to export |
| the directory <code class="docutils literal notranslate"><span class="pre">/export/shared</span></code>. The the following command would mount |
| that file system (assuming that the target also has privileges to mount |
| the file system).</p> |
| <div class="highlight-fish notranslate"><div class="highlight"><pre><span></span>NuttShell <span class="o">(</span>NSH<span class="o">)</span> |
| nsh> ls /mnt |
| /mnt: |
| nsh: ls: no such directory: /mnt |
| nsh> nfsmount 10.0.0.1 /mnt/nfs /export/shared |
| nsh> ls -l /mnt/nfs |
| /mnt/nfs: |
| drwxrwxrwx <span class="m">4096</span> .. |
| drwxrwxrwx <span class="m">4096</span> testdir/ |
| -rw-rw-rw- <span class="m">6</span> ctest.txt |
| -rw-r--r-- <span class="m">15</span> btest.txt |
| drwxrwxrwx <span class="m">4096</span> . |
| nsh> <span class="k">echo</span> <span class="s2">"This is a test"</span> <span class="o">></span>/mnt/nfs/testdir/testfile.txt |
| nsh> ls -l /mnt/nfs/testdir |
| /mnt/nfs/testdir: |
| -rw-rw-rw- <span class="m">21</span> another.txt |
| drwxrwxrwx <span class="m">4096</span> .. |
| drwxrwxrwx <span class="m">4096</span> . |
| -rw-rw-rw- <span class="m">16</span> testfile.txt |
| nsh> cat /mnt/nfs/testdir/testfile.txt |
| This is a <span class="k">test</span> |
| </pre></div> |
| </div> |
| </div> |
| <div class="section" id="configuring-the-nfs-server-ubuntu"> |
| <h2>Configuring the NFS server (Ubuntu)<a class="headerlink" href="#configuring-the-nfs-server-ubuntu" title="Permalink to this headline">¶</a></h2> |
| <p>Setting up the server will be done in two steps: First, setting up the |
| configuration file for NFS, and then starting the NFS services. But |
| first, you need to install the nfs server on Ubuntu with these two |
| commands:</p> |
| <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp"># </span>sudo apt-get install nfs-common |
| <span class="gp"># </span>sudo apt-get install nfs-kernel-server |
| </pre></div> |
| </div> |
| <p>After that, we need to make or choose the directory we want to export |
| from the NFS server. In our case, we are going to make a new directory |
| called <code class="docutils literal notranslate"><span class="pre">/export</span></code>.</p> |
| <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp"># </span>sudo mkdir /export |
| </pre></div> |
| </div> |
| <p>It is important that <code class="docutils literal notranslate"><span class="pre">/export</span></code> directory allow access to everyone (777 |
| permissions) as we will be accessing the NFS share from the client with |
| no authentication.</p> |
| <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp"># </span>sudo chmod <span class="m">777</span> /export |
| </pre></div> |
| </div> |
| <p>When all this is done, we will need to edit the configuration file to |
| set up an NFS server: <code class="docutils literal notranslate"><span class="pre">/etc/exports</span></code>. This file contains a list of |
| entries; each entry indicates a volume that is shared and how it is |
| shared. For more information for a complete description of all the setup |
| options for this file you can check in the man pages (<code class="docutils literal notranslate"><span class="pre">man</span> <span class="pre">export</span></code>).</p> |
| <p>An entry in <code class="docutils literal notranslate"><span class="pre">/etc/exports</span></code> will typically look like this:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>directory machine1(option11,option12) |
| </pre></div> |
| </div> |
| <p>So for our example we export <code class="docutils literal notranslate"><span class="pre">/export</span></code> to the client 10.0.0.2 add the |
| entry:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>/export 10.0.0.2(rw) |
| </pre></div> |
| </div> |
| <p>In our case we are using all the default options except for the <code class="docutils literal notranslate"><span class="pre">ro</span></code> |
| that we replaced with <code class="docutils literal notranslate"><span class="pre">rw</span></code> so that our client will have read and write |
| access to the directory that we are exporting.</p> |
| <p>After we do all the require configurations, we are ready to start the |
| server with the next command:</p> |
| <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp"># </span>sudo /etc/init.d/nfs-kernel-server start |
| </pre></div> |
| </div> |
| <p>Note: If you later decide to add more NFS exports to the /etc/exports |
| file, you will need to either restart NFS daemon or run command |
| exportfs.</p> |
| <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp"># </span>sudo /etc/init.d/nfs-kernel-server start |
| </pre></div> |
| </div> |
| <p>Or</p> |
| <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp"># </span>exportfs -ra |
| </pre></div> |
| </div> |
| <p>Now we can check if the export directory and our mount point is properly |
| set up.</p> |
| <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp"># </span>sudo showmount -e |
| <span class="gp"># </span>sudo showmount -a |
| </pre></div> |
| </div> |
| <p>And also we can verify if NFS is running in the system with:</p> |
| <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp"># </span>rpcinfo –p |
| <span class="go">program vers proto port</span> |
| <span class="go"> 100000 2 tcp 111 portmapper</span> |
| <span class="go"> 100000 2 udp 111 portmapper</span> |
| <span class="go"> 100011 1 udp 749 rquotad</span> |
| <span class="go"> 100011 2 udp 749 rquotad</span> |
| <span class="go"> 100005 1 udp 759 mountd</span> |
| <span class="go"> 100005 1 tcp 761 mountd</span> |
| <span class="go"> 100005 2 udp 764 mountd</span> |
| <span class="go"> 100005 2 tcp 766 mountd</span> |
| <span class="go"> 100005 3 udp 769 mountd</span> |
| <span class="go"> 100005 3 tcp 771 mountd</span> |
| <span class="go"> 100003 2 udp 2049 nfs</span> |
| <span class="go"> 100003 3 udp 2049 nfs</span> |
| <span class="go"> 300019 1 tcp 830 amd</span> |
| <span class="go"> 300019 1 udp 831 amd</span> |
| <span class="go"> 100024 1 udp 944 status</span> |
| <span class="go"> 100024 1 tcp 946 status</span> |
| <span class="go"> 100021 1 udp 1042 nlockmgr</span> |
| <span class="go"> 100021 3 udp 1042 nlockmgr</span> |
| <span class="go"> 100021 4 udp 1042 nlockmgr</span> |
| <span class="go"> 100021 1 tcp 1629 nlockmgr</span> |
| <span class="go"> 100021 3 tcp 1629 nlockmgr</span> |
| <span class="go"> 100021 4 tcp 1629 nlockmgr</span> |
| </pre></div> |
| </div> |
| <p>Now your NFS sever is sharing <code class="docutils literal notranslate"><span class="pre">/export</span></code> directory to be accessed.</p> |
| </div> |
| </div> |
| |
| |
| </div> |
| |
| </div> |
| <footer> |
| <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> |
| <a href="usbtrace.html" class="btn btn-neutral float-right" title="USB Device Trace" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> |
| <a href="index.html" class="btn btn-neutral float-left" title="Guides" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> |
| </div> |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p> |
| © Copyright 2020, The Apache Software Foundation. |
| |
| </p> |
| </div> |
| |
| </footer> |
| </div> |
| </div> |
| |
| </section> |
| |
| </div> |
| |
| |
| <script type="text/javascript"> |
| jQuery(function () { |
| SphinxRtdTheme.Navigation.enable(true); |
| }); |
| </script> |
| |
| |
| |
| |
| |
| |
| </body> |
| </html> |