You are on page 1of 11

How to resize Proxmox qcow2, raw images and Windows partitions using qemu

0.13 and Linux Gparted

October, 10 2010
By: Ian Evans
Document Review

Name Title Action Date


Ian Evans Review 10/10/10
Ian Evans Approve 10/10/10

Document History

Name Title Action Date


Ian Evans Initial Draft 10/10/10
Ian Evans Final 10/10/10
Table of Contents
Prerequisites:......................................................................................................................................................4
Software used:....................................................................................................................................................4
The Problem:......................................................................................................................................................4
Step 1: Download and Install QEMU 0.13 on Proxmox 1.6..............................................................................4
Step 2: Resize the VM........................................................................................................................................4
Step 3: Booting the Newly Resized VM Disk....................................................................................................9
REFERENCES.................................................................................................................................................11
Prerequisites:
• Proxmox installed and running a Windows VM.
• General knowledge of Proxmox and the Linux shell.
• A bootable Linux ISO in VZ templates (I am using Linux Mint 9 in this guide). If you do not have a linux ISO
in templates, you can upload one that you have downloaded by navigating to “ISO Images” in the Proxmox
web console.
• Sufficient free space on your disks to allocate additional free space to the VM.
• Use this at your own risk on production systems. I am not responsible for any damages that may occur.

Software used:
• Proxmox VE 1.6
• Linux Mint 9 Gnome iso
• Windows XP SP3
• Gparted
• QEMU 0.13RC1

The Problem:
Fixing free space problems in a Virtualized environment can be very difficult because you have to resize the the VM
filesystem size, but also the host partition size as well. Thankfully, with QEMU 0.13, correcting this issue is easier
than ever. QEMU 0.13 now has an option to resize .raw and .qcow2 formats with the qemu-img -convert option. This
document shows you how to grow your raw and qcow2 files while reallocating free space on your Windows paritions
as well.

Illustration 1: Out of free space!

Step 1: Download and Install QEMU 0.13 on Proxmox 1.6


(a) Download from here: wget http://download.savannah.gnu.org/releases/qemu/qemu-0.13.0-rc1.tar.gz
(b) Untar: tar -xzvf qemu-0.13.0-rc1.tar.gz
(c) Change directory: cd qemu-0.13.0-rc-1
(d) Download all of the necessary packages: aptitude install gcc make zlibc zlib1g-dev xlib-bin gcc+
automake
(e) Configure: ./configure
(f) Make: make
(g) Make install: make install

Step 2: Resize the VM


a) Login to your Proxmox server via ssh and navigate to the Proxmox images directory: cd
/var/lib/vz/images/<yourimagedirectory>
b) Resize the raw or qcow2 image file: /usr/local/bin/qemu-img resize <yourvm>.raw +<size>
a) example command: /usr/local/bin/qemu-img resize vm-106-disk-1.raw +20G
c) Verify your image file size has changed: ls -lh
a) Your output should look similar to this:

Illustration 2: ls -lh output of modified RAW file size

b) The Proxmox GUI will not see the new size of the changed file. You will need to remove the disk (turning
it into an unused disk) under the Hardware tab and add it back in as the primary disk. You can do this by
selecting the red arrow next to the IDE label and selecting “Delete”. After this is complete, you will see
the correct sized disk under “Unused Disks”.

Illustration 3: Resized drive now showing up properly under "Unused Disks"

c) Now you will add the disk back into the VM. This can be done by selecting the red arrow next to
“Hardware device list for VM xxx”. Select “Add a hard disk”. You will now be presented with the option
to create a new hard disk or select your exsisting disk. Select the disk you modified to add it in as the
primary hard disk for the VM.

Illustration 4: Adding the resized disk into your VM as the primary

d) You should now see the resized disk in your VM.


Illustration 5: Newly resize disk now showing properly

e) Make sure your disk is set properly in the boot order under the “Options” tab.

Illustration 6: Checking the boot order

f) Boot your Windows VM and verify the extra space is now present in “Disk Management” by right-
clicking on “My Computer”, selecting “Manage” and navigating to the “Disk Management” area.

Illustration 7: Verifying the free space in Disk Management


g) After you have verified free space, shut down the Windows VM. You will now navigate to the “Options”
tab under your VM in Proxmox and change the boot order to your Linux ISO disk. You can do this by
selecting the red arrow next to the CD-ROM device and selecting “Edit”. As noted earlier, I am using a
Linux Mint 9 ISO. I am using this distro because it has Gparted installed by default.

Illustration 8: Selecting the Linux ISO

h) Change the boot order to reflect the CD-ROM.

Illustration 9: Selecting the CD-ROM as the boot device

i) Boot your VM. It should load the Linux ISO you selected in the previous step. After everything is loaded,
start gparted. You can do this by navigating to run > gparted. You will then select the correct hard disk in
the upper right hand corner of the application.

Illustration 10: GParted showing your NTFS partitions and free space.
j) Now that Gparted has indenfied all of the disks and free space, you need to make sure the free space is in
the correct location on the disk. In this case, I had to move it after the 11.72 C:\ drive partition so I could
use the free space for that partition. Fortunately, Gparted makes this process easy. Simply right-click on
the partition and select “Resize/Move” and move it to the desired location on the disk with the slider bar.
After you have selected the location and everything looks correct, select the Resize/Move button,
followed by the check box on the top of the Gparted screen to execute the command.

Illustration 11: Moving the free space to the correct location on the disk

k) After the free space has been moved, we need to resize the NTFS partition to consume this free space.
Same as before, right-click on the partition, select “Resize/Move” and adjust the slider accordingly. After
the slider has been adjusted, select “Resize/Move” followed by the check box on the Gparted screen to
execute the command.

Illustration 12: Moving the free space to the correct location on the disk

l) Once the move of the free space is complete, resize the partition. This can be done by right-clicking on the
partition and selecting “Resize/Move”, adjusting the slider bar to consume the free space, selecting
“Resize/Move” and finally, the check box at the top of the Gparted screen to execute the command.

Illustration 13: Resizing the partition to use all free space just moved

m) One the move is complete, shut down the VM and change the boot order back to the primary hard disk.
After this has been done, select “save” and start the Windows VM.

Illustration 14: Selecting the primary hard disk as the primary boot device

Step 3: Booting the Newly Resized VM Disk


a) Boot the VM. Windows will most likely start a chkdsk. Let it complete the process and boot.
b) Navigate to Disk Management and verify the disk that was changed is the correct size.
Illustration 15: Looking good!
REFERENCES

Proxmox VE: http://pve.proxmox.com/wiki/Main_Page


QEMU: http://wiki.qemu.org/Main_Page
Linux Mint: http://www.linuxmint.com/
Gparted: http://gparted.sourceforge.net/

You might also like