Connect Nextcloud to a Storage Server: space, quotas and shares

Published on 6 min read

Nextcloud brings users, quotas and shares, the Storage Server brings the space. Together they make a cloud of your own, where a small server is enough and the terabytes live somewhere else.

Nextcloud can do everything a Storage Server cannot: manage users, assign each of them a quota of their own, share folders, create links with a password and an expiry date, and deliver files to browsers over HTTPS. What makes Nextcloud expensive, on the other hand, is the space, because it sits on the NVMe SSD of the server.

Put the two together and you get the setup that has proven itself in practice: a small server for Nextcloud, the files on a Storage Server. This article shows both ways to set it up, explains which one is better when, and names the pitfalls that show up every time.

Why this combination fits so well

Nextcloud providesThe Storage Server provides
User accounts with a password and two-factorSpace, 1 to 20 TB
A quota per userSnapshots as a second backup layer
Share links with a password and an expiry dateA location separate from the server
Delivery over HTTPS with a sign-inA fraction of the cost per terabyte
Versioning and a trash bin100 subaccounts for separate purposes

The decisive point for many projects: the Storage Server has no quota per subaccount. A subaccount does stay inside its own directory, but it can fill the whole plan from there. Nextcloud solves exactly that, because every user gets a hard quota there.

Two ways, and which one is the better one

Way A: Nextcloud talks to the storage itself, through its built-in SMB or SFTP driver. No change to the operating system needed.

Way B: You mount the storage in the operating system as a directory and set up an external storage of the type "Local" in Nextcloud that points at that directory.

Take way B if you have root access. Going through the file system is noticeably faster than the SFTP driver in Nextcloud, above all with a lot of small files, and it survives network glitches better. Way A is the answer if you cannot or do not want to change anything in the operating system.

Preparation: a subaccount of its own

In the customer panel, create a subaccount just for Nextcloud, with a home directory of its own, for example /nextcloud. Enable only the protocol you actually use. Also check under "Access Settings" that External Reachability is switched on, otherwise the server cannot reach the storage.

The examples use these values, replace them with your own:

ItemExample value
Hostnameu123456.storage.kernelhost.net
Subaccountu123456-sub1
Share (SMB)backup
SMB port445
SFTP port23

Way B: mount it and use it as a local storage

First the mount. On Debian and Ubuntu:

apt install -y cifs-utils
mkdir -p /mnt/storage
printf 'username=u123456-sub1\npassword=YOUR_PASSWORD\n' > /etc/samba/storage.cred
chmod 600 /etc/samba/storage.cred

Then the entry in /etc/fstab, so that it survives a reboot:

//u123456.storage.kernelhost.net/backup /mnt/storage cifs credentials=/etc/samba/storage.cred,uid=www-data,gid=www-data,file_mode=0660,dir_mode=0770,seal,_netdev,nofail 0 0

The three options that matter: uid=www-data makes sure the web server is allowed to write, seal encrypts the transfer with SMB 3, and _netdev plus nofail keep the server from hanging during boot if the storage happens not to answer.

mount -a
sudo -u www-data touch /mnt/storage/test && echo "Write access is fine"

After that, enable the "External storage support" app in Nextcloud and add the storage, either in the interface under Administration, External storage, or on the command line:

sudo -u www-data php occ app:enable files_external
sudo -u www-data php occ files_external:create Data local null::null -c datadir=/mnt/storage
sudo -u www-data php occ files_external:list

The folder "Data" now shows up for the users you grant it to. You control that per user or per group, so that not everybody sees everything.

Way A: external storage straight in Nextcloud

Without root access it works without mounting as well. For SMB you need the matching PHP extension:

apt install -y smbclient php-smbclient
systemctl restart php8.3-fpm

Then create an entry under Administration, External storage:

FieldValue
Folder nameData
External storageSMB / CIFS
Hostu123456.storage.kernelhost.net
Sharebackup
Remote subfoldernextcloud
Usernameu123456-sub1
Passwordthe password of the subaccount

For SFTP you pick the type "SFTP" instead, enter u123456.storage.kernelhost.net as the host and 23 as the port. That is the most common source of errors on this route: Nextcloud suggests 22, our storage listens on 23.

Assigning a quota per user

Now comes the part that justifies the whole setup. Under Administration, Users you enter a quota per account, for example 50 GB. Or on the command line:

sudo -u www-data php occ user:setting photographer1 files quota "50 GB"

