Expanding a Linux Disk on a VM

If a VM is getting a bit tight for disk space, you can expand the size of a drive. This example is the more difficult one of expanding the primary drive. The example uses the instance name, which should be replaced by your own, of course.

Tell Ganeti to Grow the Disk

Unless you want the glow-disk to take a very long time, turn off drbd for the instance and turn it back on at the end of all this.

gnt-instance stop
gnt-instance modify -t plain --no-wait-for-sync
gnt-instance start

First you need to make the Ganeti disk allocation larger.

gnt-instance grow-disk 0 8G

grows the priimary drive by 8G.

This allocates more disk in Ganeti and creates a larger partition. But it does not tell Linux that the disk is bigger.

Also, like many gnt-instance modify commands, it will not take effect until the next Ganeti start, not reboot within the VM, but a real Ganeti instance reboot or shutdown/start.

Increasing the Linux Partition Size

You can not grow the primary partion while running it. So stop the instance

gnt-instance shutdown

You will need the VNC console, so get the port number

gnt-instance info | grep console
  console connection: vnc to (display 5114)
    serial_console: True

11014 in this example

You will also need the cluster VNC password, which is in /etc/ganeti/vnc-cluster-password

Boot from an appropriate CD ROM. Note that you need a desktop ISO, not a server

gnt-instance start -H boot_order=cdrom,cdrom_image_path=/ISOs/ubuntu-16.04.1-desktop-amd64.iso

And then start VNC to the console.

  • Choose Try Ubuntu
  • Choose the File Drawer
  • Choose the Computer Device
  • Click on the Search Magnifying Glass
  • Type 'gparted'
  • There will be a 'gparted' icon, click it to run gparted
  • [ there must be an easier way to do this ]

To expand the /dev/vda1 ext4 partition, you have to get the swap and extended partitions out of the way.

  • Right click swap and turn Swapoff
  • Right click the swap partition again and delete it
  • Right click the exttended partition and delete it
  • Click Edit in the menu bar and Apply All Operations
  • Confirm, and when it's done, say thank you

You now should have the /dev/vda1 ext4 partition and a big unused partition. Now you can grow the /dev/vda1. But remember to leave room to create a new swap partition.

N.B. If you have a disk with LVM2 partitions, gparted will automatically activate them. This will prevent you from resizing the partition with grow/resize. You can turn the LogicalVolumes off with 'vgchange -a n'.


  • Right click /dev/vda1 and select Resize/Move
  • You can drag the bar or crank numbers in
  • Be sure to leave room for a swap partition
  • Click Resize/Move
  • Right click the unallocated partition and select New
  • Create as: Primary Partition
  • File system: linux-swap
  • Add the all the remaining unallocated disk space (unless you had other plans)
  • Click Edit in the menu bar and Apply All Operations
  • Confirm, and when it's done, say thank you

You should now have /dev/vda1 with an increased size and /dev/vda2 as a linux-swap partition.

Quit gparted and shut-down the linux desktop system.

You should now be able to start the VM

gnt-instance reboot

and find that it has been resized. It may take a while to restart. I suspect drbd, but really have no idea.

Once it has booted, ssh in as root and

Last modified 6 weeks ago Last modified on Jan 7, 2020, 9:40:43 PM