Mounting storage NOT on same FreeNAS server

Ixian

Patron
Joined
May 11, 2015
Messages
218
Happy to help. Yes, if I hadn't seen your last update I would have told you to clear ipv6 since what you were doing with it wouldn't work, but you figured it out.

Remember to mash "thanks" on a post if it helped :)
 

Selassie

Dabbler
Joined
Jun 22, 2018
Messages
46
You can do most of it from the GUI on both servers.

Basically, you want to:
Enable the NFS server on FreeNAS01.
Create an NFS share on FreeNAS01 pointing to the dataset on that server you want to share (presumably the one that has your media in it)
Mount said NFS share to a folder on FreeNAS02. Probably better, in this case, to mount it in the jail itself.

Something like this:

Assumptions (adjust as needed) -
FreeNAS01 - Your data (media, I assume) source
FreeNAS02 - Your application server that needs access to the above

Connected via 1GBe link (assume)
Private, internal network space

On FreeNAS01:

  • Enable the NFS server if it isn't > GUI>Services>NFS and configure to auto-start.
  • Configure NFS server (pencil icon to the right). The defaults are fine, you can tune if needed later.
    • I recommend checking "NFS4" and then checking the "NFSv3 ownership model for NFSv4 " box. NFS4 is more performant, both servers support it, and it handles things like file-locking better than NFS3. However NFS4 by default has a stricter permissions model that, while useful, is unneeded for this use case and can complicate things, hence the option to use the NFSv3 ownership model.
  • GUI > Storage > Pools. Find the dataset you want to share (the one with your media in it). Check what user/group has permission to said dataset.
  • GUI > Accounts > Users/Groups. Take note of the GID and UID of the group/user that has permissions to said dataset.
  • GUI > Sharing > Unix (NFS) Shares. Create NFS share for the dataset on FreeNAS01 that you want FreeNAS02 to be able to access.
    • Select the dataset you want to share at the top.
    • The share defaults are fine, but click Advanced and look for Mapall Group and Mapall User (NOT Maproot). Set these to the same user/group that has permissions to the dataset itself.

What this will do is simple: Any remote NFS user accessing this share will have the same rights as the user/group specified - which will be the user/group with the permissions for the dataset.

(There are cases where you would want to use Maproot instead, or nothing at all, but "sharing media over a private network" isn't one of them).

On FreeNAS02:


Open a console (or ssh in to one) to your server.
Console in to your jail (technically we could use iocage exec to do this outside the jail but let's keep it straightforward).
iocage console <jailname>. I.e. if your Plex jail is named "plex" use that for jailname.

Create a directory in to mount the NFS share in - convention is to use something under /mnt but you can create it and call it whatever you like. Example:
mkdir -p /mnt/remote_media

Grant the user/group Plex runs as ownership of this directory. If you are using one of the default installs, the user/group in the jail is "plex".

chown plex:plex /mnt/remote_media

Manually mount the remote NFS share to the directory you created above to test.

mount -t nfs <server IP>:/path/to/share /mnt/remote_media

Where <server IP> is obviously FreeNAS01's ip (don't forget the : after) and /path/to/share is the path to the data set on FreeNAS01.

Example: You have a "media" dataset in the pool "tank" on FreeNAS01, ip 192.168.0.2 and you want that to mount to /mnt/remote_media on FreeNAS02:

mount -t nfs 192.168.0.2:/mnt/tank/media /mnt/remote_media

Assuming all went well you should now be able to browse to /mnt/remote_media inside your jail FreeNAS02 and see everything that is in the remote directory.

Test permissions/access
Code:
cd /mnt/remote_media
ls -l
touch test.txt
chown -R plex:plex test.txt
rm test.txt


If everything is fine, congrads, your Plex server will now be able to see the media directory, just point it to /mnt/remote_media (or wherever you mounted/called it).

Now add it to fstab so the storage remounts on boot. Iocage handles jail fstab outside of the jail itself so first exit it, then run the exec command on the jail like so:

Code:
exit ## back to Freenas console
iocage fstab -a <jailname> <Server IP>:/path/to/share /mnt/remote_media nfs rw 0 0


Where "jailname" is plex, or whatever your plex jail is named and Server IP, paths, are the same as the mount command you did above.

Restart the jail
iocage restart <jailname>

And make sure the directory you mounted is still there.

This should get you started. I can't guarentee it is 100% cut&paste since I am doing it from memory, and really you should use this as a guide to learning more vs. something to blindly follow anyway.

Also you may find you need to tune the NFS mount a bit - increase wait time, etc. - because remote NFS mounts can lock up your jail if, for example, your remote server disconnects. Once you get the basics working it's worth investigating. And you'll be able to ask more specific questions if you need help.
I have a very similar setup with new TrueNas Servers;

Server One: TrueNas Core, Storage with two shares for TV and Movies
Server Two: Truenas Scale: I plan to run Sonarr, Radarr, NZBGet and Plex using TrueCharts.

Since Truenas Scale uses Docker, deploying these apps and connecting them to local storage is easy. However, connecting to an external server seems to be an issue. Without a resolution, I have raised this issue on the Truenas Charts Discord channel and the forums.

I have this exact scenario running, but with the apps on a Windows machine where two SMB shares from the Truenas Core machine connect to all the apps, it seems to be an issue in Truenas Scale. Even in Ubuntu straight forward to do this because you can create a mount point in the Fstab file to the second server, and everything is auto mounted on bootup.

I see you have provided a solution using Freenas core and Jails, but Truenas Scale uses Docker, and on the Scale system, there does not seem a way to add a file path or share from an external machine.

What do you suggest for this?
 

Selassie

Dabbler
Joined
Jun 22, 2018
Messages
46
Happy to help. Yes, if I hadn't seen your last update I would have told you to clear ipv6 since what you were doing with it wouldn't work, but you figured it out.

Remember to mash "thanks" on a post if it helped :)
The explanation you gave above was fantastic. I have the same setup with two servers, but the app server is running Truenas Scale. I can see how part one would work in setting up the nfs share on the first server, but the second part of me stumped as Truenas scale does not with iocage.
 
Top