• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
KaliTut

KaliTut

Kali Linux tutorial and Linux system tips

  • Home
  • Raspberry Pi
  • Privacy Policy
  • About us

mount an NFS directory with autofs

Last Updated on May 28, 2020 by Kalitut Leave a Comment

Automatically mount/unmount an NFS directory with “autofs”

mount/unmount an NFS directory with "autofs"

The goal is to make an NFS-exported directory permanently available on a client. Normally this would be done by modifying the file “/ etc / fstab” so that the NFS directory is automatically included at system startup. However, “fstab” has the disadvantage that mounting fails if no network is available at system startup. Usually you create a script that hangs the directory only when a network connection was detected. Or you can enter the mount command in the file “/etc/rc.local”.

  • Setup NFS server on Raspberry Pi
  • MountĀ NFS share

But we want a solution that really works, while avoiding error-prone pull-ups. The establishment of NFS often fails because it does not permanently get the shares on the clients. Therefore we integrate the exported directory with the tool “autofs”.
With “autofs” partitions can be mounted automatically when needed and automatically unmount after a long period of non-use.

Note: autofs uses automount. In addition, the exported directory is always mounted on first access and not automatically at system startup. This is not a problem if you accept that there will be a short delay on first access.

Solution: Permanently mount NFS directory on a client

First, we need to install “autofs” on the client:

sudo apt-get install autofs

Then we create a map file:

sudo nano /etc/auto.nfs

There we enter the exported directory:

public -fstype = nfs, rw, retry = 0 192.168.1.2:/home/public

Then save and close the file.
Then we open the master file in which the map files are entered.

sudo nano /etc/auto.master

At the end of the file we add the following line:

/home/nfs/etc/auto.nfs

Then save and close the file.

Then the modified map file must be reloaded by a restart of “autofs”. It will be taken into account for future integration.

sudo service autofs restart

Now you can test if the exported directory is included.

mount

View of the directory:

ls /home/nfs/public

Here, the contents of the exported directory should be displayed by the NFS server. Make sure you have at least one file in it to see on the client if the mount worked. If the directory on the server is empty, you can not tell the difference between mounted and not mounted on the client.

Whether “autofs” really works, you can only check by restarting the client.

sudo reboot

As a rule, the shared directory should be available after the first access.

ls /home/nfs/public

Troubleshooting: NFS client
If the integration of the exported directories does not work, check if any NFS shares are available.

showmount -e 192.168.1.2

If so, then there may be a problem with “autofs”. To do this, check the syslog file, which may contain error messages about “automount”.

sudo cat /var/log/syslog | grep -i automount

Filed Under: Raspberry Pi Tagged With: NFS directory

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow us

  • Facebook
  • Twitter
  • YouTube

Categories

  • Android pentesting tools
  • Arduino
  • Books
  • Darknet
  • database
  • General
  • Github Tools
  • Hacking
  • Kali Linux
  • Linux
  • Linux Commands
  • Network Administrator
  • Penetration Testing
  • Penetration Testing Tools
  • PowerShell
  • Raspberry Pi
  • resources
  • Review
  • Termux
  • Tutorials
  • Ubuntu
  • Uncategorized
  • Video Tutorials
  • vmware
  • WiFi Adapter
  • WiFi Pentesting
  • Wireless Router
  • Wireshark

Recent Posts

  • Hijacked Wi-Fi? Thorough explanation of hacking techniques
  • Windows PowerShell tutorial for beginners
  • Learn to Hack Steps from Beginner to Hacker
  • PowerShell Tutorial – GUIDE introduction with basics
  • Top Hacking Tools
  • Home
  • About us
  • Privacy Policy
  • Affiliate disclaimer

Copyright © 2023