INSTALL | NextcloudPi + Raspberry Pi 4 + Ubuntu Core ARM64 + Docker

INSTALL | NextcloudPi + Raspberry Pi 4 + Ubuntu Core ARM64 + Docker

Why pick Raspberry Pi 4 on ARM64?

Raspberry Pi 4 is a cheap and powerful platform to run this on. I tried this initial build on an ARMhf installation and nothing worked. Not only did I have to customize the installation process for NextcloudPi I had no option to expand my server to include things like Rocket.Chat. For any of you that were considering going the armhf/ARM32 route with an installation on a Raspberry Pi 4… just don’t. I spent two weeks trying to figure out why nothing worked until I switched to ARM64 and I got everything up and running in less than an hour. (Note… if you try to get NextcloudPi running on a ARMhf installation you have to change the database used in Docker Compose to a specialized 32-bit version of MariaDB available at yobasystems/alpine-mariadb:latest)

Why pick Ubuntu Core?

Ubuntu Core is honestly the easiest and most secure solution. It is a bare bones stripped down Ubuntu distro based on ARM with no functionality beyond what is available through the Snap Store. If you were like me and started with Ubuntu Core without being familiar with Ubuntu Server it would likely -feel- like the most difficult and complex way of doing things. Without having access to basic server functions like git, wget, curl, etc it feels downright -stupid- to go this route… until you realize that the lack of this out of the box functionality (which you don’t need to install NextcloudPi or run Nextcloud on a Raspberry Pi) is a security feature, not a flaw.

The default download version for Ubuntu Core is ARMhf (ARM32) and you have to search for the ARM64 version. Ubuntu Core ARM64 for the RPI4 is available here.

Why pick Docker?

This is a personal decision. If you were to install a version of Nextcloud on a Raspberry Pi 4 running Ubuntu Core there -is- the option to run Nextcloud as a snap. I have not tried to do this as I generally dislike Snaps. I know that it is ironic to have chosen Ubuntu Core but the only Snap you have to install is Docker (and maybe Htop). Using Docker to install the NextcloudPi means I didn’t have to do anything special to get Let’s Encrypt working or to get the Databases working. It did pretty much everything itself.

Without further ado here is the process I used to get everything up and running on the Raspberry Pi 4 in about an hour:

NEXTCLOUD on Raspberry Pi 4 running UBUNTU CORE ARM64

In order to run Ubuntu Core you need to make a Ubuntu One account. The reason for this is because the target audience for Ubuntu Core are developers that use and build Snaps. Once you set up a Ubuntu One account you will need to create a certificate and upload your public SSH key into this account.

Choosing this installation process means you will have a passwordless login tied to a specific device and you will not be able to login to your Raspberry Pi 4 any other way. For me this was a security feature that hardened the system without forcing users to learn how to do the steps enabling this on manually.

As is my Raspberry Pi 4 running Nextcloud installed using this process runs about 650-750MBs out of my 4GBs of memory.

Make a Ubuntu One account

I followed this guide to set up my Ubuntu One account with my public SSH keys successfully.

  • Go to login.ubuntu.com
  • Click “I don’t have an Ubuntu One account.”
  • Verify your email.

Set up your SSH Keys

  • You need to upload your public SSH key to your account.
  • Open a terminal and run: ls -l ~/.ssh
  • If you see a file ending in .pub that is the file you need.
  • If you do not see this file run ssh-keygen and hit enter and accept all the defaults.
  • Run the command cat ~/.ssh/id_rsa.pub and copy the output.

Login to Ubuntu SSO Account, click “SSH Keys”, paste the contents that were just copied, hit “Import SSH Key”.

This is the ONLY time you need to use this account or do this process. I used it successfully on both the ARMhf and ARM64 versions I installed. The only time you may run into a problem is if you reinstall the OS you are using on the Raspberry Pi… the solution to fix this is to simply rerun the commands to generate an SSH Key.

Download Ubuntu Core 20 ARM64

Finding Ubuntu Core ARM64 on the Ubuntu website was not intuitive. All of the Raspberry Pi models direct you to Ubuntu Server. If you do find the Ubuntu Core for Raspberry Pi webpage it only gives you an option for ARMhf. Click here for a link to download Ubuntu Core ARM64.

