Increase Virtual Image Size

For a kvm based on qcow2 the requirement was to increase the size of the hard drive. Therefore the virtual machine size needed to be increased.

The change could be divided into two parts:

  • increase the file space allocated to the virtual machine
  • increase the hard drive within the virtual machine to occupy the free space achieved.

Resize VM size

I resize the vm image using:

qemu-img resize vmdisk.img +40G

Where vmdisk.img is the virtual machine image.

The above adds 40G to the existing disk size.

If you wish to set a defined value as opposed to simply adding to the existing the command is

If you wish to find the currently assigned image size the command is

More info regards the emu-img command can be found at

Resize Hard Drive Within VM.

Having resized the vm allocated space the hard drive within the vm is to be enlarged. Also require qparted live disk to resize the partition

For ease, and a play, I chose to use a gparted live image to manage the resizing.

To start the vm I have a command within a shell file. I modified this adding a reference to the gparted live image iso file.

/usr/bin/qemu-system-x86_64 -smp 2 -soundhw hda -k en-gb -vga qxl -machine accel=kvm -m 16384 -hda "/home/neil/work/aqemu/Ubuntu_HDA.img" -hdb "/home/neil/work/aqemu/gparted-live-1.1.0-5-amd64.iso" -boot once=c,menu=on -device rtl8139 -rtc base=localtime -name "Ubuntu" $*

With the amendment added I was able to run the shell script starting the vm.

When the option is presented choose to boot the gparted live image. This can then be used to enlarge the hard drive.

Exit and reboot into the vm as normal.

Assuming all is working the reference to the gparted live image can be removed once more. Or if you prefer as this is within a file make a copy of the entry comment it out and in the ‘live’ line of text remove the gparted reference:

!/bin/sh
#This script created by AQEMU
/usr/bin/qemu-system-x86_64 -smp 2 -soundhw hda -k en-gb -vga qxl -machine accel=kvm -m 16384 -hda "/home/neil/work/aqemu/Ubuntu_HDA.img" -boot once=c,menu=off -device rtl8139 -rtc base=localtime -name "Ubuntu" $*
#/usr/bin/qemu-system-x86_64 -smp 2 -soundhw hda -k en-gb -vga qxl -machine accel=kvm -m 16384 -hda "/home/neil/work/aqemu/Ubuntu_HDA.img" -hdb "/home/neil/work/aqemu/gparted-live-1.1.0-5-amd64.iso" -boot once=c,menu=on -device rtl8139 -rtc base=localtime -name "Ubuntu" $*

Having increased the virtual allocation appropriate actions can be taken within the operating system to make use of the additional drive space.