In this tutorial, we'll walk you through setting up your own cloud storage solution similar to Google Drive using a Raspberry Pi 5 and SSDs. By the end, you'll have a robust, private cloud storage system powered by Nextcloud. We'll cover both hardware and software setup in a step-by-step manner to keep things simple and easy to follow.
Complete video setup guide:Hardware Setup1. Gather Your Components
- Raspberry Pi 5
- Pimoroni NVMe Base
- NVMe M.2 SSD: x2
- NVME M.2 SSD Enclosure
- 64 GB SanDisk SD Card
- Pi5 27 W USB C Power Adapter
- Heat sink and fan for active cooling
2. Assemble the Hardware
- Attach the NVMe SSD to the Pimoroni NVMe Base
- Connect the Additional SSD into the enclosure and then plug to Pi
After complete setup it looks like this:
Before starting the software setup, I would like you to run through a decision which I made, and it is completely up to you to decide which way you want to go, for mine I am stating the factors which I considered to choose:
Why OS on SD card instead of using SSD over PCIe?Note: The above decision is completely dependent on user's choice, due to limitations of having only two SSDs at current, I had to arrive at the above conclusion. You can always customize it based on your needs.
Setup of RPi OS and Nextcloud:1. Flash Raspberry Pi OS
- Download Raspberry Pi Imager
- Flash the OS
2. Initial Boot and Configuration
- Insert the SD Card into Raspberry Pi
- SSH into Your Pi
3. Install Docker and Portainer
- Visit: https://pi-hosted.com/ ,from there, and install docker and portainer, more details are there in Setup Video above.
4. Install Nextcloud using Portainer
- After setting up protainer, you can use app templates to install and setup the nextcloud and nextcloud db as well, refer to the video guide for the same.
This section details how to configure Tailscale to grant secure, global access to your Nextcloud instance running on a Raspberry Pi 5.
Why Tailscale?Inspired from : Novaspirit Tech 's video: Here, you can come up with your own choice of tunnel to use based on his video.
There are several reasons why Tailscale is a great choice for this purpose:
- Ease of Use: Tailscale offers a user-friendly experience, making it simple to set up and manage a private network across geographically dispersed devices.
- Security: Tailscale utilizes WireGuard®, a modern and secure VPN protocol, to encrypt all traffic between your devices and the Nextcloud server.
- Centralized Management: Tailscale provides a web-based control panel for managing devices and access permissions, simplifying administration.
- Automatic Mesh Networking: Tailscale automatically establishes a mesh network between your devices, ensuring reliable connectivity even if one device goes offline.
Here's a step-by-step guide to setting up Tailscale for global access to your Nextcloud:
1. Install Tailscale:
Run the following command on your Raspberry Pi terminal to install Tailscale:
- Install Tailscale:
Run the following command on your Raspberry Pi terminal to install Tailscale:
curl -fsSL https://tailscale.com/install.sh | sh
This script will download and install the latest version of Tailscale for your Raspberry Pi architecture.
2. Create a Tailscale Account:
If you don't have a Tailscale account yet, head over to the Tailscale website (https://tailscale.com/) and create a free account.
3. Authenticate Your Device:
After installation, run the following command to initiate the authentication process:
sudo tailscale up
Follow the on-screen instructions to link your Raspberry Pi to your Tailscale account. This will generate a unique authentication key.
4. Configure Nextcloud:
Nextcloud configuration varies depending on the specific version you're using. Consult your Nextcloud documentation for instructions on configuring it to accept connections from your Tailscale IP address. This typically involves editing configuration files to allow access from specific IP ranges or hostnames.
5. Access Nextcloud Remotely:
Once Tailscale is configured and Nextcloud is set up for remote access, you can access your Nextcloud instance from any device with the Tailscale client installed and connected to your account. You'll use the same Nextcloud address you'd use on your local network, but your device will be routed securely through the Tailscale network.
By following these steps, you can leverage Tailscale to securely access your Nextcloud instance from anywhere in the world, all while maintaining a user-friendly and centralized management experience.
Automatically Syncing Two SSDs on Raspberry PiKeeping your data synchronized across two SSDs can be crucial for backups or redundancy. Using rsync
and cron
, you can automate this process on your Raspberry Pi. Here’s how to set it up.
Step 1: Install Rsync
Ensure rsync
is installed:
sudo apt-get update
sudo apt-get install rsync
Step 2: Create Rsync Command
Use rsync
to synchronize the directories:
sudo rsync -a --delete /mnt/PiSSD-PCIe/Nextcloud/Data/thatiotguy/files/ /mnt/PiSSD-USB/Nextcloud/
-a
: Archive mode (preserves permissions, timestamps, etc.)--delete
: Deletes files in the destination that are not present in the source- Use --delete cautiously: If the source SSD crashes, and is left with NO DATA, the destination directly will also remove all data, (Better do not use delete).
Step 3: Schedule with Cron
Automate the rsync
task to run every day at 10 PM and after every reboot.
- Open crontab:
sudo crontab -e
Note:
Do not just use crontab -e.
- Add the following entries:
0 22 * * * sudo rsync -a --delete /mnt/PiSSD-PCIe/Nextcloud/Data/thatiotguy/files/ /mnt/PiSSD-USB/Nextcloud/ >> /var/log/rsync.log 2>&1
This configuration ensures that your data is synchronized daily at 10 PM and once after every reboot, with outputs logged for verification.
By following these steps, you can maintain a synchronized copy of your important data across two SSDs, enhancing data reliability and availability on your Raspberry Pi.
Enabling watchdog:Using a watchdog for my Raspberry Pi 5, which I have set up to run Nextcloud as a personal cloud drive, ensures enhanced reliability and uptime. The watchdog detects when the Pi locks up and automatically restarts the device, guaranteeing continuous access to my files and data. This is crucial for maintaining seamless operation without manual intervention, especially if the Pi is not easily accessible. It reduces the need for frequent maintenance and protects the integrity of my stored data. The watchdog provides peace of mind, knowing that my cloud drive can self-recover from any crashes, ensuring my personal cloud is always available and efficient.
Steps:
sudo apt install watchdog
sudo nano /etc/watchdog.conf
Add the following line:
watchdog-device = /dev/watchdog
watchdog-timeout = 15
max-load-1 = 24
interface = wlan0
Now enable it:
sudo systemctl start watchdog
Conclusion:By choosing to follow these steps, you can successfully move away from Google Drive and establish your own personal cloud storage system using a Raspberry Pi 5 and SSDs. This approach allows you to securely store your data and access it globally through Tailscale and Nextcloud. This setup not only ensures data privacy but also provides a scalable and cost-effective cloud storage solution.
Comments