How can I increase a virtual image disk space if it is created on a file image

This is a very useful method in your real life.. I have come across to increase the space in virtual machine when it created on a file image ..

You can try any of the below to increase the space depending on the virtual guest’s storage .. That being said , it is possible to install a virtual guest either on “fully allocated image” Or it is possible to install on a “sparse file” depending on the option ( “Allocate entire disk now” ? ) you selected when installing a virtual guest .

If it is a fully allocated file image , follow below procedure to increase the space.. Make sure that the subjected guest is powered Off for the safer side….:)

[root@hchiramm kvmguests-images]# du -sh rhel5.4-x86_64-kvm.img
5.9G rhel5.4-x86_64-kvm.img
[root@hchiramm kvmguests-images]# dd if=/dev/zero bs=1M count=2048 >> rhel5.4-x86_64-kvm.img
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 22.8518 s, 94.0 MB/s
[root@hchiramm kvmguests-images]# du -sh rhel5.4-x86_64-kvm.img
7.9G rhel5.4-x86_64-kvm.img
[root@hchiramm kvmguests-images]#

If it is a sparse file ( have a look at my previous blog for more information on sparse file ) , do below steps..


#dd if=/dev/zero of=/kvmguests-images/test-guest.img bs=1M count=0 seek=7168 conv=notrunc

By above commmand you increased the space of guest storage to “7G”…

It was “something < 7G” before .. 🙂

You will be able to see the new space inside the guest once it is started … Verify it with “fdisk -l” command….

More to come 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *