[HOW-TO] Mounting network shares with autofs (alternative to fstab)


This how-to describes how to mount your network shares via autofs. Autofs should be as performant as fstab based mounting but has the advantage that your shares are mounted on demand which also should give you more reliability in case of network interuptions.

First install the autofs package

sudo apt-get install autofs

If you already have mounted your shares already via fstab comment out that line in fstab and reboot.

For this how-to we are going to use a directory for each server, if you want to replicate your existing folder structure that can also be done.

autofs will create any mountpoints required, so you do not need to create them

Important notes to read before proceeding

  • When you see an item surrounded by < > do not include the < > in your file. For example if your server is MyServer, then /mnt/<server> would become /mnt/MyServer
  • If you have spaces in the name, then you need a \ before the space. For example /mnt/My Files should be /mnt/My\ Files
  • If you are migrating from using fstab, you were used to replacing spaces with \040. This will not work with autofs. Just a plain \ before the space is all that’s needed.

For SMB shares

sudo nano /etc/auto.master

and add to the end of the file:

 /- /etc/auto.smb.shares --timeout 15 browse

Next you need to create a map to the share:

sudo nano /etc/auto.smb.shares

and add

/mnt/<server1>/<share1> -fstype=cifs,rw,credentials=/home/osmc/.smbcredentials,iocharset=utf8,uid=osmc,gid=osmc ://<IP of server1>/<share1>/
/mnt/<server2>/<share2> -fstype=cifs,rw,credentials=/home/osmc/.smbcredentials,iocharset=utf8,uid=osmc,gid=osmc ://<IP of server2>/<share2>/

You may have to add an additional parameter to your /etc/auto.smb.shares , namely vers=3.0 to enforce the usage of SMB version 3 especially if you have connection issues with Windows 10.
We suggest the usage of a “credentials” file for security reasons.

This is what a credentials file should look like. (a good name for the file would be .smbcredentials) Create this file in the osmc home, so using nano:

nano ~/.smbcredentials

And add:


If you don’t want to use a credentials file use this instead:

/mnt/<server1>/<share1> -fstype=cifs,rw,username=<username>,password=<password>,iocharset=utf8,uid=osmc,gid=osmc ://<IP of server1>/<share1>/
/mnt/<server2>/<share2> -fstype=cifs,rw,username=<username>,password=<password>,iocharset=utf8,uid=osmc,gid=osmc ://<IP of server2>/<share2>/

For NFS:

As with smb, edit auto.master

sudo nano /etc/auto.master

and add

 /- /etc/auto.nfs.shares --timeout 15 browse

to the end of the file.

And for the map file we will be mounting several shares from 2 servers:

sudo nano /etc/auto.nfs.shares

and add:

/mnt/<server1>/<share1> <IP of server1>:</path/to/share1>
/mnt/<server2>/<share2> <IP of server2>:</path/to/share2>

If you’d like, you can always just mount them directly under /mnt (or anywhere else):

/mnt/<share1> <IP of server1>:</path/to/share1>
/mnt/<share2> <IP of server2>:</path/to/share2>

Testing the config:
After you have made the changes restart autofs:

sudo systemctl restart autofs

To test if your mounts works execute:

ls -lah /mnt/<server1>/<share1>

you should see the files from your network share. If it didn’t work run

sudo systemctl stop autofs
sudo automount -f -v -d

to debug what’s wrong.

To exit if running automount, just do a CTRL-C. To restart the service once everything is working, either reboot or:

sudo systemctl start autofs

Remount fstab shares on Vero 4k when connection is interrupted?
OSMC samba network
Can't seem to get autofs working
Reminder od how to auto mount on OSMC Forum please
Remount fstab shares on Vero 4k when connection is interrupted?
Intermittent, frequent video and audio stutter on some movies
Issues with Win 10 Samba shares with autofs on Vero 4K+
How are people mounting windows shares?
Can't See Over Network
Help please I think I messed up bad
Vero4K: want to use as PVR / view OTA broadcasting
4k hevc stutter through smb
Adding Repos
Adding Repos
Vero 4K+ freezes randomly
Vero 4K+ not turning on
Slow seeking and overall slow performance
Raspberry & Mycloud NAS failures
4K Buffering Issue on Vero 4K+
Setting up autofs help
How to connect to remote servers with SSH and Netatalk?
Trying to set up SMB Sharing for the first time
How to force fstab to work?
listed #2


I just had success using autofs to mount a remote sshfs share without root server access. I’ve bumped this thread in case others might find the solution useful.