FreeNAS: NextCloud Access to Mount Points using External Storage and Proper Permissions
Setting up FreeNAS Nextcloud permissions can be a bit tricky, but once you get it right, allows you to combine the power of FreeNAS with Nextcloud. Nextcloud is a suite of client-server software for creating and using file hosting services, which is most powerfully paired with FreeNAS when you are able to configure it to access your stored data on your server (e.g. beyond just a jail running Nextcloud). These mount points you are likely to share via samba (Windows file sharing) over your local and are likely to backup through whatever means works best for you.
As mentioned in the previous article, FreeNAS: Nextcloud Install with SSL Access, the Nextcloud application provides functionally which is similar to Dropbox, however unlike Dropbox, Nextcloud does not offer off-premises file storage hosting. As I have previously noted, it is critical that you have an off-premise copy of all sensitive data (which is encrypted). Unlike Dropbox however, Nextcloud is free and open-source, which means that anyone is allowed to install and operate it on their own private server devices. In contrast to proprietary services like Dropbox, the open architecture allows adding functionality to the server in the form of applications and enables users to have full control of their data and keeps data secure and free from the prying eyes of big companies like Google and Dropbox.
This is part of my ongoing series of TrueNAS and FreeNAS setup, configuration and install articles.
Creating Mount Points
Lets get started in ensuring FreeNAS Nextcloud permissions are setup correctly. The first thing you will need to do is create mount points within your NextCloud jail which point to the data directories that you want to access via Nextcloud. You first need to create directories to contain the mounted folders; I usually create these in the /mnt/
location. Once these directories are created, you will need to stop the Nextcloud jail from the jail tab in your FreeNAS webui. Once stopped, click the three dots and select ‘Mount Points’. Click ‘Action’ at the top right and then ‘+ Add Mount Point’. Follow the instructions in the dialog to add your mount point. Rinse and repeat for all your mount points.
Enabling External Storage in FreeNAS
Next we will need to turn on the add-on within Nextcloud which allows us to access external folders (in this case external means within the jail, but external to the configured Nextcloud base folder). You will need to start your Nextcloud jail again, and then from your Nextcloud WebUI, click on your user icon, in the top right and then select ‘Apps’. In the screen below, the user icon is the ‘A’ in the circle.

Scroll down the list and click the enable button next to external storage (possibly called ‘External Storage Support’ in newer versions and it is usually disabled for new installs, and it should be near the bottom of the app list).
Adding External Storage Locations
Now that External Storage is enabled we can add some of you external sources. Click on your user icon again, in the top right again and select ‘Settings’. In the menu on the left of the screen, under the ‘Administration’ section, you should see an ‘External Storages’ option on the left hand side of the page. Click it.
You will be presented with a screen which is asking you for a folder name and the has a drop down for add storage. The folder name is the folder name which will appear in Nextcloud and for storage we will select local. Once you’ve done that additional options will pop up: set authentication to none, in configuration you will put the mount location of the data (we setup the /mnt/
location earlier) and optionally you can select the users for which the data is available. Once done it should look something like what is the image below.

