58

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?

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

2 Answers 2

101

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.
2
  • 1
    Is there any advantage with -ra instead of only -r?
    – mvorisek
    Jan 5, 2018 at 0:45
  • 1
    @Mvorisek - it's explicit.
    – slm
    Jan 5, 2018 at 16:04
0

I was also wondering if it was necessary to restart, but after some research, I understood that in my case I didn't need to restart, just the export as detailed below.

For reference, the step-by-step procedure I performed:

  • needed to get remote access to a folder on another server;
  • include "remote_server_ip:/remote_name_folder" in /etc/fstab file;
  • after that, to mount and connect to the remote server, I ran the command "sudo mount -a";
  • at that moment the error message appeared "mount.nfs4: access denied by server while mounting remote_server_ip:/remote_name_folder";
  • I joined the remote server and configured the ip of the machine that needed access in the /etc/exports file;
  • I exported the accesses using the command "exportfs -av";
  • I went back on the machine that needed access and re-ran the command "sudo mount -a";

So my problem was solved.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .