How to do it...

The next steps demonstrate how to add additional space to the raw image we created earlier, extend the root partition, and resize the filesystem. By the end of this recipe, the original raw image filesystem size should have changed from 10G to 20G.

  1. Obtain the current size of the image:
root@kvm:~# qemu-img info debian.img    image: debian.imgfile format: rawvirtual size: 10G (10737418240 bytes)disk size: 848M    root@kvm:~#
  1. Add additional 10 GB to the image:
root@kvm:~# qemu-img resize -f raw debian.img +10GB    Image resized.    root@kvm:~#
Please note that not all image types support resizing. In order to resize such an image, you will need to convert it to raw image first using the qemu-img convert command.
  1. Check the new size ...

Get KVM Virtualization Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.