Nextcloud External Storage Permission
Ensuring the correct permissions is essential. Nextcloud access resources using the ‘web’ user and the ‘web’ group. As such, we will need to ensure that all of your mount points are owned by www:www have full access to directories and files. In other articles I have recommended that the owner of all your storage files (or at least those that would be accessible through Nextcloud) be owned by www:www and with 744 permissions set. If you need to change this now you can do so through the FreeNAS WebUI by changing permissions in your data sets.
BE CAREFUL doing this as if you haven’t setup your datasets correctly and system or jail information is stored with your dataset, then changing permissions can really bugger things up. To change permissions on a dataset go to ‘Storage -> Pools’ and then expand your pool and select the three dots beside the dataset your looking for and click ‘edit permissions’. You could of course also do this using the chmod
and chown
commands from the command line; be certain you apply recursively.
Once you’re sure the FreeNAS Nextcloud permissions are set correctly, you can head to the FreeNAS WebUI and you should be able to see and access all of your mount points! If you’ve changes privileges and it still says can’t access, it might help to delete the storage from NextCloud and re-add it back on.
Happy Nextcloudin’!
~digiMoot
Sources:
https://www.youtube.com/watch?v=60xwnoIrUTI
https://www.youtube.com/watch?v=pcAvknt53vs
Thanks for the guide! I’m pretty sure I followed it step by step but when I try to click the check mark I get a red stop sign to the left of the entry. Other than that it looks exactly like yours, including the FTP and smbclient warnings. Any advice? (Freenas 11.2 and whatever the most recent NextCloud is)
OK, I’m replying to my own reply. Sad. I figured out I was putting the wrong path in the configuration. Once I corrected that and then set permissions correctly so I could access the shares both in NextCloud and on my local network PCs it was golden. Thanks again for the guide.
Glad it worked out mate!
I have a problem, why not just mount the direcotry into nextcloud data directory, instead have to use the external storage?
Currently I use this method, but I have a problem, why not just mount the directory to nextcloud data directory, instead of use external storage? Thanks.
I suppose you could but my share points are shard between jails and are shared on my local network via SMB.
I used you previous guide to install SSL certs but was not successful with this guide. I have a server with some HDDs for storage and a SSD for jails. I wanted to install nextcloud in the jail but hold the data on my HDDs. I found a guide that I developed for linux and altered it for Truenas. I access the server from a MAC so don’t need putty.
I am no expert just an old bloke trying to get a bloody cloud working so this may be completely wrong but sofar it works for me.
Using MACINTOSH
Install Truenas on server. 2 pools multiple HDD’s for data and SSD for Jails
On MAC open Truenas GUI
In Storeage create pool for jails
in Services turn on SSH and configure to ‘log in as root with password’ and ‘Allow Password Authentication’
Install nextcloud plug-in in Jail pool
When installed and before opening nextcloud
open terminal
$ ssh root@192.168.1.XX (Truenas url)
$ iocage console nextcloud
$ pkg install sudo nano
$ service nginx stop
$ ls -la /usr/local/www/nextcloud/data -check contents
$ mkdir /usr/local/www/nextcloud/data-bak
$ cp -a /usr/local/www/nextcloud/data/. /usr/local/www/nextcloud/data-bak
$ ls -la /usr/local/www/nextcloud/data-bak -check contents are same as above
$ sudo -u #80 php /usr/local/www/nextcloud/occ maintenance:mode –on
$ rm -R /usr/local/www/nextcloud/data
$ mkdir /usr/local/www/nextcloud/data
Go to Truenass GUI
setup storeage for your data outside jail
Setup pool and dataset for your data ( /mnt/tank/ncdata )
permissions owner/group www:www permissions 770
In Jail GUI
stop nextcloud jail
make ‘mount point’ from /mnt/tank/ncdata to /mnt/jailhouse/iocage/jails/nextcloud/root/usr/local/www/nextcloud/data
in terminal
$ ssh root@192.168.1.XX (Truenas url)
$ cp -a /mnt/jailhouse/iocage/jails/nextcloud/root/usr/local/www/nextcloud/data-bak/. /mnt/tank/ncdata
$ nano /mnt/jailhouse/iocage/jails/nextcloud/root/usr/local/www/nextcloud/config/config.php
Make following additions to ‘trusted domains’ array
2 => ‘192.168.1.XX’,
3 => ‘your.domain.name’,
4 => ‘www.your.domain.name’,
Save and Exit
exit
NOTE no need to change data location
$ sudo -u #80 php /usr/local/www/nextcloud/occ maintenance:mode –off
If this helps it is a thank you for your guide on ssl.
Hi! I’m facing a weird problem that I guess it’s related to bad permissions. I’m able to mount the dataset inside the jail and it shows up normally on nextcloud, but, I can access only the root of the mount point. If I try to access a subfolder, it redirects me back to the root.
The dataset is owned by www. I changed the ownership using ACL. I also marked the “apply permissions recursively†option on the same page.
Do you have any ideia of what I should do?
I got it! I had to manually set the permissions to 744 via shell. I thought that only change the owner and group via ACL was enough.