Last summer I decided to replace my QNAP NAS by a more comprehensive NAS. I am working a lot with Dell servers, and therefore it was an easy decision for me to use a Dell PowerEdge R340 with currently two 10 TB Seagate Iron Wolf hard discs, and two 16GB microSDHC/SDXC Cards as replacement. I know using such a server as a private NAS might be exaggerated, for some, but I wanted a rack device and more important enough server resources for experimental reasons. As operating system I decided to use TrueNAS Core, formerly FreeNAS.
I configured the PERC Raid Controller in HBA mode using iDRAC, because TrueNas is using ZFS which has an integrated RAID functionality. In fact, using a Hardware RAID with TrueNAS is definitely not suggested! The two screenshots below show, how to switch to HBA mode using iDRAC:
I installed TrueNAS on one of the two 16GB microSDHC/SDXC Cards. The two 10TB Seagate discs should exclusively be used as storage devices and not partly for the operating system. The second 16GB microSDHC/SDXC Card will later be used to mirror the operating system.
I performed the installation using the web interface of iDRAC, which is really a comfortable way to do it. iDRAC is an independent administration tool, shipped with all Dell servers and works immediately after the server is plugged in to the power supply. From iDRAC you can control and administrate the complete server. There is also a remote console feature.
After installing TrueNAS Core, creating one or more pools and sharing we have a working NAS which we can access, using SMB, AFP etc. Again, I do not want to go into detail and reference to the TrueNAS documentation because scope of this blog is how to create a private cloud using NextCloud and how to access it from anywhere in the world.
Now let us start with the installation of NextCloud. TrueNAS provides a certain number of plugins to extends the functionality of the NAS. Each plugin will be installed in his own jail and is therefore independently. Wikipedia defines a jail as a “OS-level virtualization that allows system administrators to partition a FreeBSD-derived computer system into several independent mini-systems called jails, all sharing the same kernel, with very little overhead”. Simply spoken, it’s a FreeBSD container virtualization like Docker. Some plugins are officially maintainanced by iXsystems and there are also a certain number of community plugins available.
NextCloud is an official plugin, therefore we simply goes to Plugin int the TrueNAS backend and select NextCloud. At the time when this entry was written the plugin is using NextCloud 20.0.4, instead of 20.0.5. However this is nearly the current version and shows me, that the plugin is actively maintenanced by iXsystem. Select the plugin and press install. A form is opened where you can define the settings. Enter the plugin name and jail name you want. Disable NAT, we will give this jail its own IP-Address. Select the interface on which the NAS ic connected, enter the IP-Addres you want that next cloud is listening and the netmask. Alternatively press DHCP if you want to manage the IP-Address in your router, as I mostly do. The following screenshot shows the settings:
Press save and installation dialog is displayed and wait until it is finished. Press “Close” to close the dialog which informs you about the successfully installation. Next press “Post Install Notes” to display the username and password for the admin access to NextCloud and copy it or write it down:
Now switch to Jails to get the IP-Address of your NextCloud jail and to create mount points:
Creating the mount points for the jail
Before we access our NextCloud instance for the first time, we will mount the NAS directories which should be accessible from the jail and therefore from NextCloud. To do this:
- Stop the jail
- After the jail has stopped press “Mount Points”
- Press on “Actions” and select “Add”
- On the top, select the directory which should be accessable from the jail (in my case /mnt/Data/Multimedia)
- Below select the mounting point in the jail (in my case: /mnt/Data/iocage/jails/NextCloudBlog/root/mnt/Multimedia). You do not have to create the folder in the jail first, you can directly enter the path (the folder Multimedia does not exist in the jail, but it will now be created).
6. Press “Submit”. You can add additional Mount Points if you want.
7. Go back to jails and start the jail.
Add the local network to the trusted domains of NextCloud
Unfortunately before we can use the NextCloud webinterface we need to add the local network to the trusted domains. To do this:
- Select the NextCloud jail and press the “Shell button”
- Install the vim editor to directly edit the config.php file by using the following command:
pkg install vim-console
- Go to the config file by the entering the following command:
- Open config.php file to edit:
- Press i to insert and edit the lines
- Add the whole home network by adding the following line to the trusted domains:
2 => '192.168.1.*'
or whatever your home network IP-Address is.
- Press Esc and then enter :wq to store the file and exit vim.
Accessing NextCloud for the first time
No we can login to NextCloud for the first time by entering the IP-Address of the Jail:
I would suggest to change the password of ncadmin or simply create a new admin user. In the next step we will add the Multimedia mounting point to NextCloud.
Enable External storage to add a local directory to NextCloud
In the NextCloud backend we switch to apps and then to “Disabled apps”. There we find the “External Storage support” app and enable it:
In the next step we switch to settings and select “External Storages”
Now we can enter the “Folder Name”, the type of “External storage” (Local), the “Authentication”, the “Configuration” (meaning mounting point, or location) and who is allowed to access our external storages (“Available for”). Final press the Checkmark to check and store the configuration. Based on this tutorial the external storage configuration looks the following way, the green checkmark confirms that the external storage is accessable:
If you now switch to “Files” you will see a reference to the external storage:
Congratulation, you are now able to access the external storage using NextCloud! You can now download the NextCloud App on you mobile devices and use it.
In part two of this tutorial we will secure the NextCloud jail using https with let’s encrypt and allow access from outside the local network.
Any kind of feedback is highly appreciated.