All our servers have a Cloud-Init service included, this service is responsible for various tasks such as changing passwords, updating hostname, etc. It also takes care of extending our partition when a disk resize is done. If you have migrated your server from another platform or have deleted the Cloud-Init service when resizing, you must extend the partition manually, in this article we explain how to do it on Linux, you can consult the Windows article.

How to extend partitions on Linux

In order to extend the partition, enter your server through SSH and execute:

growpart /dev/sda 1 # Extiende partición; no cambia el filesystem

You can check that the size of the partition has increased by executing:

sfdisk -l
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 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
Disklabel type: dos
Disk identifier: 0x566d4019
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 209715166 209713119 100G 83 Linux

To extend the filesystem

resize2fs /dev/sda1 # Extiende el filesystem

You can check that the size of the filesystem has increased by executing:

df -h
Filesystem Size Used Avail Use% Mounted on

  udev 487M 0 487M 0% /dev

  tmpfs 100M 9.1M 91M 10% /run
  /dev/sda1 99G 1.1G 94G 2% /
  tmpfs 496M 0 496M 0% /dev/shm
  tmpfs 5.0M 0 5.0M 0% /run/lock
  tmpfs 496M 0 496M 0% /sys/fs/cgroup
  tmpfs 100M 0 100M 0% /run/user/0

Error cases

If during the process of extending the partition, you get errors, there is probably a problem with the partition of your server. In order to fix it, execute “fsck” to check and repair errors.

For example, on Linux you might encounter this error:

resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 7
resize2fs: Permission denied to resize filesystem