Is there anyway to resize a virtual machine's disk? Say increasing the disk size from 32GB to 64GB. I am running KVM/Qemu on Ubuntu server 11.10 64bit. Thanks.
I recommend before doing any of this you take a complete copy of the disk image as it is, then when it all breaks you can simply copy it back to start over.
There's 3 things you need to do:
1) Make the disk image bigger. In your host:
Now your guest can see a bigger disk, but still has old partitions and filesystems.
2) Make the partition inside the disk image bigger. You need to boot off a LiveCD in your guest for this, since you won't be able to mess with a mounted partition. This is quite involved and probably the most dangerous part. It's quite a lot to copy here, so I'll just link instead for now. You want to do something like this:
OR 2b) creating a new partition would be simpler (and safer) if you just want more storage space. Use fdisk or cfdisk, or whatever you feel comfortable with - you should see a whole bunch of unallocated space on your guest disk now.
3) Finally, if you resized your existing partition, make the filesystem inside the new bigger partition bigger (this is actually in the guide linked above anyway). Inside your guest:
I think Caesium's answer is fine, I'd just like to write down some other commands to achieve the same thing.
Assume you have a file
1) make the whole file bigger, say 4GiB. A quick way to do it is to use
2) make the partition bigger using fdisk (I wish I could do this in parted or some nicer tool... Anyone?)
What you will do is to delete that partition from the partition table and create a new partition that starts at the exact same sector but ends at a later one. Then the partition will contain a valid file system.
3) Now you need to resize the filesystem. For this you need the offset to (= the position of the) file system inside the disk image. You can compute this from the sector number if you know the sector size (which is usually 512), or you can use
This prints out the partition starts and ends. Say that your partition starts at 54525952, then you make a loopback block devices with
and finally remove the loop device
On Debian based distro you should use
Install the tool:
Get the location of your VM disk:
You may need to adapt
Create your 64G disk:
You'll need to expand /dev/sda2 (not the boot partition):
Make a backup just in case:
Now simply boot !
For more info: man virt-resize
Best solution found is here:
I think what @Caesium said is given from the above official link
I hope this will help.