File sharing with a NAS, media server, windows share or other device


#1

Whether you already have a media sharing system on your network or are setting one up for the first time the options can be bewildering. To stream high-quality video you will want the fastest possible connections. Unfortunately, the easiest systems to set up are also the least efficient so some effort is needed to get the best performance. Here are some recommendations.

This assumes you have already set up the wired or wireless LAN connections between the server where you store your media and the client(s) where you want to play it. See here: https://osmc.tv/wiki/general/setting-up-your-network-connection/

Any machine can act as a server, including one running OSMC (see OSMC as a server below). You will get the best performance, especially if there are lots of clients, from a purpose-made NAS.

Choosing a filesharing protocol

If you have a NAS that offers the NFS filesharing protocol, choose that for best performance with OSMC devices. NFS is the built-in network filesharing system in Linux. Windows (but not ‘Home’ versions) also has an NFS client so you can still access those NAS files from Windows.

If you keep your media on a Windows machine then it makes sense to use the SMB protocol, otherwise known as CIFS, especially if you have other Windows machines on the network. SMB is built in to every version of Windows. Linux machines connect to SMB shares using a package called Samba. They can’t join a ‘HomeGroup’ but according to this: http://kodi.wiki/view/SMB/Windows they can access shares created using a homegroup. The Samba client is included in OSMC, the Samba server is optional.

If your NAS or other device where you store media supports only SMB version 1 you may have to adjust the SMB version in Kodi (see below). See also https://blogs.technet.microsoft.com/filecab/2017/06/01/smb1-product-clearinghouse/

We do not generally recommend the use of UPnP for security and performance reasons, but if you already have a UPnP/DLNA server it should be the easiest of all to set up. Some media servers may offer only UPnP for sharing. OSMC has a built-in UPnP server.

Note that any filesystem format can be used with any protocol, for example you can share NTFS files using NFS or Linux (ext4) files using SMB. File ownership and permissions won’t necessarily translate but that won’t matter for media files. It stands to reason though to expect a Windows filesystem to be served best with a Windows filesharing protocol and a Linux filesystem to be served best with a Linux protocol. You can also share the same files with two different protocols at the same time.

OSMC does not support AFP. Apple Mac users can use SMB.

OSMC as a client – using Kodi

If you have a media server already you can connect to it using SMB, NFS or UPnP from the Kodi GUI but you may not get the best performance that way. When you add a source, you will be able to browse to any available NFS shares or UPnP devices. To add a network share pick Music (say) then Files then Add music and enter the network location as follows or click left to browse to the location.

If using NFS, nfs://SERVER/path.
For SMB, smb://user:password@SERVER/sharename/folder

You cannot currently browse to SMB shares if using the latest version of the SMB protocol. Neither does Kodi give you a user/password dialog. This is a major drawback since newer versions of Windows don’t seem to allow passwordless (Guest) access to shares. You will have to enter the user, password and location manually or temporarily change the SMB settings from their defauilt (see below).

SERVER is the name of the server machine, or preferably an IP address. If using an IP address, it’s best to make it a fixed address by telling your router to always assign that address to that machine. If you do use a Windows machine name, it must be in UPPERCASE. user is a Windows username with access to the share and password is that user’s password. Path is the location of a share in a Linux filesystem on the server, sharename is the name of a Windows share. path and sharename are optional – without them you would see all visible shares on that machine - folder (also optional) is the path to a folder inside that share.

If using UPnP, you must use the browse function.

To turn on browsing and password entry for SMB, you will have to force both client and server to use SMB version 1. There is a security risk in using SMB1. Do not leave SMB1 enabled if you also want to access your files from the internet. In Windows, search for Windows Features and enable SMB 1.0/CIFS File Sharing Support.
image

In OSMC, go into Settings, set the Settings level to Advanced or Expert and set the Maximum protocol for SMBclient to SMBv1 or None.


Now you should be able to see the shared folders on the Windows machine after entering a valid username and password. Once you have added a share or shares to the Library, you can (and should) go back to SMBv3 (on both machines) to restore security.

OSMC as a client – using fstab

Using the SMB or NFS services in Kodi is somewhat simple to set up but may not deliver the best performance. It may be fine for music and low-resolution video but not for high video bit-rates. For that you have to ‘mount’ a shared folder in OSMC’s filesystem. You will need to access the commandline as described here: Accessing the commandline.

