How to Resize Droplets

Resizing a server, also known as vertical scaling, increases the amount of resources a server has. Increasing its memory and CPU improves its performance, and increasing the size of its disk increases the amount of data you can store.

There are two resizing options for Droplets:

  • CPU and RAM only. This option lets you increase or decrease the amount of CPU and RAM available to a Droplet.

  • Disk, CPU, and RAM. This option increases the amount of CPU and RAM available to a Droplet and permanently increases the size of a Droplet’s disk.

You cannot decrease the size of a Droplet’s disk because doing so would pose data integrity issues. This means that disk resizes are irreversible. For flexible control of all three resources, combine a CPU and RAM only resize with DigitalOcean Block Storage.

Estimated Downtime

The downtime from resizing varies depending how much disk is in use. This is true even when only resizing CPU and RAM only because the Droplet may move to a new hypervisor, which transfers disk data over the network.

Allow one minute per GB of storage in use. You can check your disk storage on your filesystem with df.

df / -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        20G   15G  4.4G  78% /

The output shows that this 20 GB Droplet is using 15 GB of space, so a disk resize can take up to 15 minutes, although the actual time required is typically shorter.

Resizing via the Control Panel

Before you can resize a Droplet in the control panel, you need to power it off. We recommend you do this from the command line to avoid data corruption, so SSH to your Droplet and issue the shutdown command:

sudo shutdown -h now

Next, go to the DigitalOcean Control Panel. On the Droplets page, click on the name of the Droplet you want to resize, then click the Resize option in the Droplet-specific menu.

Resize page

The current Droplet size will be highlighted. Choose CPU and RAM only or Disk, CPU, and RAM resizing, then select the new Droplet size.

If the Droplet isn’t powered off, you’ll see a Turn off Droplet warning window open up. This will let you power down the Droplet from the control panel, but because this risks data corruption, we recommend shutting down from the command line.

Once the Droplet is powered down and you’ve chosen its new plan, click Resize and a progress bar will display as the resize takes place.

When the resize event is finished, click the On/Off button to power the Droplet back on.

Power On

The new size will be visible below the Droplet name. Once the Droplet is booted, you can begin verifying that the your services are working as expected.

Resizing via the DigitalOcean API

If you prefer to resize your Droplets via the DigitalOcean API, you will need:

  • The ID of the Droplet you want to resize.

    The ID is shown on a Droplet’s detail page when you’ve clicked its name (e.g. the 12345678 in https://cloud.digitalocean.com/droplets/12345678/...), or you can use the API to look it up.

  • A DigitalOcean API token with read and write access.

Once you have the Droplet ID, you will use it with the Droplet actions API endpoint.

For example, the curl command below performs a CPU and RAM only resize to a 4GB Droplet, including automatically powering down the Droplet. Substitute your own API token, Droplet ID, and desired size below.

  
    
curl -X POST -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer EXAMPLE947b217efb6f3ec3bdEXAMPLE' \
     -d '{"type":"resize","size":"s-2vcpu-4gb"}' \
    "https://api.digitalocean.com/v2/droplets/droplet_id/actions"

  

If you want to perform a Disk, CPU, and RAM resize with the same options as the previous example, set the disk attribute to true. Make sure the target size has more disk than your original Droplet.

  
    
curl -X POST -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer EXAMPLE947b217efb6f3ec3bdEXAMPLE' \
    -d '{"type":"resize","size": s-2vcpu-4gb","disk":true}'  \
    "https://api.digitalocean.com/v2/droplets/droplet_id/actions"

  

Then, for either kind of resize, power on the Droplet when it’s complete.

  
    
curl -X POST -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer EXAMPLE947b217efb6f3ec3bdEXAMPLE' \
    -d '{"type":"power_on"}' \
    "https://api.digitalocean.com/v2/droplets/droplet_id/actions"

  

Learn more in the DigitalOcean API documentation on resizing.

Verifying the Disk Resize

In certain cases, a disk resize will fail to resize the Droplet’s partition or filesystem. When you rerun df -h after a disk resize and the output is unchanged, this usually indicates a problem. Use the gdisk command to get more information:

gdisk -l /dev/vda

The output will look like this:

  
    
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present
Found valid GPT with protective MBR; using GPT.
Disk /dev/vda: 104857600 sectors, 50.0 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): C1E73477-225B-4585-8BB5-C9291E473CE4
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 52428766
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number  Start (sector)    End (sector)  Size       Code  Name
   1          227328        52428766   24.9 GiB    8300

  

Some operating systems, like CentOS, don’t come with gdisk by default. You can either install gdisk using the package manager (e.g. sudo yum install gdisk) or use fdisk:

fdisk -l /dev/vda

The output will look like this:

Disk /dev/vda: 50.0 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b956b

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    52428766    52426718   83  Linux

In both of the above cases, the partition is still 25GB even though the disk is 50GB. To resize the partition, use the growpart command. In this command, /dev/vda is the name of the disk, separated by a space, and followed by the number of the partition to resize, 1.

growpart /dev/vda 1

The command to resize the filesystem depends on the filesystem type. If you don’t know what filesystem you’re using, check with df:

df -Th /dev/vda1

You can see the filesystem type in the second column of the output. The following example output shows the filesystem type is ext4.

Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/vda1      ext4   50G  4.0G   45G  10% /

For ext3/4 filesystems, use resize2fs to resize the filesystem.

resize2fs /dev/vda1

For XFS, use xfs_growfs to resize the filesystem.

xfs_growfs /dev/vda1

If there is more than one partition on the disk, you may have to modify the above commands to more closely match the Droplet’s partition table. Partitions are numbered, so if you want to grow a specific partition, use it’s number in the growpart /dev/vda command, i.e. growpart /dev/vda 2 will grow the second partition.