How to resize your DigitalOcean droplet

Thomas Hysselinckx
3 min readMay 1, 2020
The picture is just a reminder for them people with broken servers (Photo by Belinda Fewings on Unsplash)

I didn’t think I had to ask this question, right before clicking the “Resize” button, neither did I find a simple-to-understand explanation of what to do. So let me share what I learned.

TL;DR

  1. Turn off droplet
  2. Resize it in the DO interface & turn back on
  3. Launch console
  4. Use parted & print to know the number of partition to resize
  5. Add more space using resizepart
  6. Resize using resize2fs
  7. Reboot

How I did it

Seems easy enough, right. Turn off the droplet first. No prob. After a 2–3 minutes, the resizing is finished and I turn it back on.

Result: 500 server error. You kidding me?

Right, my server is down which I can’t really afford it to be. Quickly, let’s open the console via DO by clicking on Access > Launch console.

The first thing I see is the message saying that the disk is full. But how, I just resized it 2x?

I’m quite comfortable on the command line and can manage my server pretty well, generally. But I never had to manage disk partitions before. So after doing some reading, I understand that /dev/vda1 is a partition and has a size of around 25GB (I’ve resized my droplet to 50GB).

Ah, the DigitalOcean blog states that sudo resize2fs /dev/vda1 will help me out. To be hones, I had no idea what it was about, just that it would fix this. Also, I was in a hurry as my server was down so I didn’t do man resize2fs ¯\_(ツ)_/¯

Error: The filesystem is already (n) blocks long. Nothing to do!

So I continue my search and learn sow new commands:

I start by listing my partitions: print. First thing that comes to mind is to create a second partition (mkpart), but I was on the wrong track so I deleted it again.

Solution: first add space to the partition then resize

  1. Assigning more space to /dev/vda1 using parted and resizepart
(partedq)
print
1 /dev/vda1resizepart Partition number? 1
End? [24.8GB]? 50000 // this is important to resize

So if you had 25GB available before, then end would be somewhere around 25GB. Thus, end means actually the size you want to assign to your partition. I didn’t get that at first. As I needed to resize to 50GB, I had to put 50000 (units are MB) as the end parameter.

2. Resize it

sudo resize2fs /dev/vda1

(This should work now)

3. Reboot

sudo reboot

I also had to restart mysql for some reason (didn’t check the logs):

sudo systemctl restart mysql

And voila, back online. What a relief, I thought I lost it all. Hope this can help someone. Don’t hesitate to ask any questions, I’ll do my best to help where I can.

-Thomas

--

--

Thomas Hysselinckx

Problem solver and entrepreneur, building https://cashplannr.com. Generalist, interested in many different topics. Skier, runner, weight lifter.