Your cloud storage at home

Roman Marakulin
9 min readJul 7, 2022

--

My story

A few days ago, I stumbled upon a hard drive that I hadn’t used for a long time. It was a good old storage with a half terabyte on board from Western Digital company. I was glad to find it, especially, when I’m constantly run out of memory with my 7 years old macbook. The main problem is that I hate to connect storages to a laptop constantly and have them around. Particularly, when you are out of home. Therefore, why not just create my own cloud with a raspberry pi (luckily, I have one, specifically, raspberry pi 3B model) and this good old HD? Moreover, your own cloud helps you to avoid commercial solutions, such as google drive, dropbox, etc. I’m not a big fun of these, mostly because, even they say your data is safe and protected in the most secure way, I do have a feeling, that someone (even robots/crawlers) can list and open my files/images/some private documents. Furthermore, with your own solution, you have an infinite possibilities to customise it the way you want.

Thus, in this article I want to share my research of different ‘your own cloud’ solutions, highlight pros and cons, if any and choose truly the best option to go with.

What I have:

  1. Raspberry Pi 3B
  2. microSD card for Raspberry Pi
  3. 0.5 TB WD hard drive with SATA 1.0a interface

On the Internet there are not too many solutions, so I’ve decided to set up all of them (well-known ones), compared download/upload speeds, simplicity of installation, maintenance, ease of use.

I’ve found these free popular options, that I want to test:

  1. OwnCloud: https://owncloud.com
  2. NextCloud: https://nextcloud.com (it’s kinda a spin-off of ownCloud)
  3. Seafile: https://www.seafile.com/en/home/

Although, there are several articles with comparison of these, they don’t really ‘compare’ perfomance, only appearance, which is strange to me, so I’ve decided to make my own research.

The most important characteristic for me is speed, therefore to compare different solutions, I’ve created 3 sample folders to test speed on:

  1. jpg: 20 jpg files (9,2 MB)
  2. pdf: 76 pdf files (252,3 MB)
  3. mkv: 1 mkv file (4,69 GB)

For every cloud set up I measured speed to download/upload files several times — a table at the end of the article.

TLDR: Seafile showed the best performance.

Prerequisites

To have a fair competition, the hard drive was formatted to ext4 and Raspberry Pi OS was installed: https://www.raspberrypi.com/software/.

  1. The process to install raspberry pi OS is straightforward, so you can follow the original manual. One thing, that I should mention, that during an installation process you can set up a hostname, enable ssh, username and password and even configure wireless LAN, which is useful, if you don’t have an additional monitor to configure these features afterwards. Just press a gear in the lower right corner and it shows these “Advanced options”.
Raspberry PI OS installation menu

After the installation, your microSD is ready and you can insert it into a raspberry pi. After some time (let Raspberry Pi a minute or two to boot) you can connect hard drive to it and ‘ssh’ into raspberry pi (below all commands — in terminal)

First, we need to get its IP (run it from your PC in your local/home net with a raspberry pi):

ping raspberrypi.local # give an <ip> of raspberry pi in your local net

Then, using our credentials (username, password) from installation phase we can connect to raspberrypi through a terminal:

ssh <username>@<ip>

2. To format your hard drive to ext4 I prefer to do this:

lsblk — list block devices; device <-> mountpoint mapping. It gives you understanding where your hard drive is mounted. For example, my HD was mounted to /dev/sda1.

sudo umount -fl /dev/sda1 — unmount your drive.

Then:

sudo mkfs -t ext4 /dev/sda1 # format a partition
sudo apt-get install e2label # install e2label if needed
sudo e2label /dev/sda1 blackhd # give the file system on the partition a label. My HD has black color.

Then, I set up an automount of the external drive by appending /etc/fstab: sudo nano /etc/fstab with this line: /dev/sda1 /media/blackhd ext4 defaults 0 1 .

Create a mount point and mount HD:

sudo mkdir /media/blackhd # create mount point (folder)
sudo mount /media/blackhd # mount hard drive
sudo chmod 755 /media/blackhd # just to be sure, that we will have an access to the folder

OwnCloud

(I followed this manual: https://www.makeuseof.com/raspberry-pi-owncloud/, but some steps have to be updated to fit the last ownCloud version).

  1. First, you need to install required components for OwnCloud:
sudo apt-get install apache2 # install apache2
sudo apt-get install sqlite
sudo apt-get install php7.4 php7.4-gd sqlite php7.4-sqlite php7.4-curl php7.4-zip php7.4-xml php7.4-intl php7.4-mbstring php7.4-mysqlnd

The last line is important. For now, ownCloud doesn’t support php 8.0 and the max supported version is ‘7.4’.

2. Once, they all installed, restart the Apache web server:

sudo service apache2 restart

3. Now you are ready to install owncloud itself. Get the latest version with the command:

wget https://download.owncloud.com/server/stable/owncloud-complete-latest.zip

(or go to https://owncloud.com/download-server/ and download from there and then copy it to raspberry pi with scp, for example). Then, unzip the archive:

sudo mv owncloud-complete-latest.zip /var/www/html && cd /var/www/html
sudo unzip -q owncloud-complete-latest.zip

4. Next, we need to create a directory for ownCloud data:

sudo mkdir /media/blackhd/oc_storage
sudo chown www-data:www-data /media/blackhd/oc_storage
sudo chmod 750 /media/blackhd/oc_storage

And give some permissions:

sudo chmod 750 /var/www/html/owncloud
sudo mkdir /var/lib/php/session
sudo chmod 750 /var/lib/php/session

5. After that, you can reboot (because all is set up) by typing sudo reboot and after the reboot go to the address from your web browser: <raspberry_pi_ip>/owncloud to get an access to owncloud login screen.

OwnCloud login view

And that’s it. Your OwnCloud is set up!

The interface of OwnCloud is simple enough with a minimum number of configurations, so you can start using it right away.

OwnCloud main view
OwnCloud settings view

But the upload speed is not as good as I thought. For small jpg files it took more than a second to upload it (images in average are around 450 kb).

I tried to change sqlite to mysql as a database backend (as was proposed), but it didn’t help much.

NextCloud

NextCloud installation process is the same as for OwnCloud. You can download the latest release from https://download.nextcloud.com/server/releases/ and unzip it into the same folder /var/www/html, so you could use installed earlier, Apache server.

For NextCloud, in contrast to OwnCloud, there is a separate custom image of Raspbian Lite — NextCloudPi, so you don’t have to worry about installing all dependencies. NextCloudPi can be installed directly as an OS instead of Raspberry Pi OS, which makes it even simpler to use.

The interface of NextCloud is marvellous and functionality is beyond the limits. You can even use a shared calendar and a straightforward app for chatting is on board. I like the interface more, but the downside is that we are running it on our poor raspberry pi, so almost after every click on an icon or a menu section, I see a 2–5 seconds spinning wheel. With a more powerful hardware I would definitely prefer NextCloud.

NextCloud main view (photos/folder/etc)
NextCloud settings view
NextCloud calendar app
NextCloud app for chatting

In terms of speed, it turned out to be the same as OwnCloud, so moving on.

Seafile

Mostly, I followed this manual: https://draptik.github.io/posts/2014/04/21/installing-seafile-on-raspberry-pi/

  1. You should download the proper version from here: https://github.com/haiwen/seafile-rpi/releases
    To know which version to download you can check it by typing:
    lsb_release -a
    uname -m
    in a command line. For example, I have:
    Raspbian GNU/Linux 11 (bullseye), armv7l
    Thus, download (with the same wget command) and unpack it with
    tar -xvzf seafile-server*
  2. Then, you need to install sqlite3 if you haven’t done this earlier:
    sudo apt-get install sqlite3
  3. After that, you can just run
    ./setup-seafile.sh and fill all required fields
  4. By default it creates /home/<username>/seafile-data for storing data (and you can’t change it during an installation process), so let's change this, because we want to store data in our external storage, not on an sd card.
mkdir /media/blackhd/seafile-data
mv /home/<username>/seafile-data/* /media/blackhd/seafile-data/
rm -r /home/<username>/seafile-data
ln -s /media/blackhd/seafile-data /home/<username>/seafile-data

5. Make Seafile available outside raspberry pi itself:
Edit file ~/conf/gunicorn.conf.py (for example with vim) and change bind param from ‘127.0.0.1:8000’ to ‘0.0.0.0:8000’

6. Finally, run seafile by typing consequentially:

./seafile.sh start
./seahub.sh start

7. Optionally, you can add these commands to autostart (so that seafile starts after raspberry pi restart):

crontab -e And append this line (change <username> accordingly, of course):@reboot /home/<username>/seafile-server-latest/seafile.sh start && /home/<username>/seafile-server-latest/seahub.sh start

Some problems, that I encountered, while setting a Seafile cloud:

  1. There is a possibility (if you haven’t done it before), that you need to change an owner of folder /media/blackhd/seafile-data by typing:
    sudo chown -R <username>: /media/blackhd/seafile-data
  2. It’s not a production ready solution. You should follow the official manual how to deploy it with nginx: https://manual.seafile.com/deploy/deploy_with_nginx/
  3. I had a problem with files uploading behind nginx (i.e.: “80 port was used for upload-aj”), although I changed ports in configs as was suggested. You should change ports (and urls) from admin settings in UI as well: https://stackoverflow.com/questions/36385920/seafile-file-upload-does-not-work-even-after-setting-the-file-server-root-var
  4. Additionally, if you don’t see avatars, then, most probably, you faced the same problem as me: https://forum.seafile.com/t/seahub-avatar-location-failure-apache-ubuntu-community-manual/9339

The UI of this cloud is quite ordinary — nothing special, in my opinion, but that’s not the point. It’s still easy to navigate and use it as a your own home cloud. I was looking for the fastest solution.

Seafile main view
Seafile settings view

I made several measurements in the same way as before and I was very impressed. Seafile cloud turned out to be the fastest solution. It was almost 3 times faster than nextCloud for small, jpeg files.

Results and conclusions

I present all results obtained earlier in a separate table. I didn’t expect to see a difference in terms of download speed, but for uploading, seafile 3x faster than nextcloud for small (500 KB), jpeg files, 25 percent faster for pdf files (~3 MB) and ~10% faster for huge (4,7 GB), mkv files.

Comparison of uploading (first columns) and downloading (the last column) speeds.

Following manuals, mentioned above, I was able to set up my own cloud with a raspberry pi with static ip in a home network, made it production ready with nginx and no-ip service (https://www.noip.com) to have my unique name for the cloud and made it possible to work with it from anywhere. So far, I’ve found only one drawback — Seafile, in contrast to OwnCloud and NextCloud saves files in some weird way. You won’t be able to see original files, that you uploaded to a storage. That’s how my storage looks like now:

/media/blackhd/seafile-data/storage
-|blocks
--|52ad7c5f-403b-4949-a12a-ed1a5a537d69
---|86
----|63a70ef30a5987b440a621483af2044bae1e0a
--|...
-|commits
--|...
-|fs
--|...

So, if someday seafile crashes it won’t be easy to restore my files (but it’s not impossible: https://gist.github.com/JFWenisch/50c48bd4706e6762ef531b7b3041ad1c).

At the time of writing, I have used the seafile as my own private cloud for 2 weeks and I can’t say that I’m dissatisfied with something. Moreover, I have plans to expand its functionality turning it into an infrastructure for my family.

--

--

Roman Marakulin

I write about Technologies, Software and my life in Spain