X
Popular Searches

How to Attach Extra Storage to Your DigitalOcean Droplets

Digital Ocean logo

DigitalOcean droplets come with a limited amount of SSD storage. Here’s how you can add more disk capacity without breaking the bank, using DigitalOcean’s dedicated storage solution.

Before we continue, you should check whether resizing your droplet might be an alternative option. Switching to a larger droplet type can get you more storage space as well as a bump in CPU and RAM. This can be ideal if you’re in need of all three now but don’t expect your storage requirements to grow much further in the near future.

You can resize droplets in the DigitalOcean control panel by selecting your droplet and then clicking “Resize”. Choose “Disk, CPU and RAM” and then select the plan to upgrade to. You will need to shut your droplet down while the change is applied. Resizes involving disk capacity cannot be reversed.

Attaching a Block Storage Volume

Droplet resizes aside, DigitalOcean’s Block Storage Volumes are the simplest way to add extra storage to your servers. Volumes are SSD-driven storage units. When you add a volume to a droplet, it’s akin to connecting a physical removable drive.

The droplet will now have two storage systems available – its regular SSD and the newly created volume. You define the capacity of each volume, allowing you to tailor your storage solution. Pricing is a fixed $0.10 per GB.

Advertisement

You can create a volume by logging into the DigitalOcean control panel and clicking the “Volumes” link in the left sidebar. Click the blue “Create Volume” button at the top-right of the screen.

Begin by specifying the volume size to create. Use one of the prefilled defaults or click “Enter size in GB” to customise. Next, name your volume and select the droplet you’d like to attach it to.

Formatting and Mounting Volumes

You’ll now need to choose how to mount your volume. Most of the time, “Automatically Format & Mount” will get you setup with sane defaults. When this option is selected, DigitalOcean will create a formatted volume, attach it to your droplet and then mount it into the filesystem. You’re able to choose the mount point after you click “Create Volume”. DigitalOcean supports the Ext4 and XFS filesystems. Ext4 is usually the best choice, although XFS is preferred for Red Hat systems.

Choose the “Manually Format & Mount” option if you need a different filesystem. This will also give you more control over the mounting configuration as you’ll need to set it up yourself, within your droplet.

You can use the following command to mount a volume to /mnt/example-mount:

mount -o defaults,nofail,discard,noatime /dev/sda /mnt/example-mount

We’re assuming our volume is assigned the sda device identifier. This will usually be true of the first volume you attach to a DigitalOcean droplet. The mounting options we supply are taken from DigitalOcean’s recommended approach to mounting volumes.

Using Your Volume

Once attached, formatted and mounted, volumes become just another filesystem location on your droplet. You can copy files onto your volume with commands such as cp example-file.txt /mnt/example-volume/example-file.txt – substitute in the path you mounted your volume to.

Advertisement

This is no different to using any other form of mountable storage device. Anything saved within the mount location will get stored to the volume. The remainder of your droplet’s filesystem remains on its dedicated SSD as usual.

To check the disk space remaining on your droplet and volume, use the df -h command. The line with a mount point of / represents your droplet’s SSD. Your volume’s mount point will be listed too, allowing you to see how much capacity you’ve got remaining.

Managing Your Volumes

Volumes can only be attached to one droplet at a time. It is possible to reconnect to a different droplet at any point. This is useful if you’ve moving resources between droplets or decommissioning one in favour of another.

Use the Volumes page in the Control Panel to find your volume. Hover over the name of the droplet it’s connected to and click “Edit”. You can now choose a new droplet to mount the volume to.

Volumes are resized by clicking the “More” button to the right of the table. Choose “Increase size” and select the new capacity to use. Volumes can only ever be resized upwards so the change will not be reversible.

Volume Backups

Volumes support DigitalOcean’s Snapshots system for backups. This mechanism lets you save a complete disk image into your DigitalOcean account.

Advertisement

Click the “More” button next to any volume and click “Take snapshot”. Use the dialog to name your snapshot and then press “Take Snapshot” to confirm. The process may take several minutes to complete. Larger droplets will require much more time.

You can use snapshots to recover your data at any future time. Click the “Images” link in the sidebar and find the snapshot you want to use. You can restore the snapshot to the volume it originated from or create a new volume with the snapshot as its base.

Snapshots you create are stored in perpetutity in your account. They’re billed at $0.05/GB/mo. You only pay for the data within each snapshot, not the size of the volume it originated from.

Conclusion

DigitalOcean’s Volumes allow you to easily add more storage to an existing droplet. The automated formatting and mounting process makes setup an extremely straightforward process.

Volumes aren’t the only approach to gaining more disk capacity. Depending on your requirements, DigitalOcean Spaces might be a viable alternative. It’s a remote object storage system akin to Amazon S3. Spaces is much more affordable when storing large volumes of data – $5/mo for 250GB – but does not directly connect to your droplet’s filesystem. It has to be accessed over HTTP so it’s best used for static assets and long-term archives.

James Walker James Walker
James Walker is a CloudSavvy IT contributor. He is the founder of Heron Web, a UK-based digital agency providing bespoke software development services to SMEs. He has experience managing complete end-to-end web development workflows with DevOps, CI/CD, Docker, and Kubernetes. Read Full Bio »

The above article may contain affiliate links, which help support CloudSavvy IT.