Install using Etcher

  • You shouldn’t need to unzip the IMG file… leave it as is and use Etcher to burn it to your MicroSD card.

Setup Ubuntu Core (easy)

You can follow the Ubuntu Core for Raspberry Pi install guide here:

  • Installing Ubuntu Core is SUPER easy.
  • Insert your Ethernet Cable BEFORE you turn the Raspberry Pi on.
  • Once you insert the MicroSD card and power on the Raspberry Pi 4 you will need to use a micro-HDMI to HDMI to see the initial setup.
  1. The system will boot then become ready to configure.
  2. The device will display the prompt “Press enter to configure”.
  3. Press enter then select “Start” to begin configuring your network and an administrator account. Follow the instructions on the screen, you will be asked to configure your network and enter your Ubuntu SSO credentials.
  4. At the end of the process, you will see your credentials to access your Ubuntu Core machine:
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 with SSH into Ubuntu Core, from a machine on the same network, using the following command:

ssh <Ubuntu_One_Username>@<RPI4_IP_Address>

Your user name is your Ubuntu SSO user name, it has been reminded to you at the end of the account configuration step.

SSH into the Raspberry Pi

  • SNAP INSTALL HTOP (Optional)
    • Htop is a way to see your system resources on your physical Raspberry Pi 4 Device
  • SNAP INSTALL UFW (Optional)
    • Some of you may want to use UFW to harden your device & installation. I had issues with portions of my Nextcloud website not working once I did.
  • SNAP INSTALL DOCKER

Once you have Docker installed:

  1. Install PORTAINER
  • docker volume create portainer_data
  • docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
  1. Install NEXTCLOUDPI
  • [CREATE MOUNT FOR EXTERNAL HD]
    • sudo mkdir /media/USBDrive (or) /mnt/<drive_name>
  • [CREATE DB ACCESS FOLDER]
    • sudo mkdir /media/USBDrive/ncdata (or) /mnt/<drive_name>/ncdata
  • [GIVE DATABASES PERMISSIONS FOR DB ACCESS FOLDER]
    • sudo chown www-data:www-data /media/USBDrive/ncdata (or) /mnt/<drive_name>/ncdata
  • [MOUNT EXTERNAL DRIVE]
    • sudo mount /dev/sda5 /media/USBDrive (or) /mnt/<drive_name>
  • [DOCKER CREATE]
    • docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /media/USBDrive/ncdata:/data --name nextcloudpi --restart unless-stopped ownyourbits/nextcloudpi $DOMAIN (or) $IP

Note: If you want to use a Domain to connect to your Nextcloud instance from outside your network the only thing you need to do is go to your Domain Registrar and point the Domain at your home IP. I happen to have a static IP through my ISP and did not have to do anything special to set up a dynamic DNS service. I did not have to alter my /etc/hosts or /etc/hostname files to get things working.

I have been working on making this Nextcloud instance work since mid-February. I have tried just about every single thing possible and run into problem after problem making it essentially unusable… until I tried this way.

Since I have successfully installed NextcloudPi this way I haven’t run into any issues except two…

  1. I cannot make backups. I believe this is a permissions problem stemming from switching my ARMhf installation to an ARM64 version. It says it works in the NextcloudPi Webgui but and I can see a backup being made in my external harddrive but it always ends up being an empty space.
  2. I am unable to get any Document Server to run (including the Collabora Code Arm64 plugin) which really sucks. I can get Collabora CODE running and connected to a server but whenever I try this my Nextcloud installation grinds to a halt and becomes unusable.
  3. The issue is discussed at length here and affects quite a few people.

Beyond that I am running the most up to date version of Nextcloud. Nextcloud Talk runs impeccably. I don’t have any issues uploading, downloading, adding plugins, or anything.

One small issue I had was that I if I checked in Portainer it had the ncdata volume I created listed as “unused”. Deleting the volume broke the Nextcloud instance. Editing the NextcloudPi docker instance and reattaching it to a correctly structured volume broke the instance. This is because the way the docker run command is formed it creates a bind instead of a path in the volume so if you see “unused” listed next to your volume this is fine and nothing is broken.

2 Likes