Install Nextcloud with External Storage as Primary Storage

This guide will take you through the steps of installing Nextcloud using the snap installer on a DigitalOcean droplet with a Volume as primary storage. We’ll start by creating a new droplet and finish up with an SSL secured installation of Nextcloud.

Save $10 when signing up with DigtalOcean (affiliate link)

Caveat: When installing Nextcloud using the snap installer you are trading convenience for flexibility. The snap version has configuration limits, but that also means less can go wrong. As the snap includes everything needed, including all required packages and dependencies, you don’t need to do most of the manual configuration.

Who is this for?

Anyone who prefers to keep their data under their control instead of using one of the big services like Dropbox and wants an easy to maintain install of Nextcloud. Snaps usually auto-update, and the Nextcloud snap generally has the most recent, stable version.

Why use a volume as primary storage? This keeps your data separate from your Nextcloud install making it less likely you will lose data in the event of a server fault.

I find that using an SSD external drive (aka block storage or Volumes in DigitalOcean) works better than object storage (Spaces with DigitalOcean or buckets with Amazon S3) because Nextcloud has a bug and doesn’t always count object storage towards storage quotas.

This guide assumes you have some familiarity with the Linux terminal, DigitalOcean, and a domain or subdomain you want to use with Nextcloud.

Step 1: Create a droplet of your desired size using Ubuntu 18.04.


  • As you will be using a volume for storage, CPU and RAM are your primary considerations. Disk space won’t be an issue.
  • You can always increase the number of CPU’s and the amount of RAM, up or down by resizing the droplet. But you cannot resize disk size down. So it is best to start with a small instance and then resize up as needed.

2) Create a volume of the desired size.

  • Just like droplets, you can increase the size of the volume later but you cannot decrease it, so start small and increase as needed.

Be sure to choose the “Manually Mount and Format” option, not the “Automatically Mount and Format” option.

By default, DigitalOcean mounts Volumes on  mnt . The snap version needs the volume mounted on  media instead.

Name the volume something memorable for ease of use.

3) Login to  ssh root@ipaddress

You will be prompted to enter your password and then to reset your password. Be sure to choose a strong password. Remember, you are responsible for your security!

4) Update the server. First: sudo apt-get update then: sudo apt-get upgrade .

5) Run kernel update (or skip this step and let step 7 take care of this for you automatically)

sudo apt-get install linux-virtual

6) Clean up after updates: sudo apt autoremove

7) Next, we will setup Canonical Livepatch Service for Managed live kernel patching. Visit to register.

After registering with Canonical, you will be given a Livepatch Key, be sure to make a note of it.

Now, set up your droplet with Livepatch.

sudo snap install canonical-livepatch

sudo canonical-livepatch enable YourLivepatchKey

Replace “YourLivepatchKey” with your key.

8) Next, let’s get your volume ready to go.

First, we need to format it:

sudo mkfs.ext4 -F /dev/disk/by-id/scsi-0DO_Volume_yourVolumeName

Then we need to create a mount point, mount the volume, and change fstab so the volume will be mounted after reboot.

Note: use /media/ instead of default recommendation of /mnt/ from Digital Ocean as Nextcloud installed by snap can’t access mnt for primary storage!

Remember to replace yourVolumeName in the commands below with the name of your volume

mkdir -p /media/yourVolumeName

mount -o discard,defaults /dev/disk/by-id/scsi-0DO_Volume_yourVolumeName /media/yourVolumeName

echo /dev/disk/by-id/scsi-0DO_Volume_yourVolumeName /media/yourVolumeName ext4 defaults,nofail,discard 0 0 | sudo tee -a /etc/fstab

Now let’s check to see if your volume is mounted: lsblk

Normally, if it is the first and only volume mounted on that droplet you will see something like:

sda with a mount point /media/yourVolumeName

9) Set up a domain or subdomain for Nextcloud and point it to the droplet. Depending on the TTL you select you may need to wait an hour before the subdomain resolves.  Be sure your domain resolves to the correct IP address before continuing!

10) Now comes the fun part: install Nextcloud using snap: sudo snap install nextcloud

11) Now we need to tell Nextcloud to use the volume as primary. First set Nextcloud up for removable media:

sudo snap connect nextcloud:removable-media

Then we need to complete the install of Nextcloud. We’ll do this manually from the terminal instead of the web browser as we don’t need to log in yet:

sudo nextcloud.manual-install your_username your_password

Now, set up a directory for Nextcloud on your volume, so Nextcloud isn’t using the root of the volume. This is so the lost&found folder is not visible within Nextcloud UI.

You will need to navigate to /media/yourvolume

Then mkdir yourNextcloudData (name this folder what you wish)

Now you’ll need to edit Nextcloud’s config.php to point to the new directory:

sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php

change the 'datadirectory' => 'nextclouds default directory path' to
'datadirectory' => '/media/yourVolume/yourNextcloudData'

Disable Nextcloud sudo snap disable nextcloud and then move the data directory: sudo mv /var/snap/nextcloud/common/nextcloud/data/.* /media/yourVolume/yourNextcloudData

Note depending on the snap version you may see an error about being unable to move the directory, but as far as I can tell it made no difference. I disregarded and moved on, and months later my installation is still working fine.

Now re-enable Nextcloud: sudo snap enable nextcloud

12) Now we need to set up the trusted domains. I recommend you set up the IP address, the and the (assuming you used a subdomain, otherwise just the root domain and www. rootdomain).

sudo nextcloud.occ config:system:set trusted_domains 1 --value=ip_address sudo nextcloud.occ config:system:set trusted_domains 2 sudo nextcloud.occ config:system:set trusted_domains 3

13) Finally Set up HTTPS SSL using LetsEncrypt.

Note this step requires your domains set up in step 16 are already working, so make sure your enough time as passed as determined by your TTL or LetsEncrypt may fail!

First, make sure the ports are open on your firewall. LetsEncrypt expects 80 and 443 so:

sudo ufw allow 80,443/tcp

Then, run the Nextcloud command to setup LetsEncrypt

sudo nextcloud.enable-https lets-encrypt

It will ask you for an email address for recovery and then a list of the domains you want to be included separated by spaces. You should enter both the www and not www versions of your domain here.

14) Go to your domain in the browser and log in with your Nextcloud username and password. If everything worked, you should have a functional and secure install of Nextcloud.

Leave a Reply

Your email address will not be published. Required fields are marked *