JustPaste.it

Create an NFS server to share your media to Kodi

folder.jpg

Let's get right to it.
 
First thing you want to do is setup your directory you want to share. If you have a USB hard drive to share, the next steps are essential. If you are not using a USB hard drive, you may skip this part and simply place your media directory or symlink it where you want.
 
1. Get the UUID of the disk partition:
 
sudo blkid
 
2. Find the disk partition from the list and note the UUID, NOT GUID. For example,
 
5C24-1453.
 
3. Open the fstab file using a command line editor such as nano:
 
sudo nano /etc/fstab
 
4. Add the following line at the end the fstab file:
 
UUID=5C24-1453 /Slack ntfs-3g auto,user,rw 0 0
 
This will ensure disk partition identified in blkid will be automounted to /Slack on every boot, if your file system is not ntfs-3g, change that accordingly, you may try auto if all else fails for filesystem type. Now that we have our desired share directory defined, we may move on to installing the NFS server.
 
Linux desktops using Apt:
 
1. Install NSF server:
 
sudo apt-get install nfs-kernel-server nfs-common
 
note: most instructions show portmap or rpcbind as a requirement, it is no longer required since NSFv4
 
2. Create the NSF share:
 
sudo nano /etc/exports
 
3. Ignore the commented lines preceded by #'s and create a new line at the end of the file like so:
 
/Slack 10.0.0.*(rw,no_root_squash,sync,insecure)
 
This creates the share using the media location /Slack for all users on the local network range, you can modify this for your own network/use, the insecure option is so that all clients can connect and see your media without setting up group ID's on the server, setting the file permissions for that group, and then setting your group ID client side... since it is impossible to set group ID on certain clients, insecure is essential for my setup.
 
4. Export the shared directory
 
sudo exportfs -a
 
5. Restart the NFS Server Service
 
sudo service nfs-kernel-service restart
 
6. You’re now ready to connect to your new NFS shares. Clients like Kodi can now browse and find the NFS share.
 
 
Final note: Permissions are confusing as fuck, NFS is built on top of RPC authentication. Basically the sever has the ability to set what they like, and the client can try anything they like, but unless both are set correctly, nothing will work and just fail silently. This is compounded by the fact that there are different methods of circumventing this circus sideshow, I feel like my way is best, but you must trust your clients to not just delete all your files on your server. Please practice safe backups.
 
Reference pages:
 
https://cgscomputer.com/create-nfs-share-linux-mint/
https://www.raspberrypi.org/documentation/configuration/external-storage.md
https://help.ubuntu.com/community/Fstab
https://serverfault.com/questions/240897/how-to-properly-set-permissions-for-nfs-folder-permission-denied-on-mounting-en
https://vitux.com/install-nfs-server-and-client-on-ubuntu/ <--- extra info on permissions and firewalls