How to extend LVM on qcow2 images

Categories Virtualization

Preparing to add some more space for VM’s swap and /. Commands listed below [note: host = node, VM = virtual machine]

Make sure that the VM is stopped before trying this out.

Current VM space layout (compare with final):

 

* Extend image to required size

* Boot up the VM,  then log into it, delete and recreate LVM partition

* Reboot then VM, and login back to resize physical volume

* I have to extend swap as well, so better unmount swap which is on LVM before extending it

* Now extend swap LVM

* Make Swap and mount it back again

New Swap = 2GB [success!!]

* Now extend root LVM so that it has ~10GB+ space

* Online resize (WARNING: for ext4 only)

Done!

So, final VM layout is as follows:

 

Where the hell is “HYPERVISOR_MEM” in OpenNebula 4.6?

Categories Virtualization

This was the question I asked myself when I saw no mention of HYPERVISOR_MEM in file /etc/one/sched.conf. It is the percentage of memory reserved for Hypervisor use.

# HYPERVISOR_MEM: Fraction of total MEMORY reserved for the hypervisor.
# E.g. 0.1 means that only 90% of the total MEMORY will be used

HYPERVISOR_MEM=0.4

.. will reserve 40% of the total memory for OpenNebula (only 60% RAM will be available for guest VMs). You can choose to over-commit resources by simply specifying a negative value:

HYPERVISOR_MEM=-0.4

This  is  was the preferred method to over-commit resources in OpenNebula.

Well, now things have got even more easier since OpenNebula v4.6. HYPERVISOR_MEM is deprecated now – instead set RESERVED_MEM and RESERVED_CPU attributes to the host via Sunstone -> Infrastructure -> Hosts -> [host]

  • RESERVED_CPU in percentage. It will be subtracted from the TOTAL CPU
  • RESERVED_MEM in KB. It will be subtracted from the TOTAL MEM

These values can be negative, in that case you’ll be actually increasing the overall capacity so over-commiting host capacity

 

Restrict VM network Speed in OpenNebula

Categories Virtualization

Environment:

OpenNebula + KVM

Requirement:

Automatically set a cap on VM network speed to 1MB/s for all VMs when it start.

.. and then:

# chmod 755 /var/lib/one/remotes/hooks/set_vm_network_speed.sh

Resize KVM images in OpenNebula

Categories Virtualization

Although I am doing this for OpenNebula, this can be followed for any KVM setup.

I am using a CentOS 6.2 image downloaded from OpenNebula Marketplace. This is of size 10GB, and my requirement is to extend root partition (/dev/sda1) to 20GB.

All commands on KVM host:

Make a backup of the existing disk image before proceeding..

I wish to add 10 more GB to the current partition (so, total size = 20GB). So, create a new raw disk image of size 20GB first, and then clone the contents from original image file to new image file.

The filesystem should be ready by now, but just in case you wish to run “resize2fs” manually:

Now include the new image in OpenNebula, use it in the VM template and start a new instance again.

NOTE: There are many more ways to resize, this is just one of those methods (like http://docs.openstack.org/image-guide/content/ch_modifying_images.html , or even live-resize using “qemu-img resize”).

For example: to extend the entire disk in order to create additional partitions (/dev/vda2, /dev/vda3 etc), “qemu-img resize” command should be enough.