This post is roughly 7 years old; originally published on December 13, 2016! The information presented here may be out of date and inaccurate.
I recently bought the Nextcloud Box. When it came to setting it up I ran into a problem, I only had Raspberry Pi 3 computers available and at the time of writing the microSDHC card provided with the Nextcloud Box only supports the Raspberry Pi 2. Bummer!
This guide outlines how to use Ubuntu Core on the Raspberry Pi 3 to run Nextcloud provided as a snap from the Ubuntu store.
If you’re not familiar with Ubuntu Core, here’s a quote:
Ubuntu Core is a tiny, transactional version of Ubuntu for IoT devices and large container deployments. It runs a new breed of super-secure, remotely upgradeable Linux app packages known as snaps
After following this guide Ubuntu Core and any installed snaps (and their data) will reside on the SD card and the 1TB hard disk in the Nextcloud box will be available for file storage. This guide explains how to:
removable-media
interface to allow access to the hard diskI explained the main steps in this post but you really should read and follow the Get started with a Raspberry Pi 2 or 3 page as it fully explains how to use a desktop computer to download an Ubuntu Core image for your Raspberry Pi 2 or 3 and copy it to an SD card ready to boot.
Here’s how to create an Ubuntu Core microSDHC card for the Raspberry Pi 3 using an Ubuntu desktop:
An Ubuntu SSO account is required to setup the first user on Ubuntu Core:
Insert the Ubuntu Core microSHDC into the Raspberry Pi, which should be in the assembled Nextcloud Box with a keyboard and monitor connected. Plug in the power.
This device is registered to <Ubuntu SSO email address>.
Remote access was enabled via authentication with the SSO user <Ubuntu SSO user name>
Public SSH keys were added to the device for remote access.
Once setup is done, you can login to Ubuntu Core using ssh, from a computer on the same network, using the following command:
ssh <Ubuntu SSO user name>@<device IP address>
The user name is your Ubuntu SSO user name.
Should you need to reconfigure the network at a later stage you can do so with:
sudo console-conf
Log in to your Raspberry Pi 3 running Ubuntu Core via ssh.
ssh <Ubuntu SSO user name>@<device IP address>
This will create a single partition formatted with the ext4 filesystem.
sudo fdisk /dev/sda
Do the following to create the partition:
Command (m for help): o
Created a new DOS disklabel with disk identifier 0x253fea38.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-1953458175, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-1953458175, default 1953458175):
Created a new partition 1 of type 'Linux' and of size 931.5 GiB.
Command (m for help): w
Now format the partition and give it the label data. This label will be used to reference it for mounting later:
sudo mkfs.ext4 -L data /dev/sda1
Most of the Ubuntu Core root file system is read-only, so it is not
possible to edit /etc/fstab
. Therefore we’ll use systemd
to achieve that.
Be aware of one of the systemd.mount
pitfalls:
Mount units must be named after the mount point directories they control. Example: the mount point /home/lennart must be configured in a unit file home-lennart.mount.
Yes that’s right! The unit filename must match the mount point path.
Create the media-data.mount
unit:
sudo vi /writable/system-data/etc/systemd/system/media-data.mount
Add the following content:
[Unit]
Description=Mount unit for data
[Mount]
What=/dev/disk/by-label/data
Where=/media/data
Type=ext4
[Install]
WantedBy=multi-user.target
Reload systemd, scanning for new or changed units:
sudo systemctl daemon-reload
Start the media-data.mount
unit, which will mount the volume, and also
enable it so it will be automatically mounted on boot.
sudo systemctl start media-data.mount
sudo systemctl enable media-data.mount
And just like any other unit, you can view its status using
systemctl status
:
sudo systemctl status media-data.mount
Make sure Ubuntu Core is up-to-date and reboot.
sudo snap refresh
sudo reboot
After the reboot, make sure /media/data
is mounted. If not double
check the steps above.
The Nextcloud snap uses the removable-media
interface, which grants
access to /media/*
, and requires manual connection:
sudo snap install nextcloud
sudo snap connect nextcloud:removable-media core:removable-media
Browse to the Nextcloud IP address and create the admin user account, for example:
In the examples below replace nextcloud.local
with the IP address or
hostname of your Nextcloud Box and replace example.org
with your domain.
Enable the External Storge app via:
Configure External Storage app via:
Use these settings:
/media/data
Configure your outgoing email settings via:
I use Sendgrid for sending email alerts from my servers and devices. These are the settings that work for me:
apikey
theactualapikey
It is strongly recommend that you use HTTPS if you intend to expose your Nextcloud to the Internet.
First do a test to see if you can install a Let’s Encrypt certificate:
sudo nextcloud.enable-https -d
Answer the questions:
Have you met these requirements? (y/n) y
Please enter an email address (for urgent notices or key recovery): [email protected]
Please enter your domain name(s) (space-separated): nextcloud.example.org
Attempting to obtain certificates... done
Looks like you're ready for HTTPS!
If everything went well, then install the certificate
sudo nextcloud.enable-https
Answer the questions again:
Have you met these requirements? (y/n) y
Please enter an email address (for urgent notices or key recovery): [email protected]
Please enter your domain name(s) (space-separated): nextcloud.example.org
Attempting to obtain certificates... done
Restarting apache... done
If Let’s Encrypt didn’t work for you, you can always use Nextcloud with a self-signed certificate.
sudo nextcloud.enable-https -s
If you need to make any tweaks to the Nextcloud configuration file you can edit it like so:
sudo vi /var/snap/nextcloud/current/nextcloud/config/config.php
If you have manually edited the Nextcloud configuration you may need to restart nextcloud:
sudo snap disable nextcloud
sudo snap enable nextcloud
So there it is, Nextcloud running on Ubuntu Core powered by a Raspberry Pi 3. The performance is reasonable, obviously not stellar, but certainly good enough to move some cloud services for a small family away from the likes of Google and Dropbox. Now go and install some Nextcloud clients for your desktops and devices :-)