Configuring fstab based NFS share mounts

This tutorial is to help those who’d like to use NFS (Network File System - mostly used with Linux/Unix systems). It assumes that you already are sharing media files favourably on a NAS system that supports NFS shares (for how to setup NFS sharing e.g. on your NAS system, look for instructions by your system’s vendor).

Why use /etc/fstab instead of Kodi’s built in NFS client? Using /etc/fstab is faster than Kodi’s own NFS client - it delivers better throughput and is more reliable (also than SMB mounting). Many performance issues, especially with high-bitrate content can be solved by using NFS shares and /etc/fstab. Additionally, it’s quite easy to set up.

You will need to know the following information

  1. The IP address of the system where your media files are shared from.
  • For this tutorial, we will be using
  1. The directory used by the NFS share on your media sharing device (e.g. NAS).
  • We will be using /nfs (which is probably the standard path on many NAS).

  • please use the following command to find the correct export path for your NAS (if it’s NOT /nfs):

    showmount -e IP_of_your_NAS

  1. What you would like the share to be named on OSMC?
  • We will be using Server_Movies.
  • You may use any name here you’d like.
  1. Does the share name contain spaces?
  • Replace spaces with \040. So My Movies would be My\040Movies.

Once you know that information, log into your OSMC system via SSH: Accessing the command line - General - OSMC

Edit your /etc/fstab file:

sudo nano /etc/fstab

Go to the end of the file (use the down arrow key) and add this line: /mnt/Server_Movies        nfs     noauto,x-systemd.automount  0  0

An example with spaces: /mnt/TV\040Shows        nfs     noauto,x-systemd.automount  0  0

Once done editing /etc/fstab, save the file and exit nano /etc/fstab with CTRL+X and Y for “yes”.

Now verify that there are no errors in your fstab file:

sudo mount -a

You should just get a new prompt back. If you get any errors, look again at your /etc/fstab for any mistakes.

Once you get a prompt with no errors, you will need to reload systemd:

sudo systemctl daemon-reload
sudo systemctl restart

At this point, your shares should just work. To test, simply try to go to the share:

cd /mnt/Server_Movies

Or if you used the TV Shows example (TV\040Shows):

cd /mnt/TV\ Shows

Notice the difference! In the fstab file, you use \040 for a space. On the command line, you just use a \ followed by a space.

and if all is well, you will see your files!

If you do not see your files, try this:

sudo mount /mnt/Server_Movies

Or if you used the TV Shows example (TV\040Shows):

sudo mount /mnt/TV\ Shows

If you see errors, post your logs on the forum:

grab-logs -f -J

If everything is fine, you can add the NFS mount as a media source to Kodi. The path were the NFS mounts are found will always be this one:


When you follow this guide - especially the noauto,x-systemd.automount 0 0 part of the line that you add to /etc/fstab - the mount should be present before any library updating begins after a startup or in other words: as soon as the share is accessed. Keep this line as simple as possible! If no errors occur, don’t add any other commands!

Be aware: NFS mounting under FSTAB does not allow for a username and password to be set. The NFS share has to be configure e.g. on your NAS system so that it can be accessed via the path IP_of_your_NAS:/nfs (which we used as an example here, the /nfs part may be different for you) without any other configuration (than the one explained above) needed on the OSMC device. Make sure to configure your NAS or other media sharing device accordingly.

A hint to gather the information mentioned under “2.” in more words: Type in the command showmount -e IP_of_your_NAS into the command line of your OSMC device (via SSH). The output should show you the mount directories that your NAS offers. Choose the correct path that you’d like to mount via NFS FSTAB on your OSMC device and use that for the setup process above (the path would then replace /nfs under “2.”).


Nice job!

You are connecting to the directory /nfs on the NAS and I can’t see where a username is input. I don’t know how NASs are usually set up. Could you check that?

I’m just trying to translate from the way the setup process worked with my NAS here.

Yep, I see what you mean. Will change that.

The user on my NAS is calles nfs - which I created myself - and then had to add a number chain (something like 1000) belonging to that user (found under etc/passwd on my NAS) to the /nfs share directory (this had to be added under etc/exports on my NAS). So, the single nfs in the middle of the line /mnt/Server_Movies nfs noauto,x-systemd.automount 0 0 is that user or is that just giving the command in fstab to mount the directory as an NFS share?
I don’t know, if there’s a username specified in that line or whether the NFS share has to be enabled on the media sharing device to be accessible without username and password… What does the FSTAB line say about that?

Except for my case, I don’t know either. But all the info I found when I tried to figure out NFS FSTAB mounting was explaining it the way I then did it. So, the NFS share has to be accessible openly via the home network without a password. Just pointing to the device’s IP and the /nfs directory on that device should be enough when mounting the NFS share.

EDIT: I just cut out the part about username. Just wasn’t sure about that, but looking at the setup I’m using, there is no user to be set and definitely no password - at least not for the NFS access itself, only internally on the NAS to configure which shares should be visible when mounting /nfs. IMHO everything in the guide should be fine now and should explain the setup on the OSMC device to users who’d like to use NFS FSTAB mounts… Or did I miss anything else?

