1. Introduction
We have installed on a Raspberry Pi with 2 NVMe SSD’s running an Apache webserver under Virtualmin. It makes sense to store Piwigo data on a separate drive (cache, photos and videos) to prevent the often lower capacity of the boot drive becomes an issue.
This article describes how to configure the Webmin based server and Piwigo to store the data on a second data SSD.
2. Requirements
The following is required to store Piwigo data on a separate drive:
- Working Raspberry Pi with 2 SSD’s
- Working setup of Piwigo. See also Setup a Piwigo site on a Raspberry Pi with Virtualmin
3. Setup
Execute the followings steps, whereby in the instructions the /home/gallery.fotokruse.eu/public_html needs to be replaced by your path to the piwigo folder. Also the mounted data drive /mnt/data-ssd needs to be replaced by your own mounted second drive.
- Go to Webmin and select Tools > Terminal
- Prepare the data SSD with the required folders :
1234sudo mkdir -p /mnt/data-ssd/gallery.fotokruse.eusudo mkdir -p /mnt/data-ssd/gallery.fotokruse.eu/galleriessudo mkdir -p /mnt/data-ssd/gallery.fotokruse.eu/_datasudo mkdir -p /mnt/data-ssd/gallery.fotokruse.eu/upload
This will create the following folder structure:
- Set the required permissions for the web server user (here www-data, but replace with your web server user):
12sudo chown -R www-data:www-data /mnt/data-ssd/gallery.fotokruse.eusudo chmod -R 755 /mnt/data-ssd/gallery.fotokruse.eu
This will change the permissions from (also for the upload folder):
into www-data:www-data under the blurred section:
- Now the Piwigo data needs to be copied from the boot drive to the data drive. Before doing this the web server needs to be stopped to prevent new files are being written while copying.
1sudo systemctl stop apache2 - Copy the Piwigo galleries folder from the first SSD to the second SSD:
1sudo rsync -avh --progress /home/gallery_fotokruse_eu/public_html/galleries/ /mnt/data-ssd/gallery.fotokruse.eu/galleries/ - Copy the Piwigo _data folder from the first SSD to the second SSD:
1sudo rsync -avh --progress /home/gallery_fotokruse_eu/public_html/-data/ /mnt/data-ssd/gallery.fotokruse.eu/_data/ - Copy the Piwigo upload folder from the first SSD to the second SSD:
1sudo rsync -avh --progress /home/gallery_fotokruse_eu/public_html/upload/ /mnt/data-ssd/gallery.fotokruse.eu/upload/ - Backup the original folders:
123sudo mv /home/gallery_fotokruse_eu/public_html/galleries /home/gallery_fotokruse_eu/public_html/galleries.baksudo mv /home/gallery_fotokruse_eu/public_html/_data /home/gallery_fotokruse_eu/public_html/_data.baksudo mv /home/gallery_fotokruse_eu/public_html/upload /home/gallery_fotokruse_eu/public_html/upload.bak
Check with the file manager that this indeed has been done. - Create new folders within the Piwigo website folder:
123sudo mkdir -p /home/gallery_fotokruse_eu/public_html/galleriessudo mkdir -p /home/gallery_fotokruse_eu/public_html/_datasudo mkdir -p /home/gallery_fotokruse_eu/public_html/upload - Ensure the new folders have the correct website owner:
123sudo chown -h www-data:www-data /home/gallery_fotokruse_eu/public_html/galleriessudo chown -h www-data:www-data /home/gallery_fotokruse_eu/public_html/_datasudo chown -h www-data:www-data /home/gallery_fotokruse_eu/public_html/upload - Create the bind mounts
123sudo mount --bind /mnt/data-ssd/gallery.fotokruse.eu/_data /home/gallery_fotokruse_eu/public_html/_datasudo mount --bind /mnt/data-ssd/gallery.fotokruse.eu/galleries /home/gallery_fotokruse_eu/public_html/galleriessudo mount --bind /mnt/data-ssd/gallery.fotokruse.eu/upload /home/gallery_fotokruse_eu/public_html/upload - Restart the Apache webserver
1sudo systemctl start apache2 - Make the binds mount permanent so they are recreated when rebooting the Webmin / Virtual min based webserver. Open the Webmin Filemanager and go to the folder /etc
- Find the file fstab, right mouse click and select Edit. Add the following instructions (of course modified for your situation):
123/mnt/data-ssd/gallery.fotokruse.eu/_data /home/gallery_fotokruse_eu/public_html/_data none bind 0 0/mnt/data-ssd/gallery.fotokruse.eu/galleries /home/gallery_fotokruse_eu/public_html/galleries none bind 0 0/mnt/data-ssd/gallery.fotokruse.eu/upload /home/gallery_fotokruse_eu/public_html/upload none bind 0 0
Save and close the editor. - Use the command below to mount all filesystems listed in /etc/fstab that are not currently mounted. If no errors are shown it is working.
1sudo mount -a - Check the site is working. If the Piwigo site works the backup folders on the first SSD can be removed.
123sudo rm -rf /home/gallery_fotokruse_eu/public_html/galleries.baksudo rm -rf /home/gallery_fotokruse_eu/public_html/_data.baksudo rm -rf /home/gallery_fotokruse_eu/public_html/upload.bak
This concludes the setup to store Piwigo data on a separate drive. The following articles might also be of interest:





0 Comments