Nextcloud-AIO: Extended Storage Via NFS

On Same LAN Using An External USB Drive

A major stumbling block in perfecting our Nextcloud AIO instance was attaching a read-only archive of media by LAN from an adjoining Plex server we run at home. It took several tries to get it attached and working as desired. These notes may be helpful if you are attempting something similar.

We started from having Nextcloud-AIO up and running on an ubuntu-based virtual machine created in ProxMox. Our prior instance of Nextcloud ran on a bare-metal ubuntu server with all storage attached internally or externally by usb to the system, so using a network share into nextcloud-aio was doubly unfamiliar.

The plex server runs on the same local subnet on a bare-metal ubuntu instance. Here are the steps that got the share working:

First, install and configure nfs server on the plex system:

sudo apt update
sudo apt install nfs-kernel-server

Verify it’s running:

sudo systemctl status nfs-server

Configure a shared directory:

sudo mkdir -p /mnt/nfs_plex_share

In my instance, this directory is not where the plex media is actually stored. This new directory will be bound to the external usb drive where the media is maintained in a later step. (For now it’s just an empty folder.)

Configure nfs exports: sudo nano /etc/exports …And add the line below adjusting the ip address for your own subnet:

/mnt/nfs_plex_media 192.168.0.0/24(rw,sync,no_subtree_check,no_root_squash,crossmnt)

Some notes on the above:
The ip address in my case grants the entire subnet access to the nfs share on the plex server. You could limit it to the nextcloud host alone if you want to.

And this was important to learn: If, like me, your media files are to be linked to /mnt/nfs_plex_share by using mount – -bind , you must include the “crossmnt” parameter, else the files probably won’t be readable.

The “no-root-squash” parameter allows the client’s root user to have root privileges on the nfs share.

One more thing: do use “rw” here. You will likely be adjusting ownership and permissions later on. You will ultimately control read-only access to the archive in nextcloud as you configure External Storage there.

Load this configuration into the nfs server with :

sudo exportfs -ra
…Then restart the nfs-server:

sudo systemctl restart nfs-server

Now here’s the step where we bind the plex media files to /mnt/nfs_plex_share :

If your external drive is mounted in /etc/fstab as, say, /media/plex-drive you can bind the archive to /mnt/nfs_plex_share with this:

sudo mount – -bind /media/plex-drive /mnt/nfs_plex_share

Now you should be able to see the archive files in /mnt/nfs_plex_share , and modify them there just as permitted at /media/plex-drive.

To make the mount persistent after a reboot, add this to /etc/fstab:

/media/plex-drive /mnt/nfs_plex_share none bind 0 0

Be certain the above line appears below the entry which mounts /media/plex-drive , else your system might not boot up correctly!

This would be a good time to be sure of the user:group and permissions in your plex archive. Nextcloud-aio wants the archive contents belonging to www-data:www-data These work for me, and have not disturbed the workings of the plex server. Do:

sudo chown -R www-data:www-data /mnt/nfs_plex_share

Then:

sudo chmod -R 755 (or 750) /mnt/nfs_plex_share

The above can take quite a while for a large archive. Be patient.

Now we go set up what’s needed on the nextcloud-aio machine:

Begin with installing the nfs client:

sudo apt install nfs-common

Then make a mount point for the external nfs share you will be mounting:

sudo mkdir -p /mnt/plex-archive

Now, mount the nfs share manually: Use your own plex server LAN ip address:

sudo mount 192.168.0.101:/mnt/nfs_plex_share /mnt/plex-archive

You can verify the mount worked with:

mount | grep nfs

Make the mount permanent:

sudo nano /etc/fstab …and add this line:

192.168.0.101:mnt/nfs_plex_share /mnt/plex-archive nfs auto,nofail

Test this with:

sudo mount -a

Then check that your mount point is working.

Ok.

Lastly, we need to configure a mount point within nextcloud-aio for /mnt/plex-archive before we go to set up External Storage in the nextcloud web interface.

It would be wise to shutdown nextcloud-aio for the next steps. I built nextcloud-aio using docker compose, so I used:

sudo docker compose stop

This also works, and is recommended:

sudo docker exec -it nextcloud-aio-mastercontainer sudo -u www-data php /var/www/docker-aio/php/src/Cron/StopContainers.php

If you use Portainer, you can easily and gracefully monitor and stop all the containers that way. Depending on how you built your nextcloud-aio, you might need to use Portainer or this next command to finally stop the nextcloud mastercontainer:

sudo docker stop nextcloud-aio-mastercontainer

Once stopped, you need to add the NEXTCLOUD_MOUNT parameter to you nextcloud-aio environment. For me, that meant doing something like this in the environment section of my compose.yaml file:

NEXTCLOUD_MOUNT: /mnt/plex-archive

Start nextcloud-aio back up again:

sudo docker compose up

Finally, log in to your nextcloud admin account, and go to Administration Settings/Administration/External Storage. Create an external storage thus:

Folder name: can be anything.
External Storage: choose Local
Authentication: None
Configuration: /mnt/plex-archive
Available For: select groups or individuals. Do include “admin”, else you won’t find it for yourself!
Click the three dots, and I strongly recommend Read Only to protect your archive. Enable Previews can take a long time to process. Click the check mark, and you should see a pale green check at the start of the line indicating it’s worked.

Before your data can be found or browsed, you must do a file scan, thus:

sudo docker exec –user www-data -it nextcloud-aio-nextcloud php occ files:scan –all
One other note about the External Storage in the Administration section: The choice to select a “Local” storage doesn’t appear until you’ve added the NEXTCLOUD_MOUNT environment variable. Then it shows up!

That’s pretty much it. If you find any faults or errors in these notes, please leave a comment, and I’ll try to fix it in an update. Best of luck!