Setting NFS server in OSMC to share USB drives

I’ve spent a couple of days trying to share a USB hard drive or flash drive connnected to my RPi 2 (the drive is being recognized correctly) with NFS, with no good results. I am using nfs-kernel-server service, and exports like this:

/media/-mounted drive name here- 192.168.1.0/255.255.255.0(rw,insecure,no_root_squash,subtree_check)

following different threads, but based mostly in this RPi forum. I am using RC2. When I go to a windows PC I have with Kodi 13.2, NFS are not detected. I have to write down the address nfs://192.168.1.115/ (my Pi’s address), and the source is added. When I try to browse it, all I get is the /media/-name-, but no access to any file, or any error message.

I’ve tryed sharing /home/osmc folder, and I can see all the home subdirectories folders with no problem. Seems to be a user permission issue, but cannot figure out so far. Is it possible to share folders that are not in the home folder, like media or a mounting point? I want to use the Pi as media center and some kind of NAS, to share all my files with other devices (tablets, PC’s and maybe other Pi’s later) with Kodi.

You should start by mounting your drives in /mnt/ as anything mounted in /media/ is temporary. Possible that there is nothing in /media/ yet when nfs tries to share it.

Create your directory in /mnt/ , edit /etc/fstab to mount your drive there, set your /etc/exports to share the directory you created in /mnt/.

Sidenote: That line you’re adding into /etc/exports in your post above would make that nfs share only accessible from one IP address (192.168.1.0). Consider changing it to something like this to rule out some problems until you get it working:

/mnt/Main 192.168.1.0/24(rw,sync,no_subtree_check,insecure)
1 Like

I already tried mounting the drive, but it is already mouted by OSMC and OS would not allow me to mount it twice. Unmount command is not present, I do not know what Sam is using for automonting USB drives to /media/ as they can be unmounted from Kodi. As is already mounted, I’ve tried sharing the mounted drive in /media/, when already mounted so NFS should be seeing it.

To your sidenote, the subnet mask after the IP is supposed to be allowing to all IP’s in that range to be able to connect, and I’ve tried both methods, but you are correct, I will try it just to make sure is working before opening the range.

Uh, yes it is, it’s called umount, like all other Linux distributions…

osmc@osmc:~$ umount

Usage:
 umount [-hV]
 umount -a [options]
 umount [options] <source> | <directory>

Options:
 -a, --all               unmount all filesystems
 -A, --all-targets       unmount all mountpoints for the given device in the
                           current namespace
 -c, --no-canonicalize   don't canonicalize paths
 -d, --detach-loop       if mounted loop device, also free this loop device
     --fake              dry run; skip the umount(2) syscall
 -f, --force             force unmount (in case of an unreachable NFS system)
 -i, --internal-only     don't call the umount.<type> helpers
 -n, --no-mtab           don't write to /etc/mtab
 -l, --lazy              detach the filesystem now, clean up things later
 -O, --test-opts <list>  limit the set of filesystems (use with -a)
 -R, --recursive         recursively unmount a target with all its children
 -r, --read-only         in case unmounting fails, try to remount read-only
 -t, --types <list>      limit the set of filesystem types
 -v, --verbose           say what is being done

 -h, --help     display this help and exit
 -V, --version  output version information and exit

We use udisks, with udisks-glue. See /etc/udisks-glue.conf. Drives automounted by udisks can be unmounted with the standard umount command. (Or using the udisks command line tool itself)

Have you run updates today ? We have pushed most of RC3 and among the changes are changes to the udisks-glue.conf and the permissions that drives auto mount in /media with. (Permissions were too restrictive before on exfat, fat32 and ntfs)

If not try running an update and see if you are still having the same problem with the drive when mounted under /media.

Thank you DBMandrake, I did ran the update yesterday, but let me do it one more time as I may not got RC3. Weird, I tried unmount (and also man to see help) and the output was “command not present”, hopefully it was just my mistake.

Should I run “sudo apt-get update” or do it from MyOSMC update, or are they the same?

Edit: By the way, my USB flash drive filesystem is FAT32 and I tried also with a HDD in NTFS with a cheap USB so SATA converter.

Edit 2: Just saw for a second time the unmount command… UMOUNT! I am sorry, I knew I was doing something wrong. Let me try it this when I get back to home this afternoon, I’ll reply back. Thanks again!

RC3 was only pushed in the early hours of this morning so if you updated yesterday you won’t have it. Either check through MyOSMC or