You make a directory in the filesystem then attach the shared directory to that ‘mountpoint’, usually under the /mnt directory. The share can be mounted automatically by editing file /etc/fstab as described here: Configuring fstab based Samba share mounts or here: Configuring fstab based NFS share mounts

When mounted, the shared directory looks to Kodi just like a local directory so you need to browse to Root filesystem then the mountpoint when adding a media location (source).

OSMC as a server

To share files on your OSMC device with other devices proceed as follows. You can use NFS, SMB or UPnP. If sharing a USB drive or other removable media it first needs to be mounted in the filesystem. OSMC automatically mounts removable devices under the /media directory and automatically shares them if you have installed the SMB server (see below).

To share using NFS you need to install the nfs server:

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

For NFS do not rely on the built-in automount which mounts removable drives under /media. Instead, add a line in fstab to mount the drive under /mnt so that its location and shared name is predictable. First make a directory under /mnt. Lets call it mySharedDrive.

sudo mkdir /mnt/mySharedDrive

Then add a line to fstab like this

UUID=uuidofpartition /mnt/mySharedDrive ext4 defaults,noatime,auto,nofail,x-systemd.mount-timeout=30 0 0

Type blkid at the command prompt to get the value of uuidofpartition.

You need to make a file /etc/exports which will contain lines like this:

/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.

Windows machines (Pro, Ultimate and Enterprise) can access NFS shares by adding the NFS client.

image

It is not possible to browse to an NFS share from Windows but you can go there by entering the location eg \\192.168.1.1\mnt\mySharedDrive in Windows Explorer and you can map a Windows drive letter to that NFS shared directory.

To share OSMC’s files using SMB, install the Samba server from the AppStore. The server automatically shares your home directory and any removable media. Configuration files for the server are in /etc/samba. If you want to change the SMB version or other defaults, create a new file smb-local.conf as described in smb.conf. OSMC’s samba server by default will serve any SMB version. To browse to the samba shares from Windows, turn on the SMB 1.0/CIFS Client in Windows features. To force a more secure protocol, add server min protocol = SMB2_10 to the [global] section of smb-local.conf.

To share using UPnP/DLNA turn this option on in Settings->Services. Other devices will then be viewing your media through the library rather than directly through the filesystem. They will only be able to access media that you have added to the library, therefore.


Unable to connect to a network share via smb
SMB not accessible
How do I mount Windows network shares in OSMC?
Access to SMB Share - Error: File exists
Configuring fstab based NFS share mounts
SMB not accessible
Not even my WORKGROUP is browse-able when trying to add SMB source
First comparison between Vero 4K and my Intel NUC
How do I share a folder from OSMC (RPi) mounted drive to read write file from Windows laptop
How do I share a folder from OSMC (RPi) mounted drive to read write file from Windows laptop
Play content from another multimedia
Mount an external USB drive
Raspberry 3 - SMB not working
Samba Sharing
OSMC + Synology (with username and password)
Mounting SMB via fstab - Help
Mounting SMB via fstab - Help
[Solved] Add Network Location problem Vero 4K
Instructions for idiots
Help please for beginner who cannot play video files
Help needed: Setup video source
Can't access Vero 4K/OSMC from Windows
Vero 4k cant see my server
Vero 4k cant see my server
Some questions Vero 4K
Question about Osmc and options
File sharing
SMB is empty
Windows 10 Fall creators SMBv1 fix
'Couldn’t connect to network server'
Raspberry & Mycloud NAS failures
NAS or USB 4K 60-70GB files?
OSMC, Unraid server
Sharing files with Windows PC via Samba?
Adding Repos
Interrupted Video playback on vero 4K
How do I mount Windows network shares in OSMC?
Time Capsule Connection
Vero 4K+ not turning on
OSMC samba network
Setting up Vero 4K+ basic questions
[SOLVED] Can't access OSMC with windows explorer
Question about media servers
Should my new Vero 4K see my Windows network?
Vero 4K and playing files from shared folder on Windows desktop
The Hurricane Heist 4K playback problem
#2

Bug since January 2018

There are reports of problems streaming video from NASs when the maximum protocol on either the NAS or in Kodi (or both) is set to SMB2. This seems to affect only Vero4k and only when connecting through Kodi (not when using fstab).

If you get this problem, set your NAS and Kodi client to SMB3. If your NAS does not support SMB3, try ‘SMB2 with large MTU’ or similar. If that doesn’t work, set the Kodi client to max SMB1.

This should be fixed in the next update.


#3

This bug has been fixed.