October 21, 2014

Extending QCOW2 virtual hd on Mac using VBoxManage

If you are on a linux box, you could just run qemu-img to resize the virtual hd file. But on Mac, at least I could not get qemu to build. So using the Virtualbox command line tool I did the following :

VBoxManage clonehd original-hd-file.qcow vdi-copy-of-original-hd-file.vdi --format VDI

VBoxManage modifyhd vdi-copy-of-original-hd-file.vdi --resize [ new size in MB]

Virtual box does not have support for resizing QCOW files, so you have to convert it into either VDI, VMDK format before you can resize the file. If the file is not too big and you have ample space, this is a fairly quick solution. Also note that with modifyhd --resize you can only extend a file, you cannot shrink it.