updated 2017-1205
After rebooting my Ubuntu server, I sometimes am unable to mount my NFS shares on the server from my desktop or laptop (debian 9.0 or Ubuntu 17.10). The NFS shares are automatically mounted at boot through the file /etc/fstab. I think the problem is that the server gets a new file handle for the share and the desktop machine still has the old file handle and it gets rejected by the server. Here is my solution and all commands are run from the command line. Command line commands will look like this sentence.
- show mounted filesystems from the client computer
- $ df -h
- output: df: ‘/mnt/nfs/backup.serv’: Stale file handle
- If the file system is mounted, I now need to unmount the share with the old file handle and then mount the share with new file handle. Remounting the share will cause the destop client to get the new updated file handle from the server.
- sudo umount -v /mnt/nfs/backup.serv
- If the file system is not mounted
- Try exporting the file system from the server
- exportfs -vf
- exportfs -vra
- I put this in a crontab on server and have it export every 15 minutes. Open the crontab editor with the following command
- sudo crontab -e
- Insert the next two lines
- # rexport nfs shares every 15 minutes
- */15 * * * * exportfs -ra
- From the client, try to mount the nfs share
- sudo mount -av
- If the above does not work then restart the nfs-kernel-server on the nfs file server. See section restarting nfs-kernel-server
- Try exporting the file system from the server
- If the file system is mounted, I now need to unmount the share with the old file handle and then mount the share with new file handle. Remounting the share will cause the destop client to get the new updated file handle from the server.
- output: df: ‘/mnt/nfs/backup.serv’: Stale file handle
- $ df -h
- Mounting nfs share from client
- /media/chad/backup.serv is the mount point for my NFS share
- Have the client mount all file systems
- $ sudo mount -av
- -a mounts all file systems in fstab that are not mounted
- $ sudo mount -av
- show mounted file systems
- $ df -h
- output: 192.xxx.xxx.xxx:/media/backup.serv 1.8T 913G 828G 53% /media/chad/backup.serv
- $ df -h
Restarting nfs-kernel-server
-
- If you are getting the error “mount.nfs: mount(2): Stale file handle” on your client when you try to mount your nfs mount, then you need to restart the nfs-kernel-server from the server.
- ssh into the server
- run restart command (debian or ubuntu)
- $ sudo service nfs-kernel-server restart
- from the client, remount the nfs partition
Miscellaneous
Good information about the problem and I script to find stale nfs file handles at http://serverfault.com/questions/617610/stale-nfs-file-handle-after-reboot