Mounting network shares with autofs (alternative to fstab) - General - OSMC (2024)

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

[EDIT 09/24/2020: Make sure that it’s browse, not --browse!]

(Don’t forget to save the file: CTRL-O ENTER CTRL-X)

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>

[EDIT 09/24/2020: Make sure that the mount point (/mnt/… does not end with a / )
For example, /mnt/server/share1/ will cause problems with autofs. The mounts will not automatically be unmounted if the mount point ends with a /. This is true for all of the following examples also.]

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. Some setups may require vers=3.1.1 to be used instead (possibly Synology users).
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:

username=<username> password=<password>

Note that the credentials in this file are read from the equals sign to a line feed. If you have any trailing spaces or a carriage return because you created it in, or copied it from a Windows PC then the file will not work. If you have special characters in your password you may need to place your username line after your password line.

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>

If your username or password includes a space then use quotes around it like this:

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

You don’t need quotes in a credentials file to deal with spaces. You can’t use escape characters in either file.

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. (Don’t forget to save the file: CTRL-O ENTER CTRL-X)

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 autofssudo automount -f -v -d

to debug what’s wrong. While this is running, it will appear to keep trying to mount. That’s normal. While automount is running, open another SSH connection and try:

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

again while watching the output from the automount command.

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

Using Path Substitution in case you want to keep old library

If you are migrating from Kodi build in Network access you might want to check out path substitution if you don’t want to rescan your library.

Mounting network shares with autofs (alternative to fstab) - General - OSMC (2024)
Top Articles
Welcome to CoinJar for non-UK residents
Women in Real Estate
Frases para un bendecido domingo: llena tu día con palabras de gratitud y esperanza - Blogfrases
Will Byers X Male Reader
Lowe's Garden Fence Roll
Moon Stone Pokemon Heart Gold
Brady Hughes Justified
Tesla Supercharger La Crosse Photos
Unitedhealthcare Hwp
Craigslist Parsippany Nj Rooms For Rent
Practical Magic 123Movies
Klustron 9
Elden Ring Dex/Int Build
Tlc Africa Deaths 2021
Learn How to Use X (formerly Twitter) in 15 Minutes or Less
About Goodwill – Goodwill NY/NJ
Gina's Pizza Port Charlotte Fl
World Cup Soccer Wiki
Bjork & Zhulkie Funeral Home Obituaries
Craigslist Sparta Nj
Dallas Craigslist Org Dallas
Grimes County Busted Newspaper
Happy Life 365, Kelly Weekers | 9789021569444 | Boeken | bol
Doublelist Paducah Ky
Suspiciouswetspot
fft - Fast Fourier transform
Cowboy Pozisyon
Pacman Video Guatemala
Maisons près d'une ville - Štanga - Location de vacances à proximité d'une ville - Štanga | Résultats 201
Login.castlebranch.com
Nurofen 400mg Tabletten (24 stuks) | De Online Drogist
Ilabs Ucsf
"Pure Onyx" by xxoom from Patreon | Kemono
Average weekly earnings in Great Britain
2015 Chevrolet Silverado 1500 for sale - Houston, TX - craigslist
Joplin Pets Craigslist
Exploring TrippleThePotatoes: A Popular Game - Unblocked Hub
Watchdocumentaries Gun Mayhem 2
Keeper Of The Lost Cities Series - Shannon Messenger
Enjoy4Fun Uno
Gun Mayhem Watchdocumentaries
M Life Insider
Gravel Racing
Sun Tracker Pontoon Wiring Diagram
Unit 11 Homework 3 Area Of Composite Figures
Air Sculpt Houston
The Complete Uber Eats Delivery Driver Guide:
Dicks Mear Me
Makes A Successful Catch Maybe Crossword Clue
Treatise On Jewelcrafting
Where Is Darla-Jean Stanton Now
Selly Medaline
Latest Posts
Article information

Author: Nathanial Hackett

Last Updated:

Views: 5841

Rating: 4.1 / 5 (72 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Nathanial Hackett

Birthday: 1997-10-09

Address: Apt. 935 264 Abshire Canyon, South Nerissachester, NM 01800

Phone: +9752624861224

Job: Forward Technology Assistant

Hobby: Listening to music, Shopping, Vacation, Baton twirling, Flower arranging, Blacksmithing, Do it yourself

Introduction: My name is Nathanial Hackett, I am a lovely, curious, smiling, lively, thoughtful, courageous, lively person who loves writing and wants to share my knowledge and understanding with you.