Using block storage is almost like attaching a USB drive to a laptop. It shows up on your Droplet as a separate drive. That said, you can mount the block storage /home/www-data
and store your data there.
The first step would be to move the existing data:
- mv /home/www-data /home/www-data-backup
Next, when you are following the configuration instructions provided in the control panel, replace the instances refrencing /mnt/
with where you really want to mount the volume. For example, if you named the volume volume-nyc3-01
the instructions will suggest you mount it to /mnt/volume-nyc3-01
. Instead use: /home/www-data
like so:
- sudo mkdir -p /home/www-data
- sudo mount -o discard,defaults /dev/disk/by-id/scsi-0DO_Volume_volume-nyc3-01 /home/www-data
- echo /dev/disk/by-id/scsi-0DO_Volume_volume-nyc3-01 /home/www-data defaults,nofail,discard 0 0 | sudo tee -a /etc/fstab
Next, we’ll make sure that the new block storage backed directory has the same permissions and ownership as the old directory:
- sudo chown -R --reference=/home/www-data-backup /home/www-data
- sudo chmod -R --reference=/home/www-data-backup /home/www-data
Finally, after verifying everything works as expected, you can remove the old directory to free up the space on your Droplet’s local drive.
Check out this tutorial for more information DigitalOcean Block Storage: