Sunday, April 16, 2017

Idiosyncrasies of ${HOME} that is an NFS Share

NFS is perhaps best for more 'permanent' network mounted directories such as /homedir or regularly accessed shared resources.  In this article, we will cover the following topics:
  • Set up NFS share via automounter
  • Idiosyncrasies of  /homedir that is an NFS share 


One drawback to using /etc/fstab is that, regardless of how infrequently a user accesses the NFS mounted file system, the system must dedicate resources to keep the mounted file system in place. This is not a problem with one or two mounts, but when the system is maintaining mounts to many systems at one time, overall system performance can be affected.

An alternative to /etc/fstab is to use the kernel-based automount utility.  An automounter consists of two components:[1]
  • A kernel module
    • implements a file system
  • A user-space daemon
    • performs all of the other functions

The automount utility can mount and unmount NFS file systems automatically (on demand mounting) therefore saving system resources. The automount utility can be used to mount other file systems including AFS, SMBFS, CIFS and local file systems.


When your home directory is automounted, it has different behaviors than other file systems due to its sharing.  For example, you could run into the following two issues:
  • cp: cannot stat  "": Permission denied[2]
  • ".bashrc" E509: Cannot create backup file (add ! to override)"
In the below sections, we will discuss these two issues in more details.

cp: cannot stat "" : Permission denied

In [2], the author has described an issue in which she has tried to copy a file from her home directory to /usr:
$ chmod 777
$ cp /usr/keepass/
cp: cannot create regular file `/usr/keepass/': Permission denied
$ sudo cp /usr/keepass/
cp: cannot stat `': Permission denied
However, sudo cp can't statKeePass-2.14.zi because${HOME} is on an NFS mount and the NFS server doesn't grant your machine root permission to the NFS share.

To workaround this "cannot stat: Permission denied" issue, you need to copy the file to another directory (e.g., /tmp) first:
cp /tmp
sudo cp /tmp/ /usr/keepass/

".bashrc" E509: Cannot create backup file (add ! to override)"

One time when I edited and saved my $HOME/.bashrc, the system has thrown the following message:

".bashrc" E509: Cannot create backup file (add ! to override)"
Then I used "df" command to find the disk space available on my homedir:

$ df -h .
Filesystem            Size  Used Avail Use% Mounted on
                      5.0T  1.4T  3.7T  28% /home/myusername
It showed that there were still plenty of space.  However, because ${HOME} is NFS shared for the home directories of many others, every user has been assigned a disk quota.  To find out how much quota you have been assigned for your homedir, you can run:

$ quota -Q -s
Disk quotas for user myusername (uid 40000):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace

                  1624M   2048M   2048M               0       0       0

So, to resolve this issue, you can simply remove other junk files form the homedir to gain some disk space for saving the file.


  1. autofs
  2. How to copy a file from my home folder to /usr
  3. Automount mini-Howto
  4. How to configure autofs in Linux and what are its advantages?
  5. Is it feasible to have home folder hosted with NFS?

No comments: