$1.99 a month to store a measly 100GB of data on Google Drive?!? Yeah right!
You must be saying to yourself: “I want to make permanent, large, private, free cloud storage for under $100”
If you are, welcome to this guide. I will show you how to take any old hard drive and a cheap raspberry pi computer and turn it into a cloud storage space for yourself or anyone you want to share it with.
Preemptive questions and answers (READ THESE)
1.) I used a Raspberry Pi Model B specifically for the following reasons: It’s a cheaper model, it has *just enough* RAM to work at speeds that are tolerable to use, and it can connect to WiFi, so it makes this project much easier. However, a Raspberry Pi Model 3 A+, which costs $25 ($15 less), is also acceptable to use, as it has the same features, but only half as much ram.
2.) If you have a laptop or desktop computer already, you wont have to buy a monitor or keyboard, saving at least $60! I will go over something called SSH remote connection in this guide that lets you connect to and work on the RaspberrPi computer remotely.
The Shopping List (check the list below this one for specific links)
Raspberry Pi Model B (or if you have money, buy one of the newer models!)
Power Supply that is compatible with your model of Raspberry Pi computer (the Model 3 B has a microUSB power port)
A spare keyboard and mouse
A computer monitor that you can hook up to
A MicroSD card
A MicroSD card reader
A hard drive to store your stuff on.
If you use an internal SSD or HDD, you will also need a SATA to USB Adapter (common SSDs (2.5 inch models), and all HDDs need to be powered, so you will be best off getting a model that takes power from a wall outlet)
Here are some shopping links
Raspberry Pi Model 3 B (~$40)
I used a micro usb charger I had lying around ($2)
NOTE: Any wall charger block and any USB to microUSB cable will work just fine!
Keyboard and Mouse
Monitors
MicroSD Card
SanDisk 32Gb/64Gb/128Gb microSD card ($0.99/$0.99/$4/)
MicroSD Card Reader
An external SSD or HDD is a fine choice if you don’t want to buy a SATA to USB adapter.
Kodak X200 Portable SSD 256GB/512GB/1TB ($22/$31/$56)
Seagate Portable HDD 1TB/2TB/4TB External ($60/$80/$120)
Internal SSD or HDD
SATA to USB (only if you are using internal drives as your storage)
NOTE: New stuff is great, but buying it used on online marketplaces like FaceBook Marketplace, OfferUp, or Ebay is just as good and twice as cheap!
The Guide: Turn a Raspberry Pi into Sharable Cloud Storage
Table of Contents
Step 1: Prepare Your Raspberry Pi
Install Raspberry Pi OS
Enable SSH
Set a Static IP Address
Connect via SSH
Update the System
Step 2: Set Up Duck DNS
Create a Duck DNS Account
Add a Domain
Set Up the Duck DNS Updater
Configure Port Forwarding
Step 3: Set Up External Storage
Connect Your External Drive
Mount the External Drive
Set Permissions
Step 4: Install Apache, MariaDB, and PHP
Install Apache
Install MariaDB (MySQL)
Secure MariaDB
Install PHP and Required Extensions
Install
php-smbclient
Step 5: Install Nextcloud
Download Nextcloud
Extract Nextcloud
Set Permissions
Step 6: Configure Apache for Nextcloud
Create a New Apache Configuration File
Add the Configuration Content
Enable the Site and Restart Apache
Step 7: Set Up a Database for Nextcloud
Log in to MariaDB
Create a Database and User
Step 8: Complete the Nextcloud Setup
Access Nextcloud in Your Browser
Follow the Setup Wizard
Step 9: Set Up HTTPS with Let’s Encrypt
Install Certbot
Obtain an SSL Certificate
Restart Apache
Step 10: Configure External Storage in Nextcloud
Log in to Nextcloud as an Admin
Add External Storage
Resources
Links and Additional Information
- How to Add More Storage
Step 1: Prepare Your Raspberry Pi
1.1 Install Raspberry Pi OS
Download the latest Raspberry Pi OS from the official website.
Flash the OS to a microSD card using a tool like Raspberry Pi Imager.
Make sure to toggle on ‘Enable SSH’ with ‘Use password authentication’ under the ‘Services’ tab. If you do, skip Step 1.2
Insert the microSD card into your Raspberry Pi and power it on.
1.2 Enable SSH
During the initial setup (or after booting), enable SSH:
sudo raspi-config
Navigate to Interfacing Options > SSH and enable it.
Alternatively, create an empty file named
ssh
in the boot partition of the microSD card to enable SSH headlessly:touch /boot/ssh
1.3 Set a Static IP Address
Edit the DHCP client configuration:
sudo nano /etc/dhcpcd.conf
Add the following lines (replace
192.168.1.100
with your desired IP address):interface eth0 static ip_address=192.168.1.100/24 static routers=192.168.1.1 static domain_name_servers=8.8.8.8 8.8.4.4
Save and exit (
Ctrl+O
,Enter
,Ctrl+X
), then restart the networking service:sudo systemctl restart dhcpcd
1.4 Connect to Your Raspberry Pi via SSH
From another computer, use an SSH client (e.g.,
ssh
on Linux/Mac or PuTTY on Windows) to connect to your Raspberry Pi:ssh pi@192.168.1.100
The default username is
pi
, and the default password israspberry
. Change the password immediately for security:passwd
1.5 Update the System
Run the following commands to update your system:
sudo apt update && sudo apt upgrade -y
Step 2: Set Up Duck DNS
2.1 Create a Duck DNS Account
Go to Duck DNS and sign up using your Google, GitHub, Reddit, or Twitter account.
2.2 Add a Domain
Choose a subdomain (e.g.,
mycloud
) and click Add Domain.
2.3 Set Up the Duck DNS Updater
Install the Duck DNS updater script on your Raspberry Pi:
mkdir ~/duckdns cd ~/duckdns nano duck.sh
Add the following script (replace
your_token
andyour_domain
with your Duck DNS token and domain):#!/bin/ echo url="https://www.duckdns.org/update?domains=your_domain&token=your_token&ip=" | curl -k -o ~/duckdns/duck.log -K -
Save and exit (
Ctrl+O
,Enter
,Ctrl+X
), then make the script executable:chmod +x duck.sh
Test the script:
./duck.sh
Set up a cron job to run the script every 5 minutes:
crontab -e
Add the following line:
*/5 * * * * ~/duckdns/duck.sh >/dev/null 2>&1
2.4 Configure Port Forwarding
Log in to your router’s web interface (usually at
http://192.168.1.1
orhttp://192.168.1.254
).Forward ports
80
(HTTP) and443
(HTTPS) to your Raspberry Pi’s local IP address (e.g.,192.168.1.100
).
Step 3: Set Up External Storage
Step 3: Set Up External Storage
This step now includes formatting the external drive.
3.1 Connect Your External Drive
Connect your external drive to the Raspberry Pi.
3.2 Identify the Drive
List all connected drives to identify your external drive:
sudo lsblk
Look for your external drive (e.g.,
/dev/sda1
).
3.3 Unmount the Drive (if already mounted)
Unmount the drive if it is automatically mounted:
sudo umount /dev/sda1
3.4 Format the Drive
Format the drive to
ext4
(recommended for Linux compatibility):sudo mkfs.ext4 /dev/sda1
Note: Formatting will erase all data on the drive. Back up any important files before proceeding.
3.5 Create a Mount Point
Create a directory to mount the external drive:
sudo mkdir -p /mnt/external_drive
3.6 Mount the Drive
Mount the drive to the created directory:
sudo mount /dev/sda1 /mnt/external_drive
3.7 Set Up Automatic Mounting on Boot
Edit the
/etc/fstab
file to mount the drive automatically on boot:sudo nano /etc/fstab
Add the following line (replace
/dev/sda1
with the correct device name):/dev/sda1 /mnt/external_drive ext4 defaults 0 2
Save and exit (
Ctrl+O
,Enter
,Ctrl+X
).
3.8 Set Permissions
Ensure the external storage is accessible to the
www-data
user (used by Apache):sudo chown -R www-data:www-data /mnt/external_drive sudo chmod -R 755 /mnt/external_drive
Step 4: Install Apache, MariaDB, and PHP
4.1 Install Apache
sudo apt install apache2 -y
4.2 Install MariaDB (MySQL)
sudo apt install mariadb-server -y
4.3 Secure MariaDB
sudo mysql_secure_installation
Follow the prompts to set a root password and secure the database.
4.4 Install PHP and Required Extensions
sudo apt install php php-mysql php-gd php-curl php-zip php-xml php-mbstring php-bz2 php-intl php-imagick php-gmp php-bcmath php-imap php-opcache unzip wget -y
4.5 Install php-smbclient (if this fails dont worry and move on)
sudo apt install php-smbclient
Step 5: Install Nextcloud
5.1 Download Nextcloud
wget https://download.nextcloud.com/server/releases/latest.zip
5.2 Extract Nextcloud
sudo unzip latest.zip -d /var/www/ sudo mv /var/www/nextcloud /var/www/nextcloud
5.3 Set Permissions
sudo chown -R www-data:www-data /var/www/nextcloud sudo chmod -R 755 /var/www/nextcloud
Step 6: Configure Apache for Nextcloud
6.1 Create a New Apache Configuration File
sudo nano /etc/apache2/sites-available/nextcloud.conf
6.2 Add the Configuration Content
<VirtualHost *:443> DocumentRoot "/var/www/nextcloud" ServerName mycloud.duckdns.org <Directory /var/www/nextcloud/> Options +FollowSymlinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined </VirtualHost>
6.3 Enable the Site and Restart Apache
sudo a2ensite nextcloud.conf sudo systemctl restart apache2
Step 7: Set Up a Database for Nextcloud
7.1 Log in to MariaDB
sudo mysql -u root -p
7.2 Create a Database and User
sql
CREATE DATABASE nextcloud; CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost'; FLUSH PRIVILEGES; EXIT;
Replace
your_password
with a strong password.
Step 8: Complete the Nextcloud Setup
8.1 Access Nextcloud in Your Browser
Open a browser and navigate to:
http://mycloud.duckdns.org
8.2 Follow the Setup Wizard
Enter the database details:
Database user:
nextcloud
Database password:
your_password
Database name:
nextcloud
Database host:
localhost
Data Folder: /mnt/external_drive/nextcloud_data
Create an admin account and complete the setup.
Step 9: Set Up HTTPS with Let’s Encrypt
9.1 Install Certbot
sudo apt install certbot python3-certbot-apache
9.2 Obtain an SSL Certificate
sudo certbot --apache -d mycloud.duckdns.org
9.3 Restart Apache
sudo systemctl restart apache2
Step 10: Configure External Storage in Nextcloud
Step 10: Configure External Storage in Nextcloud
This step now includes configuring the formatted external drive as external storage in Nextcloud.
10.1 Log in to Nextcloud as an Admin
Open a browser and navigate to:
https://mycloud.duckdns.org
Log in with your admin account.
10.2 Add External Storage
Go to Settings > Administration > External Storage.
Add a new storage configuration:
Folder name: Choose a name (e.g., "External Drive").
External storage: Select "Local".
Configuration: Enter the mount point (
/mnt/external_drive
).Click Save.
10.3 Verify External Storage
Go to the Files section in Nextcloud.
You should see the external storage folder (e.g., "External Drive") listed.
You can now upload, share, and manage files directly from the external drive.
Final Step: Access Your Cloud Storage
Access your Nextcloud server securely via:
https://mycloud.duckdns.org
Your external drive is now fully integrated into Nextcloud, and you can use it for cloud storage.
Step 11: Access Your Cloud Storage
Access your Nextcloud server securely via:
https://mycloud.duckdns.org
You can now upload, share, and manage files from your Raspberry Pi cloud storage.
Resources
How to Add More Storage
Eventually, you will have more media than storage. When that happens you have the following options.
Option 1: Add Another External Drive
1. Connect the New Drive
Physically connect the new drive to your Raspberry Pi (via USB for HDD/SSD for network storage).
2. Format and Mount the Drive
Identify the new drive (check with lsblk or sudo fdisk -l)
lsblk
Format as ext4 (WARNING: erases all data!)
sudo mkfs.ext4 /dev/sdb1 # Replace sdb1 with your drive
Create a mount point
sudo mkdir /mnt/new_storage
Mount the drive
sudo mount /dev/sdb1 /mnt/new_storage
Auto-mount on boot: Add to /etc/fstab
echo "/dev/sdb1 /mnt/new_storage ext4 defaults 0 2" | sudo tee -a /etc/fstab
3. Add as External Storage in Nextcloud
Log in to Nextcloud as admin.
Go to Settings > Administration > External Storage.
Add a new storage:
Folder name: "Extra Storage" (or any name)
External storage: "Local"
Configuration:
/mnt/new_storage
Check "Read-only" if needed.
Click the checkmark to save.
Option 2: Expand Existing Storage
1. Replace with a Larger Drive
Clone your existing drive to a larger one using
dd
:sudo dd if=/dev/sda1 of=/dev/sdb1 bs=1M # Replace sda1 (source) and sdb1 (target)
Resize the partition afterward:
sudo resize2fs /dev/sdb1
2. Merge Drives with LVM (Advanced)
If you want to combine multiple drives into one logical volume:
Install LVM
sudo apt install lvm2
Create physical volumes
sudo pvcreate /dev/sdb1 /dev/sdc1
Create volume group
sudo vgcreate vg_nextcloud /dev/sdb1 /dev/sdc1
Create logical volume
sudo lvcreate -l 100%FREE -n lv_storage vg_nextcloud
Format and mount
sudo mkfs.ext4 /dev/vg_nextcloud/lv_storage sudo mount /dev/vg_nextcloud/lv_storage /mnt/nextcloud_data
IMPORTANT: Post-Expansion Steps
Rescan Files:
sudo -u www-data php /var/www/nextcloud/occ files:scan --all
Update Permissions:
sudo chown -R www-data:www-data /mnt/new_storage sudo chmod -R 750 /mnt/new_storage
Comments
Displaying 0 of 0 comments ( View all | Add Comment )