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

KaliTut

Kali Linux tutorial and Linux Tips

  • Home
  • Raspberry Pi
  • Privacy Policy
  • About us
  • Affiliate disclaimer

mount an NFS directory with autofs

by

Automatically mount/unmount an NFS directory with “autofs”

mount/unmount an NFS directory with

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
Post Views: 531

Filed Under: Raspberry Pi Tagged With: NFS directory

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Follow us

  • Facebook
  • Twitter
  • YouTube

Categories

  • algorithm
  • Android Ai coding
  • Android pentesting tools
  • Arduino
  • Artificial Intelligence
  • Books
  • ChatGPT Prompt
  • 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

  • Shannon – The AI Pentesting Tool That Finds Real Exploits
  • Transforming Photos with ChatGPT Prompt : A Cinematic Double Exposure in a Post-Apocalyptic World
  • Stryker Android App: Your Mobile Pentesting Powerhouse
  • Alfa awus036ach review
  • Alfa AWUS1900 for Wireless Penetration Testing

Footer

Kalitut

Kalitut.com goal is to share the knowledge for free, help you find the best tools on the web and provides tutorials

Find us on social media

  • Facebook
  • Pinterest
  • Reddit
  • Twitter
  • YouTube

Copyright © 2026

  • Home
  • About us
  • Privacy Policy
  • Affiliate disclaimer