Expand storage with Block Storage

Hey! I’d like to know how to expand existing disk with block storage? Currently my droplet is running out of storage and I’m thinking about using Block Storage, but I’d like to expand with it already existing folder eg. all my files are stored /home/www-data Is it possible to add more space to www-data folder ?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

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:

  1. 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:

  1. sudo mkdir -p /home/www-data
  2. sudo mount -o discard,defaults /dev/disk/by-id/scsi-0DO_Volume_volume-nyc3-01 /home/www-data
  3. 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:

  1. sudo chown -R --reference=/home/www-data-backup /home/www-data
  2. 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: