sakana

very short memo

resize disk size of guest on KVM

Sometimes you regret that you created guest OS with too small disk space. sigh... And you would like to increase disk space a little.

You can do it with some steps and I hereby quote a sample procedure of such operation. In this sample, OS of guest instance is Windows 7.

shutdown

Shutdown guest OS before start operation.

resize image file

Guest OS’s file system is represented in image file (*.img), which reflect its size.

$ du -sh /var/lib/libvirt/images/win7.img
21G /var/lib/libvirt/images/win7.img

Let us manipulate image file by qemu-img command. In this sample, 20GB will be added to existing file.

$ sudo qemu-img resize /var/lib/libvirt/images/win7.img +20G
Image resized.

resize partition

Now you need to resize existing partition to grow as much as you increased. For that sake, let us make use of gnome partition editor (gparted).

Download ISO file of gparted and connect it to guest instance. And boot from gparted. You will select graphical user interface of gparted and increase partition size easily.

boot

Now you can boot with guest OS and see that disk size does increase.