Configuring fstab based NFS share mounts


#5

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:


#6

How can this be turned into a wiki entry?


#7

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.


#8

Good point. You need

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

#9

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.


#10

You want something like:

/mnt/mySharedDrive 192.168.1.0/24(sync,no_subtree_check)

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.


Best / fastest connection between 2 Vero 4k boxes
#11

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?


#12

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.


#14

Might need “wait for network” to be ticked


#15

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…


#16

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?


#17

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.


Vero 4K initial setup question
#19

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:

192.168.1.1:/media/USBDRIVE /mnt/USBDRIVE nfs noauto,x-systemd.automount 0 0

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

/media/USBDRIVE 192.168.1.0/24(rw,sync,no_subtree_check)

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?


#20

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?


#21

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


#22

No, I will try that one.


#23

But honestly, this is out of my league… :joy: Does anybody like @grahamh or @fzinken have any ideas?
It’s a setup I haven’t tried myself yet and technically the NFS server doesn’t need to wait for the network to be ready, but for the mount process of USB devices… How could that be forced to happen?


#24

So this is a matter of timing in the Vero. The NFS server won’t start if the mountpoint doesn’t exist. That’s why I mount my shared drive in /mnt. If you mkdir /mnt/USBDRIVE on the vero then /mnt/USBDRIVE is always there and NFS server will share it even it’s a bare directory. Then when it gets mounted (via fstab on the vero) you are good to go.


#25

OK, this is a good argument to mount the drive manually via fstab instead of relying on automount.

But then I will not be able to “remove safely” via Kodi File Manager anymore, right?


#26

Probably not. But you said you only want to do his occasionally so just power down.

Edit: You can ‘remove safely’ if you add users as an option in fstab and make sure no-one is connected to the drive. But you will still have to reboot to mount it again.