Honestly, I wouldn’t like to address the setup process on the media sharing device any more as that may vary from device to device and I’m not at all an expert on that. Users who’d like to use this should be able to figure that out for their own device…

That’s pretty much nailed it. Yes, the nfs in the middle of the fstab line is the filesystem type. The only thing I would do is add to the list of things you need to start with the address of the share on the server - in your case it’s /nfs but that may not be the same for everyone.

Very wise not dealing with how to set up the server - I’m sure they are all different!

PS: I think you are right there is no username/password authentication when accessing from linux to linux. IIRC when I first attached a nfs share to a Windows drive letter it did ask for a user and password though.

Good now?

From what I’ve read here in the forum, NFS on Windows is a whole different thing and probably best avoided. :joy: Also because of that issue… I’m pretty sure that I read that, although Windows would like to have a username and password, you can’t configure it in FSTAB. :man_shrugging:t2: Don’t even want to mention Windows in the guide to avoid trouble! :rofl:

1 Like

How can this be turned into a wiki entry?

1 Like

Fantastic guide, should definitely be added to the WIKI.
I would also like to see a wiki entry for:

  • how to share folders via NFS via fstab aka how to setup NFS server on OSMC.

My “NAS” will be my old RPi3, it runs OSMC. My mediacenter is now the Vero.
Thanks to this guide, I know how to setup the Vero (which will be a ‘client’) but no idea how to setup the Raspberry with OSMC. I suppose just add the correct entry to /etc/exports but I wasn’t sure if I need to install something first.

1 Like

Good point. You need

sudo apt-get update
sudo apt-get install nfs-kernel-server

Ha you were too quick, I just wanted to post that!

All that is left is to figure out the best/optimal et/exports entry with the right options, assuming you are indeed connecting 2 OSMC devices that are within your LAN/WLAN. Something like this:

sudo nano /etc/exports
Add this line, with the name of your usbdrive.

/media/yourusbdrive (rw,no_root_squash,no_subtree_check,insecure)

Not sure if “nosync” should be added.
In my case, the RPi3 (NFS server) has a NTFS usbdrive connected to it. I remember reading something in a long time ago “nosync” would be faster for NTFS drives on Linux. But perhaps that is only related to fstab and not etc/exports.

You want something like:


In the example, the drive mounted at /mnt/mySharedDrive is shared with any device on the 192.168.1.x subnet. Access will be read-only by default. For other sharing options refer to linux documentation for exportfs. I think the default is root_squash, sync minimises issues if disconnected but, yes, is slower if writing and no_subtree_check should speed things up, as I understand it.

I actually use no_root_squash beacuse I keep system backups on that nfs share which needs root permissions.

Thanks a lot! I didn’t know about the IP range.
But shouldn’t “rw” option always be present? To make sure you can read and write on the device?

If it’s just for media, ro should be enough and is the safest. Since there’s no authentication, using rw needs a bit of careful thought.

Might need “wait for network” to be ticked

In a “normal” scenario, I’d say no. This was an issue for me and keeping the line simple with exactly the above commands fixed the issue of the share not being mounted early enough. No “wait for network” was needed anymore.

As “wait for network” can have other effects, too, that are not very convenient, I’d try to always avoid it. And I’d definitely not want to recommend it to all users setting up NFS FSTAB…

I noticed you use /mnt/ instead of /media/
I understand automounted drives are in /media/ and permanently connected drives should be mounted manually via /etc/fstab in /mnt/.

What happens when I mount my USB drive via fstab in /mnt/, but select “remove safely” in Kodi? And replug the drive later? Should I add it to fstab again? Or will I no longer have the option in Kodi to remove safely if I mount via fstab?

This is about remote mounts which should be present or, let’s say, available all the time. These should be mounted to /mnt/. Removable drives like a USB drive are and should be automounted to /media/.

Why would you want to mount a USB drive manually to /mnt/ via fstab? I’d guess that fstab mounted removable drives wouldn’t show up as safely removable. But it’s just a guess, somebody more experienced has to comment on this.

Well the USB drive is connected permanently but I might remove it once or twice a year.

But strangely, mounting NFS doesn’t work anymore (I’m doing a new setup).
On a clean OSMC RPi3 with Kodi disabled (headless) I have this in my /etc/fstab: /mnt/USBDRIVE nfs noauto,x-systemd.automount 0 0

And on the Vero 4K (with IP with a usb drive attached, nfs server is installed, this is /etc/exports:


Strangely, this is the output on the client (RPi)

Ah, I see… This is a completely different scenario. It’s about sharing a USB drive connected to the Vero 4k to a RPi via NFS FSTAB?

Yes exactly.

BTW I notice when the Vero4K boots, it is unable to start the NFS server, because /media/USBDRIVE is not mounted yet automatically.

How can I make sure it waits for the USB drive to be mounted?

Have you enabled “wait for network” under MyOSMC/network?

No, I will try that one.