Nextcloud counts versions and the trash bin toward that figure. That is the right behavior, but it does catch people out: somebody who gets 50 GB and uploads 50 GB has quickly taken up more than expected through old versions. For accounts that replace a lot instead of adding, it pays off to limit how long versions are kept.

To Nextcloud the external storage is a folder like any other, so shares work unchanged. A link with a password and an expiry date takes three clicks, and the file is delivered through Nextcloud, not straight from the storage. Your credentials for the storage therefore never leave the server.

This is exactly the building block that a Storage Server on its own is missing. If you run a website with a download area, you get user management, permissions and delivery in one, without programming anything yourself. What the alternative without Nextcloud looks like is covered in Using a Storage Server for your own website.

Four pitfalls that show up every time

  • The data directory does not belong on the storage. Technically possible, in practice risky: Nextcloud also writes lock files and temporary state there, and a brief network glitch takes the whole instance down. As external storage, a glitch only hits that one folder.
  • The database stays local. Always. Files belong on the storage, nothing else.
  • Set up Redis. Without a cache for file locks, Nextcloud with external storage gets noticeably slow, because every lock goes through the database.
  • Port 23 instead of 22. With SFTP, Nextcloud suggests 22. Our storage listens on 23, and the error message about it is not much help.

Which server and which plan

For Nextcloud itself a small machine is enough. The files live somewhere else, the server only manages them: for a handful up to a few dozen active users, 4 to 8 GB of RAM is enough, provided Redis is running and the background job is set up. A guide for that is in Installing Nextcloud on your own server.

With the storage, the choice comes down to space:

PlanSpaceSnapshotsPrice
Storage-11 TB10 plus 10 automatic9.99 EUR
Storage-25 TB20 plus 20 automatic29.99 EUR
Storage-310 TB30 plus 30 automatic39.99 EUR
Storage-420 TB40 plus 40 automatic69.99 EUR

All Storage Servers are located in Germany, speak SMB, SFTP, WebDAV and more, allow up to 100 subaccounts and come with snapshots. No setup fee, PrePaid, no minimum term. If your need for space grows, you move up to the larger plan without touching the data.

Frequently asked questions

Why not simply take a big server with a lot of disk space?
Because disk space on a server with an NVMe SSD costs a multiple of that. Nextcloud itself needs little space and little performance, the bulk sits in the files. A small server plus storage is therefore usually far cheaper than a big server with a lot of disk space.
Should I use SMB or SFTP?
If you have root access on the Nextcloud server, mount the storage into the file system over SMB and set up a local external storage in Nextcloud that points at that directory. This is faster and more stable than the SFTP driver in Nextcloud, which slows down noticeably with a lot of small files.
Can I give every user a size of their own?
Yes, and that is exactly the reason for this setup. The Storage Server itself has no quota per subaccount, Nextcloud does. In the user management you assign a quota per account, and Nextcloud enforces it.
Can I put the data directly on the storage instead of using external storage?
Technically yes, by putting the Nextcloud data directory on the mounted storage. It is not advisable: Nextcloud also writes lock files, previews and temporary state there, and a brief network glitch brings the whole instance to a halt. As external storage, a glitch only affects the folder in question.
Do share links work for files on the storage as well?
Yes, to Nextcloud an external storage is a folder like any other. Shares with a password and an expiry date work exactly the same, and the file is delivered through Nextcloud, not straight from the storage.
How fast is this?
For large files the limit is the uplink of your server, not the storage. With a lot of small files the network round trip is added to every access, which is why thumbnails belong in the local cache of Nextcloud and not on the external storage.
What happens if the storage is briefly unreachable?
Mounted as external storage, Nextcloud reports the folder as unavailable and everything else keeps running. If the entire data directory sits there, the instance comes to a halt. That is the most important reason for the external storage variant.
Do I need a database on the storage?
No, under no circumstances. The database stays on the server, on fast local storage. Only the files belong on the storage.
How many users can a small server handle?
For a handful up to a few dozen active users, a server with 4 to 8 GB of RAM is plenty, provided Redis and a regular background job are set up. The files live somewhere else anyway, the server only manages them.
What does the combination cost?
A small server for Nextcloud plus a Storage Server from 9.99 EUR a month for 1 TB. Storage-2 with 5 TB costs 29.99, Storage-3 with 10 TB 39.99 and Storage-4 with 20 TB 69.99. All of it with no setup fee, on a PrePaid basis and with no minimum term.

Nextcloud Storage Server Externer Speicher SMB SFTP Quota Freigaben