sudo apt-get update && sudo apt-get dist-upgrade

I’ve had just a short time to try it, but I was able only to unmount the flash drive from media, and mounting it into /mnt/ the files were accessible with “ls /mnt/hdd/”. Changed exports to:

/mnt/hdd 192.168.1.127/24(rw,no_root_squash,no_subtree_check,insecure)

And my android Kodi app was able to see the path change immediately, even to see the NFS server when searching from Kodi for NFS servers, but the folder still was not accessible, now it throws an error that says “Server cannot be connected” or something similar (Kodi is in another language so I’m just translating). Is an advance but no luck yet.

I’ve seen some other post with permission problems that I am starting to think may be the cause and I also want to do the same Torrent client scheme in my setup:

[Solved] Can’t get around “Permission Denied” in Transmission

I will continue today if possible and let you know.

@DBMandrake I did the update, it took more than 30 minutes, but not sure as I had to get away. In Kodi build says May 15, so I assume it finished correctly.

Please do:

ls -al /mnt/hdd/

and post the results for us.

osmc@osmc:~$ ls -al /mnt/hdd/
total 24004
drwxr-xr-x 2 root root 16384 Jan 1 1970 .
drwxr-xr-x 4 root root 4096 May 19 12:27 …
-rwxr-xr-x 1 root root 160731 Mar 12 08:29 Lista Streams.xml
-rwxr-xr-x 1 root root 2109006 May 10 18:24 pelisalacarta-xbmc-addon-gotham-3.9.99.zip
-rwxr-xr-x 1 root root 22210321 May 10 18:58 plugin.video.pulsar-0.5.0.zip
-rwxr-xr-x 1 root root 20770 May 10 19:08 repository.pulsarunofficial-1.0.1.zip

I’ve tried one more time, after rebooting and starting over with unmount from /media, mount to /mnt and adding to nfs. Finally I’ve seen some light, the files shown up in my windows 7 Kody installation, but not in my android tablet. I will modify later my fstab as seen on other posts.

Issues:
Windows 7 Kodi installation can access the shared folder from the file manager, but when I press “…” it can not go back and show a “Could not connect to network server” message. Still, it works, as navigating from adding the source in Videos->Files, I can go back and navigate without any issue. Unlike android, the share cannot be found by searching NFS shares.

On Android (4.4.4 custom rom for Nexus 7 2012), I can find the share without having to write down the address, but as soon as I try to navigate the shared folder, a “Not possible to connect to the server” message, so is a no go for android.

I still have to test from my other Pi with Raspmbc to see if it can connect to the shared folder or not…

I was expecting to be able to see it from android, but is not that bad. If Raspbmc then it is bad, we’ll see.

EDIT:

I finally managed to get Android working also. What did the trick was this setting in exports, insecure parameter was missing:

/mnt/hdd 192.168.1.0/255.255.255.0(rw,no_root_squash,no_subtree_check,insecure)

Thanks everybody for your time and support!

Glad you got it working. Kodi doesn’t do so well with nfs shares that don’t have the insecure flag. Guess Android has some problems also.

Reviving an old topic because I have a similar issue:
2x Raspberry Pi 1 model B, each with OSMC on it.

192.168.1.1: Not connected to a tv. Kodi startup disabled. USB HDD (NTFS) attached and mounted to /mnt/usb0
192.168.1.2: Connected to TV. Running Kodi, no USB drive connected. Trying to add video files from NFS location (the first RPi).

I did ‘sudo nano /etc/exports’ and added the line. My file looks like this:

/mnt/usb0 192.168.1.0/255.255.255.0(rw,no_root_squash,no_subtree_check,insecure)

But whatever I do, even if I just insert the IP address 192.168.1.2(rw,no_root_squash,no_subtree_check,insecure) it does not work. In OSMC/Kodi on the second RPi, it does not find any Network Filesystem (NFS). I also tried adding nfs://192.168.1.1 manually in Kodi but Kodi cannot find it.

Do I need to enable NFS server somewhere on the first RPi? Or do I need to do something after saving the exports file? I have installed the latest OSMC image (June).

Try:

sudo apt-get install nfs-kernel-server

NFS Server is not installed by default so has to be added. You may want to back up your exports file first, it will be overwritten.

2 Likes

Thanks, I bought a RPi2 to replace the 2 old RPis because I couldn’t get it working and thought it would be too risky/sensitive for problems. But good to know I had to install NFS Server first!

Would be nice if it could be enabled via OSMC Apps