Create your own private cloud using Raspberry Pi for your photos and documents

Written by Zahid on
Create your own private cloud using Raspberry Pi for your photos and documents

With Google ending their unlimited free storage for photos after June 1, 2021, most of you are looking for solutions that that is free and gives complete control over your data.

I like to have complete control over my data and so I created my local private cloud to store my photos and documents, and I would like to share step-by-step guide on how I achieved that.

With storage devices prices hitting an all-time low this Black Friday it’s the best time to run your own cloud. Let’s dive in.

Hardware requirements:

  1. Raspberry Pi 4 (Pi 4 is not necessary. You can use Raspberry Pi 3)
  2. External USB storage (preferably HDD)

Presuming you have NOOBS or Raspberry Pi OS installed on your Pi here are the steps.

Step 1 : Assign an IP to your Raspberry Pi
This can be found in your router settings. Based on your router brand you can go through the documentation to set it up. This is particularly important because you don’t want to reconnect all your devices again when you reboot your Raspberry Pi. (A next available IP will be assigned if you don’t assign an IP)

Step 2 : Install Docker

This is will allow you to run a NextCloud container with zero configuration.

  • Update your Pi OS by:
     sudo apt-get update && sudo apt-get upgrade
  • Download Docker installation shell script
     curl -fsSL -o
  • Run Docker installation script:
     sudo sh

Step 3 : Format your hardrive to ext4 filesystem

  • Format:
     sudo mkfs.ext4 -F -O ^64bit -L "YOUR_LABEL" /dev/sda1

Step 4 : Connect your external USB HDD to you Raspberry Pi and mount it to a permanent location

  • Make a directory in Raspberry Pi to use that as a mount folder:
     mkdir /media/pi/YOUR_LABEL
  • Open mount config that runs when you boot your Raspberry Pi
     sudo nano /etc/fstab
  • Add below line to mount you external HDD permanently
     LABEL=YOUR_LABEL /media/pi/YOUR_LABEL ext4 defaults 0 2

    Note: YOUR_LABEL is the name of your hardrive

    After adding the line save and exit the editor by Ctrl+o (write out) and Ctrl+x (exit)

Step 5 : Update permissions on your hardrive so that only Nextcloud app can add or update files on you external hardrive

  • Change the owner of your mapped folder from HDD to www-data:
     sudo chown -R www-data:www-data /media/pi/YOUR_LABEL/nextcloudpi/
  • Change permission of the folder to only allow owner to add or update the files:
     sudo chmod -R 0750 /media/pi/YOUR_LABEL/nextcloudpi/

Step 6 : Run NextCloud Docker container and map data its data directory to your external HDD

  • Download Nextcloud pi docker image and run using:
     docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /media/pi/YOUR_LABEL/nextcloudpi/data:/data --name nextcloudpi ownyourbits/nextcloudpi-armhf

    Note: Please replace your with the IP that you assigned to your Raspberry Pi

Step 7 : NextCloud Activation

  • Activate your NextCloud by visiting from any computer that is connected to your network. You will be presented with two sets of credentials.
    1. NextCloudPi User: This is soley for application administration purposes.
    2. NextCloud User: This is a NextCloud admin user, who can have their files, photos etc added to the their account and can also add additional users to the cloud.

Step 8 : Download iOS and Android app and connect

  • Download NextCloud app on your iOS or Android
  • On the first screen add your Raspberry Pi IP address after which you will be promted to input user credentials you go it step 5. You can create multiple users, assign them storage quota an so on.


  • I highly recommend that you keep your cloud to your local network
  • Always take weekly backup of your cloud hardrive to another hardrive that is offline. It is ideal to have 3 copies of your data in which one copy should be at different location. Here is how you can sync two hardrives using rsync so that only updated files are synced.

    Dry run:

     sudo rsync -aunv /mnt/f/nextcloudpi/* /mnt/e/nextcloudpi-backup/nextcloudpi/

    Copy modified or new files:

     sudo rsync -auv /mnt/f/nextcloudpi/* /mnt/e/nextcloudpi-backup/nextcloudpi/
  • Raspberry Pi 4 comes with USB 3.0 which has higher transfer rates. You will notice some performance issue if you use Rapspberry Pi 3 or lower.

Advantage of this approach is that your data is stored completely on external hardrive and it does not rely on Raspberry Pi installation. You can swap Raspberry Pi and reinstantiate NextCloud again with the steps mentioned above. You can skip the activation step (#6)