Expand storage with Block Storage

July 24, 2017 1.3k views
Ubuntu Block Storage Storage Ubuntu 16.04

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 ?

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

  • 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:

Have another answer? Share your knowledge.