Guide For Setting Up Basic NFS Shares Using autofs

Configuring Autofs for NFS Shares on OpenMandriva

This guide explains how to configure autofs on OpenMandriva Rock 6.0 to automatically mount a basic NFS share, specifically using the example share1 from 0.0.0.0:/mnt/user/share1 at /mnt/share1, on a private home network. It addresses common issues like sample configuration files, the OPTIONS warning, and OpenMandriva’s autofs expecting the master map in /etc/autofs/auto.master. The steps can be adapted for other NFS shares. Look at the end for a shortcut to mounting multiple shares from the same server.

This guide encompasses every issue I had as a new Linux user getting this set up so you can avoid the issues I faced. I had to track this information down in multiple sources, especially the troubleshooting. It is not all-encompassing of every possibility, just how to get going with NFS share. It is working insanely well for me after significant testing.

0.0.0.0 = Your Server IP
share1 = Your NFS share
/mnt/user/share1 = The Path of Your Share
/mnt/share1 = The Directory You Wish To Mount The Share (I suggest within the /mnt/ folder)

Prerequisites

The NFS server (e.g., Unraid, Linux, NAS, Desktop, Laptop) at 0.0.0.0 exports the share /mnt/user/share1 with permissions allowing your network (e.g., 0.0.0.0/24(rw,async,no_subtree_check)).
Verify the export:

showmount -e 0.0.0.0

Expected output:Export list for 0.0.0.0:
/mnt/user/share1 0.0.0.0/24

###The above will tell you which NFS shares are available from that IP addreess and the exact path of your share on the server.

Ensure network connectivity:
ping 0.0.0.0

###To stop ping command use ctrl=+c

Step-by-Step Instructions
1. Install Required Packages

Install autofs and nfs-utils:
sudo dnf install autofs nfs-utils

###Read the output and type “y” if correct to install.

Verify installation:
rpm -q autofs nfs-utils

###There should be some output with the versions of these packages.

2. Create the Mount Point

Create the directory for the NFS share :

sudo mkdir -p /mnt/share1
sudo chown root:root /mnt/share1
sudo chmod 755 /mnt/share1

###(An additional subdirectory might be useful in the above example. If you are going to be mounting shares from multiple servers or multiple types of shares in the /mnt/ directory you could, for example, use /mnt/nfs/share1 or /mnt/server1/share1)

3. Handle Sample Configuration Files

The autofs package seems to include sample autofs files in /etc (e.g., /etc/auto.master, /etc/auto.nfs) that can cause conflicts. Back them up to avoid issues.

List files to check for them:
ls -l /etc/auto.*

Back up any existing files:

sudo mv /etc/auto.master /etc/auto.master.bak 2>/dev/null
sudo mv /etc/auto.nfs /etc/auto.nfs.bak 2>/dev/null
sudo mv /etc/auto.misc /etc/auto.misc.bak 2>/dev/null
sudo mv /etc/auto.net /etc/auto.net.bak 2>/dev/null
sudo mv /etc/auto.smb /etc/auto.smb.bak 2>/dev/null

###By using 2>/dev/null, any error messages produced by a command are redirected to /dev/null and not displayed on the terminal. This is useful when you want to run a command without seeing error messages, making the output cleaner. (optional)

Verify only .bak files remain:
ls -l /etc/auto.*

4. Configure Autofs

autofs expects the master map in /etc/autofs/auto.master. Configure it to mount the NFS share.

Create /etc/autofs/auto.master:

sudo mkdir -p /etc/autofs
sudo nano /etc/autofs/auto.master

Add:
/mnt/share1 /etc/autofs/auto.nfs

Save and exit (Ctrl+o, Enter, Ctrl+x in nano).

Create /etc/autofs/auto.nfs:
sudo nano /etc/autofs/auto.nfs

Add:
* -fstype=nfs,rw,vers=4 0.0.0.0:/mnt/user/share1

