Skip to main content

Resize a Partition After a Disk Upgrade (CloudVM)

Important: It is assumed that the partition scheme is left unaltered after the initial delivery of your CloudVM. Therefore, depending on the configuration, some values may differ. Disk space of CloudVMs cannot be reduced.

These changes can be performed on a running system.

note

The disk can be named /dev/sda or /dev/vda depending on the server generation. Replace sda with vda in the commands below if applicable.

CloudVMs Without LVM

After upgrading the disk size in Cockpit, the disk has more space but the partition and filesystem still have the old size. Use growpart to expand the partition and resize2fs to expand the filesystem.

  1. Verify that the disk has been enlarged (the disk shows the new size, but the partition still has the old size):
root@cloudvm:~# fdisk -l /dev/sda
GPT PMBR size mismatch (41943039 != 104857599) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
...
Device Start End Sectors Size Type
/dev/sda1 2099200 41943006 39843807 19G Linux filesystem
  1. Grow the partition:
$ growpart /dev/sda 1
  1. Resize the filesystem:
$ resize2fs /dev/sda1
  1. Verify the new size:
root@cloudvm:~# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 48G 1.9G 46G 4% /

CloudVMs With LVM

  1. Resize the partitions /dev/sda2 and /dev/sda5:
$ growpart /dev/sda 2
$ growpart /dev/sda 5
  1. Resize the PV:
$ pvresize /dev/sda5
  1. Extend the LV. lvs shows you all available volumes. In the following example the root partition and the filesystem will be increased:
$ lvextend -l +100%FREE /dev/vg0/root --resizefs