25

I have NFSv4 Server (on RHELv6.4) and NFS Clients on (CentOSv6.4). Let's say in /etc/exports:

/shares/website1      <ip-client-1>(rw,sync,no_subtree_check,no_root_squash)
/shares/website2      <ip-client-2>(rw,sync,no_subtree_check,no_root_squash)

Then whenever i made some changes in that (let's say the changes ONLY for client-2), e.g:

/shares/website1      <ip-client-1>(rw,sync,no_subtree_check,no_root_squash)
/shares/xxxxxxxx      <ip-client-2>(rw,sync,no_subtree_check,no_root_squash)

Then i always service nfs restart. And then eventually .. the mount-point on client-1 got unresponsive (Can't open its files, etc). (Why? Because of RESTART?)

But as described, i only modified the line for client-2 only. Everything for the client-1 are still untouched.

So my questions here are:

  • Whenever i modify the /etc/exports, should i restart the service or what?
  • If i service nfs restart, why the Mount-Point on other Clients are eventually affected? (For those Client Machines with NO changes made in /etc/exports for them.)

That means, whenever i make the changes in /etc/exports and restart the service, i will need to go RE-MOUNT the directories on EVERY CLIENTS in the export list, in order to have the mount-points working again.

Any idea, please?

  • 1
    After modifying /etc/exports, try just running, as root, exportfs -ra. See man exportfs for details. – John1024 Feb 26 '14 at 2:50
  • Then i wouldn't need nfs restart anymore? – 夏期劇場 Feb 26 '14 at 3:13
44

You shouldn't need to restart NFS every time you make a change to /etc/exports. All that's required is to issue the appropriate command after editing the /etc/exports file:

$ exportfs -ra

Excerpt from the official Red Hat documentation titled: 21.7. The /etc/exports Configuration File.

excerpt

When issued manually, the /usr/sbin/exportfs command allows the root user to selectively export or unexport directories without restarting the NFS service. When given the proper options, the /usr/sbin/exportfs command writes the exported file systems to /var/lib/nfs/xtab. Since rpc.mountd refers to the xtab file when deciding access privileges to a file system, changes to the list of exported file systems take effect immediately.

Also read the exportfs man page for more details, specifically the "DESCRIPTION" section which explains all this and more.

DESCRIPTION An NFS server maintains a table of local physical file systems that are accessible to NFS clients. Each file system in this table is referred to as an exported file system, or export, for short.

  The exportfs command maintains the current table of exports for the NFS 
    server.  The master export table is kept in  a  file  named
    /var/lib/nfs/etab.  This file is read by rpc.mountd when a client sends 
    an NFS MOUNT request.

  Normally  the  master  export  table  is  initialized  with the contents 
    of /etc/exports and files under /etc/exports.d by invoking exportfs -a.  
    However, a system administrator can choose to add or delete exports 
    without modifying  /etc/exports  or  files  under /etc/exports.d by 
    using the exportfs command.

Also take note of the options we're using, -ra:

   -a     Export or unexport all directories.
   -r     Reexport all directories, synchronizing /var/lib/nfs/etab with 
          /etc/exports and files  under  /etc/exports.d.   This  option
          removes  entries  in  /var/lib/nfs/etab which have been deleted 
          from /etc/exports or files under /etc/exports.d, and removes
          any entries from the kernel export table which are no longer
          valid.
  • Is there any advantage with -ra instead of only -r? – Mvorisek Jan 5 '18 at 0:45
  • @Mvorisek - it's explicit. – slm Jan 5 '18 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.