FreeNAS Plex VM with NFS

I’ll demonstrate here how I generally build a Plex VM and mount storage with FreeNAS.

VM Build

I’ll fill in this section later.


FreeNAS User

In order for everything to behave, you’re going to want to create a user on FreeNAS. This user can be used if you need to mount a dataset through SMB or NFS to other computers. If you have already created a user then you can skip to the next heading.

NOTE: This is only creating a single user called ‘plex’. You can get more complex with the setup if you need multiple users to access the share by using groups but that is beyond the scope of this tutorial.

  1. Select ‘Accounts’ menu then ‘Users’
  2. Click ‘Add’ button in the top right
  3. For ‘Full Name’ enter something like: Plex User
    For ‘Username’ enter something like: plex
    Type in a password you will remember for ‘Password’ and ‘Confirm Password’
  4. You should be able to leave everything else at the defaults
  5. Click Submit

You should see something like the screenshot below:

Create dataset

So your VM is built and FreeNAS is ready. If you haven’t already, create a dataset on FreeNAS that will store your Plex media. We’re going to mount our share as an NFS mount to our VM.

  1. Click ‘Storage’ then ‘Pools’
  2. Next to your pool, click the three dot menu and select ‘Add dataset’
  3. Give your dataset a name, like ‘media’. You shouldn’t need to adjust any other settings
  4. Click Submit

You should see your new dataset similar to the screenshot below.

My pool called ‘pool0’ and Plex dataset called ‘media’

Dataset Permissions

Now we need to set permissions on the dataset.

  1. Click the three dots to the right of the dataset you just created
  2. Click ‘Edit permissions’
  3. Set the ‘User’ to the user you created, which is ‘plex’ for us. Check ‘Apply User’
  4. Set the ‘Group’ to the same as the user you created, which is ‘plex’ for us. Check ‘Apply Group’
  5. Check ‘Apply permissions recursively’
  6. Click Save

NFS Setup

Now we create the NFS share.

  1. Click on ‘Sharing’ then ‘Unix Shares (NFS)’
  2. Click ‘Add’ in the top right
  3. For ‘Path’, select your pool and then select the dataset you created, which is ‘media’ in our example
  4. Set the ‘Description’ to something like: Plex media
  5. Click the ‘Advanced Options’ button
  6. Set ‘Mapall User’ to the user you created, which is ‘plex’ for us. This is necessary because NFS operates permissions based on user IDs. The user ID for ‘plex’ on FreeNAS likely will not match up with any user ID on your VM. It does not care what the user is called, it strictly looks at IDs. By using this Mapall setting, we tell it to ignore everything and force file actions as the FreeNAS plex user.
  7. Set ‘Mapall Group’ to the same as the user you created, which is ‘plex’ for us. You can also leave this blank.
  8. Click Submit

You should see an entry that looks like below:

Mount on Plex

For this step, I’m going to make some assumptions:

  • You need to know how to SSH to your Plex VM and use sudo, or run the commands as the root user
  • You need to know how to edit a file on your Plex VM through SSH
  • You know what your FreeNAS server IP is and that it is static set or has a DHCP reservation (also called a ‘sticky IP’) so that the IP does not change. If your FreeNAS server gets a new IP through DHCP then all of this will break since it’s no longer on the same IP.

SSH to your VM. Then we are going to create a mount point and then try mounting the NFS share to make sure everything is happy:

sudo mkdir /mnt/plex
sudo mount -t nfs /mnt/plex

If everything went well, you should now be able to run: ls /mnt/plex which is probably empty if you don’t have any content yet. You can test to make sure writes are working by typing:

touch /mnt/plex/media/testfile.txt

If everything is happy and no error messages came up, you are ready to set this to mount on boot. Edit /etc/fstab and add a line that looks like the one below. Obviously change the IP to your FreeNAS server’s IP (the one you use to browse it’s web interface): /mnt/plex nfs soft,intr

Save the file and close your editor.

Plex Library

Now go into the Plex UI and add a library. Point it to the new /mnt/plex folder and tell it what type of files you’re storing there (Movies, TV, etc). If you want those to be in separate folders, you will need to create new folders before telling Plex to use them. You can do that via SSH to the Plex VM or you can create an SMB share in FreeNAS and point it to the same dataset that NFS is using.

Author: Fuzzy