How to increase space on an existing qemu ou kvm disk

23 Dec 2013 » {[{categoryPostCurrent}]}

This article describe how to increase the size of an existing KVM/QEMU image stored in raw format. The example use virt-manager, windows 7 as guest OS and debian Jessie as host T

Defragment and stop the original VM

Given that we use Windows 7 and that we are going to modify the main partition size, we must defragment the disk using the famous tool provided by windows.

Once the defragmentation is finished you can stop the VM.

Create the new VM image

The following operations assume that the VM images are stored in /var/lib/libvirt; it's the default location where virt-manager put his VM.

  • The first step is to rename the original VM image :

    mv win_7.img win_7.backup
    
  • Next, you have to create a new blank VM image using the qemu-img tool:

    qemu-img create -f raw plus.raw 10G
    
    • 10G is the additional size you want to add to your original image
  • Finally, you aggregate the previous files into a newer:

    cat win_7.backup plus.raw >> win_7.img
    

Download Gparted

Without to wait the end of the previous operation you can download the gparted live CD in order to prepare the next step.

Gparted live CD is available at http://gparted.org/

Resize the partition

Once the file win_7.img has been created, you can setup your VM in virt-manager in order to spread over his maximum the partition size.

Add the Live CD ISO to your VM

  • select IDE CDROM on the left panel.

If there is no IDE CDROM item you must add it using the add hardware button.

resize_partosh

Change the boot order

  • check the CDROM item
  • put the CDROM item on top of the list

change boot order

Boot on CD

  • Once the VM is correctly setup you can start it.

The following screen must appear

boot on CD

At startup the live CD will ask you several questions about your country and you keyboard layout. Be aware to answer correctly if you don't wan't to be in trouble later.

Resize using gparted

  • Choose your partition and click on resize/move:

step1

  • Spread the partition size in order to take all the new disk space.

step2

  • finish the partition process by clicking on Apply

step3

  • Verify the new size of your partition:

step4

Shutdown the VM

At this step, you have finished to use gparted.

  • shutdown the VM using the proper exit button on the GUI

Disconnect Live CD

  • Disconnect the live CD ISO using the setup panel of the VM.

disconnect ISO

Start the new VM

  • At the first boot, Windows 7 will detect the change of the size partition and then will ask you to check the integrity of your disk. You must answer YES.

  • Once the check is finished the system should boot normally and you can verify using the explorer that the disk size increased as expected.

checksize

That's all!!

Voir aussi...

comments powered by Disqus