This tutorial is how I set up Piwigo on a Raspberry PI 2 W to replace Google photos and Apple photos after running out of free space. I set it up with a 4tb external hard drive, planning to add a second drive as a backup.
Be sure the usb drive has an external power source as the PI cannot power it while writing files.
I switched to a 150$ Lenovo mini PC, running proxmox, and an ubuntu vm with immich as a picture manager.
Setup a normal way, assuming hostname is pics.local.
Update the system
sudo apt update
sudo apt upgrade
sudo apt autoremove
sudo parted -l
. It will probably be /dev/sda
or /dev/sdb
Assuming the name is /dev/sda
Erase it with sudo shred -v /dev/sda
or sudo dd if=/dev/zero of=/dev/sda status=progress
Create partition map with sudo parted /dev/sda mklabel gpt
Create a partition with sudo parted /dev/sda mkpart primary ext4 0% 100%
Get the new partition name with sudo parted -l
. Probably something like /dev/sda1
Format filesystem with sudo mkfs.ext4 /dev/sda1
Mount it
sudo mkdir /external
sudo chown -R $USER:$USER /external
sudo chmod -R 744 /external
sudo nano /etc/fstab
# add line to mount new drive
/dev/sda1 /external ext4 defaults,nofail,noatime,rw,user 0 0
# reload
sudo systemctl daemon-reload
# test
sudo mount -a
swapon --show
or free -h
sudo fallocate -l 4G /swap
# update permissions
sudo chmod 600 /swap
# make it swap
sudo mkswap /swap
# enable
sudo swapon /swap
# check
swapon --show
# enable after reboot
sudo nano /etc/fstab
# add
/swap swap swap defaults 0 0
curl -sSL https://get.docker.com/ | CHANNEL=stable sh
# might need to enable docker
systemctl enable --now docker
# and docker compose
sudo apt update
sudo apt install docker-compose-plugin
cd /external
nano docker-compose.yml
services:
piwigo:
image: lscr.io/linuxserver/piwigo:latest
environment:
- PUID=1000
- PGID=1000
- TZ=America/Chicago
volumes:
- ./piwigo/config:/config
- ./piwigo/gallery:/gallery
ports:
- 80:80
- 443:443
depends_on:
- db
restart: unless-stopped
db:
image: lscr.io/linuxserver/mariadb:latest
restart: unless-stopped
environment:
- PUID=1000
- PGID=1000
- TZ=America/Chicago
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_DATABASE=mysql
volumes:
- ./mysql:/config
sudo docker compose up
sudo docker compose up -d
When accessing piwigo (http://pics.local) for the first time, you can set up the database connection with:
server: db
username: root
password: secret
database: mysql
docker compose pull
docker compose down
docker compose up -d
docker compose logs