- I’ve always used
/etc/fstabfor auto-mounting things. When getting a new computer, I wanted to try something different (possibly because I always forget some step). Enter AutoFS.
- There are 3 shares on my NAS which I access via NFS that I want to mount to 3 separate folders on my PC.
- This is written from the perspective of Arch Linux using Systemd.
- I could not, for the life of me, get this to work in the way that is documented using this or this. Hence this post.
This is how they were when I was having issues with the error mentioned in the title:
# /etc/autofs/auto.master /- /etc/autofs/auto.nas --timeout=30 +dir:/etc/autofs/auto.master.d #+auto.master
# /etc/autofs/auto.nas share1 -rw,soft,intr,rsize=8192,wsize=8192,fstype=nfs4 NAS:/volume1/share1 share2 -rw,soft,intr,rsize=8192,wsize=8192,fstype=nfs4 NAS:/volume1/share2 share3 -rw,soft,intr,rsize=8192,wsize=8192,fstype=nfs4 NAS:/volume1/share3
Install some packages and run the
pacman -S --noconfirm nfs-utils rpcbind systemctl enable rpcbind systemctl start rpcbind && systemctl status rpcbind
AutoFS reads from a master config file @
/etc/autofs/auto.master . Here is mine, minus default comments:
/- /etc/autofs/auto.nas --timeout=600
A sub-file called
auto.nas is where the information for my 3 specific mount-points are. You’re essentially using the master file to point to any sub-files which contain the information for the mount points
/mnt/NAS/share1 -rw,soft,intr,rsize=8192,wsize=8192,fstype=nfs4 NAS:/volume1/share1 /mnt/NAS/share2 -rw,soft,intr,rsize=8192,wsize=8192,fstype=nfs4 NAS:/volume1/share2 /mnt/NAS/share3 -rw,soft,intr,rsize=8192,wsize=8192,fstype=nfs4 NAS:/volume1/share3
/etc/autofs/master.auto , there are three fields. The problem I had with trying to get this to work was with the first field. According to the Arch Wiki on AutoFS:
Alternatively, you can have autofs mount your media to a specific folder, rather than inside a common folder.
The way I read it, the Arch Wiki was written to recommend the following way of configuring the file. Supposedly it should have automatically mounted the 3 shares dynamically under
/mnt/NAS, if in
This is how I had originally written line 1 in
auto.master, written in the way that gave me problems
/mnt/NAS /etc/autofs/auto.nas --timeout=600
Which yields this error after restarting the
systemctl restart autofs && systemctl status autofs
Jun 18 17:17:24 host systemd: Started Automounts filesystems on demand. Jun 18 17:17:25 host automount: key "-" not found in map source(s).
/- as the first field in line 1 of
auto.master lets you explicitly set the absolute path for each of the three mount points as defined in
Having that value as the first field in the line that references the
auto.nas file is what resolved the error, and allowed me to access my NAS over NFS.