Other How do I mount a network folder (CIFS, Samba Windows Share) to a jail for Plex-access to LAN?

devnullius

New Member


Messages: 17

Running FreeNAS 9.10 which is built on FreeBSD 10.3

I added a Plex jail to the system. All is working, which is great. But because Plex is running inside of a jail, it (obviously) cannot access my network. So I was looking for a way to add a persistently mounted network share to my Plex jail. This way, I can let Plex index and play LAN resources. I thought this to be pretty obvious, but I couldn't find a solution :/ I asked the question here too and got shot down :) (https://forums.freenas.org/index.ph...lex-can-index-and-play-lan.42345/#post-275237).

Do you guys know how to get it done? Or am I really 'special' in a negative way for wishing this feature? :)

Peace!

Devnullius
 
OP
D

devnullius

New Member


Messages: 17

I've read the prerequisites you gave me; luckily I seem to fulfill the rules when posting my question here. I already included a link to the FreeNAS forum where I tried to get an answer in 2 different posts. I was told "I was mad in the head" and was pointed to the FreeBSD forum for my question. I have root / shell / console access and I have the jail up and running. The remaining question is how to (persistently) mount a network share in a jail. I feel this will apply to FreeNAS too.

If I shouldn't have posted this network question in Storage; please advise where to go?

So please advise me, FreeBSD community. For everyone keeps telling me how easy it is, yet I haven't figured it out and nobody has a link for me :)

Peace!

Devvie
 

Justin D Holcomb

New Member

Reaction score: 2
Messages: 6

To answer your question, yes this is possible on FreeBSD. On FreeNAS it is very likely possible. However, I am not too familiar with FreeNAS, specifically which files are rewritten on boot and what needs to be configured via GUI for changes to persist across reboots. The solutions below can be translated to work on FreeNAS but I will leave that to you.

If the media files are on the physical host, then I would recommend using a nullfs() mounts instead. nullfs mounts allow a directory to be mounted in another location. This method is compatible with jails where symlinks/hardlinks are not. I recommend buying this book for a better explanation (no affiliation).

Test it by:
mount_nullfs /host/media /jail/root/media

Make it permanent
/etc/fstab
Code:
/host/media        /jail/root/media        nullfs  ro      0       0

You will notice the ro flag being used, Plex does not need to write access to the media files and it is better security. Jails are a form of process separation [think chroot at the application level] however root access in a jail can allow files on the host to be rewritten, writable nullfs mounts are an easy vector for that attack.

You will need to configure the jail to "allow mounts" and to "allow nullfs mounts", this is dependent on the jail manager. In iocage it would be:

iocage set allow_mount=1 jailname
iocage set allow_mount_nullfs=1 jailname


Using a nullfs mount is a much better way of achieving your goal if the files are hosted on the same physical hardware. It involves less layers than Samba, should have better file/folder updates/notifications so that Plex notices and updates it's library, and does not involve keeping a password in clear text.

If the media files are being hosted on a different physical machine and you wanted to use Samba/CIFS/SMB, then I would configure nmbd to auto mount the directory at boot.

Add to /etc/nsmb.conf
Code:
[FREENAS-HOSTNAME:USERNAME]
password=pass1234

The hostname and user must be in all capital letters in this file. I can not stress this enough, it will not work otherwise.

Add a layer of security because storing a password in plain text is insecure. Please use a Samba user with limited or read only permissions.
chmod 600 /etc/nsmb.conf

Add to /etc/fstab
//USERNAME@FREENAS-HOSTNAME/shareNAME /jail/root/media smbfs rw,-N,-I10.0.0.110 0 0

I have used both methods for Plex setups. Both work, the nullfs works a little better for the reasons mentioned above.

I would also recommend using a tmpfs mount for your transcode folder, the reason is due to how COW filesystems work. With the transcode folder, you have files constantly written to and deleted. This creates a lot of blocks being used for no good reason, this leads to fragmentation of contiguous blocks. Data integrity for a transcoded file is unnecessary due to the file's short and insignificant existence. A corrupted bit in a transcoded file will look the same as a blip in the video stream from packet loss due to a wireless connection. To configure a tmpfs mount:

/etc/fstab
Code:
tmpfs        /jail/root/transcode        tmpfs  rw,mode=1777,size=32G    0       0

Then in the Server advanced section for transcoding you would set the folder to /transcode.

EDIT: Updated to reflect my notes. nmbd_enable is not required as I falsely remembered.
 
OP
D

devnullius

New Member


Messages: 17

Wauw - I have some reading ahead of me! Super thanks - at first glance you are very knowledgeable and really took the time to help me here! xx

If I have any more questions regarding this, do you guys prefer me to take it over to FreeNAS forum or should I request more info here?

Thanks!

Devvie
 

Justin D Holcomb

New Member

Reaction score: 2
Messages: 6

If the questions are unique to FreeNAS and most likely will be, then yes to the FreeNAS forums.

If the questions are based on the under lying technology then either is fine. Feel free to PM me if you are unsure.
 
Top