Tuesday, May 19, 2015

Resize qemu (.qcow2) images

Scenario:  You have a working VM (qemu) which is running out of disk space. You need to add more space without destroying its current contents.

The following steps will let you accomplish the task.
  1. Backup the image first.
  2. Check if it is in qcow2 format:
    file winxp.qcow2
  3. Boot the image and take note of the current sizes of the entire disk (use fdisk command) and partitions (use df command).
  4. Resize the image (for example add 10GB of unallocated space):
    qemu-img resize winxp.qcow2 +10GB
  5. Run qemu to boot the gparted[1] live cd:
    qemu-system-i386 -hda winxp.qcow2 -cdrom gparted-live.iso -boot d
  6. From within gparted live resize the nearly full partition to "eat" the unallocated space we added (10 GB). Apply the changes. You may need to move partitions especially if you have many. Exit from gparted live.
  7. Boot the image and check if the changes have been reflected. Again use df and fdisk commands.
[1] http://gparted.org/livecd.php

Thursday, May 14, 2015

Speed up VM startup in OpenStack Juno

By default Nova deletes unused images in compute nodes after 24 hours. If you start an instance in which the image is no longer in the compute node, a transfer of the image from Glance is performed which increases the instance start up time. To override this, simply add the following line in the default section of nova.conf and restart the nova-compute service. The line will disable the removal of unused images from the compute nodes.
remove_unused_base_images = False