How can I mount a Block Storage Volume to my Linode if using ServerPilot?
I'd like some additional storage added to my Linode / ServerPilot setup, and I saw the Block Storage option, though it doesn’t look like this will easily fit into my current setup (Linode handled by ServerPilot) without some fancy formatting.
Or maybe I am wrong? Is there any documentation that explains how I can add Block Storage that seamlessly appears in my Linode’s available disk space for ServerPilot?
I haven't used ServerPilot, but from what I'm gathering ServerPilot configures a LAMP stack on your Linode. Block Storage can be mounted to whatever mount point you designate on your Linode, so if you keep all your WP files stored in
/var/www/html/wp-content/uploads, for example, you can mount your volume there.
The below is a bit of a hack, and I'm sure there are more efficient ways you can accomplish this that would involve some scripts to make your life easier. Though here are the steps I took for what it's worth.
I created a Wordpress Marketplace app, which uses a LAMP stack.
Note: it takes a bit of time for the install to fully complete. But by the end you should have the following directory once you ssh into your Linode:
Since wordpress throws all the uploads in the
/var/www/wordpress/wp-content/uploads directory, I mounted my Block storage volume there. From my Linode (while logged in via SSH) I ran:
sudo mkfs.ext4 "/dev/disk/by-id/scsi-0Linode_Volume_serverpilot-volume" sudo mount "/dev/disk/by-id/scsi-0Linode_Volume_serverpilot-volume" "/var/www/wordpress/wp-content/uploads"
Instructions for mounting are found in Block Storage guide, as well as in Cloud Manager after you create a Block Storage Volume.
If you want the volume to automatically mount every time your Linode boots, you'll want to add a line like the following to your /etc/fstab file as well:
/dev/disk/by-id/scsi-0Linode_Volume_serverpilot-volume /var/www/wordpress/wp-content/uploads ext4 defaults,noatime,nofail 0 2
The hack-y thing about this is that I need to modify some permissions as well as manually upload files to my Volume from my laptop (rather than use the Wordpress Media UI). Here are the permission changes I made on my Linode:
To my uploads folder:
sudo chown www-data:www-data uploads/
Then I used
scp to upload a file from my MacBook:
sudo scp image.jpg firstname.lastname@example.org:/var/www/wordpress/wp-content/uploads
I also had to modify permissions on my image so it's publicly readable:
chmod 744 image.jpg
Once I did that, I could manually view the image from my browser using this format, for example:
Again, very hack-y, so if there's a better way to do this hopefully someone else chimes in.
The hack-y thing about this is that I need to modify some permissions as well as manually upload files to my Volume
Is this because you're mounting the root of the volume as the uploads directory, so you can't set permissions on the root of the volume itself?
What about if you created a sub-directory on your volume and symlink the uploads folder to it? You can then set permissions on the sub-directory on the volume.
sudo mkfs.ext4 "/dev/disk/by-id/scsi-0Linode_Volume_serverpilot-volume" sudo mount "/dev/disk/by-id/scsi-0Linode_Volume_serverpilot-volume" "/mnt/serverpilot-volume" sudo mkdir /mnt/serverpilot-volume/wp-uploads sudo chown www-data:www-data /mnt/serverpilot-volume/wp-uploads sudo rm -rf /var/www/wordpress/wp-content/uploads sudo ln -s /mnt/serverpilot-volume/wp-uploads /var/www/wordpress/wp-content/uploads
/etc/fstab would then look like:
/dev/disk/by-id/scsi-0Linode_Volume_serverpilot-volume /mnt/serverpilot-volume ext4 defaults,noatime,nofail 0 2