Question

How to resize your droplets without having any problems.

Finally I created my website and I had some issues and now it working perfectly and I will post a post for all the problems that I face in the coming days. What I want to ask, is how to resize my droplet without losing anything. My website does not having traffic. 0 traffic a day. my visitors come to a time I know it. I need to make my website 2 or 4 gb of ram. for example for 5 hours. and after that back to the 1 ram or 0.50… Thank you for help. I need to resize my droplet from low to high and back to the low.


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello there,

You can check our article on How to Resize Droplets

https://docs.digitalocean.com/products/droplets/how-to/resize/

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

  1. gdisk -l /dev/vda

The output looks 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:

  1. fdisk -l /dev/vda

The output looks 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 25 GB even though the disk is 50 GB.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.

  1. growpart /dev/vda1

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

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

  1. resize2fs /dev/vda1

For XFS, use xfs_growfs to resize the filesystem.

  1. xfs_growfs /dev/vda1

Hope that this helps!

@Abdo

As of right now, the only way you can automate this would be to use DigitalOcean’s API using either a programming language (your choice) or a combination of bash scripting and doctl, a CLI-based interface for the API.

API

https://developers.digitalocean.com/documentation/v2/

doctl

https://github.com/digitalocean/doctl

For automation to work, you’d have to code your own solution that would check X, Y, Z and then do an action based on the results of said check.

Otherwise, the only solution would be to manually do this from the DigitalOcean Control Panel.