July 25, 2022

How to mount an NFS share on LibreElec with a system.d service

How to mount an NFS share on LibreElec with a system.d service

Our first job is to make a directory for our mount.
Typically /mnt is used, but as this is for media we'll use /media this time.
Be careful though, on LibreElec /media is symlinked to /var/media, so to make the 'blackbox' mount location we'll need to issue:

mkdir /var/media/blackbox

Now we can create our system.d unit file.
The name should be the full path, but with / replaced by - instead, ending with .mount.
So we'll create:

sudo nano /storage/.config/system.d/var-media-blackbox.mount

In this file we'll define our mount details

Description=media nfs mount



If you have some trouble getting your .mount file to work, check out the great sample files in /storage/.config/system.d/. In our NFS case here particularly look at /storage/.config/system.d/nfs.mount.sample.

Next up is a quick daemon reload so system.d knows about our new mount file.

systemctl daemon-reload

Now we're all set to test out our new mount.

systemctl start var-media-blackbox.mount

If that's working then all that's left to do is enable the service, so it works after reboots as well.

systemctl enable var-media-blackbox.mount

That's all! You can now stream media, or use this as a backup location for your automatic raspberry pi backups!