###The * wildcard maps the share directly to /mnt/share1.
###The vers=4 ensures compatibility with Unraid’s NFSv4. You may not need this for your setup or you may need a different version number.
Save and exit.

If you don’t need or want the wildcard:
share1 -fstype=nfs,rw,vers=4 0.0.0.0:/mnt/user/share1

Create /etc/autofs/autofs.conf:
sudo nano /etc/autofs/autofs.conf

Add:

[autofs]
timeout = 300
browse_mode = no

Save and exit. This sets a 5-minute unmount timeout and disables browse mode.

Set Permissions:

sudo chown root:root /etc/autofs/auto.master /etc/autofs/auto.nfs /etc/autofs/autofs.conf
sudo chmod 644 /etc/autofs/auto.master /etc/autofs/auto.nfs /etc/autofs/autofs.conf

5. Fix the OPTIONS Warning

The autofs systemd service references an unset OPTIONS variable by default, causing a warning. Override the service to remove it.

Edit the Systemd Service:
sudo systemctl edit autofs

Add:

[Service]
EnvironmentFile=
ExecStart=
ExecStart=/usr/bin/automount --systemd-service --dont-check-daemon

###You should be able to just uncomment the lines, they were already there for me.

Save and exit.

Reload Systemd:
sudo systemctl daemon-reload

6. Start and Enable Autofs

Enable and start autofs:
sudo systemctl enable --now autofs

Verify the service is running without the OPTIONS warning:
systemctl status autofs

7. Test the Mount

Access the mount point:

cd /mnt/share1
ls

You should see the share’s contents listed (e.g., Documents, Gaming, Music).

Verify the mount:
mount | grep share1

Expected:
0.0.0.0:/mnt/user/share1 on /mnt/share1 type nfs4 (rw,...)

8. Add Additional Shares (Optional)

To mount other NFS shares (e.g., share2, share3, share4, share5), edit /etc/autofs/auto.nfs:
sudo nano /etc/autofs/auto.nfs

Add:
* -fstype=nfs,rw,vers=4 0.0.0.0:/mnt/user/&

Note: The & wildcard matches the mount point name to the share name (e.g., /mnt/share2 mounts /mnt/user/share2).

Create mount points:

sudo mkdir -p /mnt/share2 /mnt/share3 /mnt/share4 /mnt/share5
sudo chown root:root /mnt/share2 /mnt/share3 /mnt/share4 /mnt/share5
sudo chmod 755 /mnt/share2 /mnt/share3 /mnt/share4 /mnt/share5

Restart autofs:
sudo systemctl restart autofs

Test each share:

cd /mnt/share2
ls

9. Troubleshooting

If the mount fails:

Check Logs:Enable debug logging:
sudo nano /etc/autofs/autofs.conf

Add:
logging = debug

Restart:
sudo systemctl restart autofs

View logs:
journalctl -u autofs -b

Verify NFS Server:
showmount -e 0.0.0.0

Test Manual Mount:
sudo mount -t nfs -o vers=4 0.0.0.0:/mnt/user/share1 /mnt/share1

Unmount after testing:
sudo umount /mnt/share1

Check RPC Services:

sudo systemctl enable --now rpcbind
systemctl status rpcbindshowmount -e

Firewall:

sudo firewall-cmd --add-service=nfs --permanent
sudo firewall-cmd --reload

Notes

The share mounts only when accessed and unmounts after 5 minutes of inactivity.
If the server’s export path changes, update /etc/autofs/auto.nfs with the path from showmount -e 0.0.0.0.
For Unraid NFS issues, check the web interface (Shares > share1 > NFS Settings) or edit /etc/exports via SSH:

ssh root@0.0.0.0
nano /etc/exports

Ensure:/mnt/user/share1 0.0.0.0/24(rw,async,no_subtree_check)

Apply:exportfs -ra

For more about autofs and what it can do see the arch Wiki: Autofs - ArchWiki

6 Likes