Category Archives: Virtualization

VMware, KVM, Xen

Installing VMware ovftool on Mac OS X

VMware offers a free tool to convert virtual machine files in different formats for example from .vmx to .ovf.

This tool can be used to convert:

VMX -> OVF
VMX -> OVA
OVF -> VMX
VMX -> vSphere

Or you can deploy a OVF directly to a ESX host. It’s  more powerful than it looks like.

The documentation can be found on the VMware site and it’s short and clear.

Installation:

Download the documentation and the tool from the VMware site: http://www.vmware.com/support/developer/ovf/

You need a VMware id to have access but the tool itself is free.

After you downloaded the tool you can install it using the installer. The stand alone version 2.1 (which I used) will be located here: /Applications/VMware OVF Tool/

Start a terminal and change to this directory:

cd /Applications/VMware OVF Tool/

Now convert your files like you want. For example:

ovftool vmxs/Fedora.vmx ovfs/Fedora.ova

More examples how the tool can be used are shown by the command

ovftool --help examples

Examples:

ovftool –vService:vDep1=provider_1 /ovfs/my_vapp.ovf
vi://username:pass@localhost/my_datacenter/host/esx01.example.com
(specify a vService dependency)

ovftool -tt=vmx /ovfs/my_vapp.ovf /vms/
(.ovf file to .vmx file. Result files are /vms/my_vapp/my_vapp.[vmx|vmdk])

ovftool /vms/my_vm.vmx /ovfs/my_vapp.ovf
(.vmx file to .ovf file. Result is put in /ovfs/my_vapp.[ovf|vmdk])

ovftool https://my_ovf_server/ovfs/my_vapp.ova /vm/my_vm.vmx
(.ova file to .vmx file)

ovftool /ovfs/my_vapp.ovf vi://username:pass@my_esx_host
(.ovf file to ESX host using default mappings)

ovftool /ovfs/my_vm.vmx vi://username:pass@my_esx_host
(.vmx file to ESX host using default mappings)

ovftool http://my_ovf_server/ovfs/my_vapp.ovf \
vi://username:pass@my_esx_host
(.ovf file from a web server to ESX host using defaults)

ovftool /ovfs/my_vapp.ovf \
vi://username:pass@my_vc_server/?ip=10.20.30.40
(.ovf file to vCenter server using managed ESX host ip address)

ovftool vi://username:pass@my_vc_server/my_datacenter?ds=\
[Storage1] foo/foo.vmx c:\ovfs\
(VM on ESX/vCenter server to OVF using datastore location query)

ovftool /ovfs/my_vapp.ovf \
vi://username:pass@my_vc_server/my_datacenter/host/my_host
(.ovf file to vCenter server using vCenter inventory path)

ovftool vi://username:pass@my_host/my_datacenter/vm/my_vm_folder/my_vm_name \
/ovfs/my_vapp.ovf
(VC/ESX vm to .ovf file)

ovftool /virtualmachines/MyVM.vmx \
~my_vApprun_workspace/
(Imports a .vmx file into a vApprun workspace using default name)

ovftool https://my_ovflib/vm/my_vapp.ovf
(shows summary information about the OVF package [probe mode])

Some experiences with KVM

On my workstation I am running Fedora and KVM for testing some Linux based configurations. It’s an AMD based system with 2 x Dual-Core AMD Opteron(tm) Processor 2216, 8Gb of Ram and normal SATA hard discs. Works still o.k for everything I am experimenting with and has enough power to run a few virtual machines with no impact on the host systems normal stuff.

As you can see I run different Linux distributions for testing and a FreeBSD installation as well. Screenshot-Virtual Machine Manager

If there is a limitation of performance in the most cases it’s I/O limitation because of slow SATA discs and a cheap raid controller or board chipset. I still have no SSD bought because I work on my Laptop most of the time and there is no need to pimp this machine for the things I am doing with it. Maybe if you run some I/O intensive applications this can boost your system but I will maybe test this in the next weeks or month and report my experiences here. I know it from my Mac Book when I use VMware Fusion or Virtual Box it’s o.k for doing some normal testing in your VM but if you want to run more virtual machines and still want to use you host system with fast responding you will become old while waiting on changing from virtual machine to virtual machine or check you emails and things like that. Everything on your computer gets really slow if you use such a solution in a more professional way.

My experiences with KVM and all my Linux based virtualization stuff are quite positive up to now. I am compiling quite often some software packages within my Gentoo and FreeBSD without bigger impact on the speed of my desktop applications or hanging mouse effect. Only thing I don’t use at the moment is a graphical interface within my VMs, because I don’t need it. As I wrote before which makes the system slow is big I/O on the disc. If you start some copy jobs in more virtual machines you see the discs coming under stress.

One of the next things I want to test is how the system works with an Windows 2008 R2 virutal machine. I virtualized Windows on XEN before and it works good. The Xen Hypervisor is sill a good solution and a powerful peace of software. In my eyes the negative point was that it wasn’t pushed like KVM for its kernel integration. And now after RedHat started to create a powerful toolset around KVM the marked will change again.

For me KVM will be my OSS solution for the next time because of its integration within the Linux kernel. I hope there will be some powerful solutions built around this core and it will become a mature and secure solution.

If you want to know how to install KVM on Fedora you can use the CentOS tutorial I wrote some time ago.

For console administration you can use the virsh command shell:

virsh

with this command you enter the virsh shell. To see all command available type help. In the default configuration your configuration files for your virtual machines are located in /etc/libvirt/qemu. To start just use virsh create <configuration_file>, for example:

virsh create Fedora-Minimal.xml

or with full path:

virsh create /etc/libvirt/qemu/Fedora-Minimal.xml

To check if the machine is active use:

virsh list

The output looks something like that:

Id Name                 State
———————————-
1 Fedora-Minimal       running

I use VNC and ssh X forwarding to connect to the host machine from remote and use the guest machines console. First check which display id your virtual machine has.

virsh vncdisplay Fedora-Minimal

In this case it’s the only running machine so it has display :0

Run the vncviewer command if you already have connected via ssh with the -X option.

vncviewer :0

Now on your administration machine should open a vncviewer window like you see it in the screenshot. This should work on every Linux and Mac OS X system out of the box. If you are on Windows you need to install a X server and configure Putty to use X forwarding.

VNCViewer Window which shows virtual machine output

Over slow connections this can be a bad solution. There is also an option only to see the console but therefor you need to add some kernel parameter to the guest systems boot configuration. Edit the /boot/grub/menu.lst and add this option at the end of your kernel options:

console=tty0 console=ttyS0,11520

Here an example menu.lst:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_proxy-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/vda
default=0
timeout=0
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.35.12-90.fc14.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.35.12-90.fc14.x86_64 ro root=/dev/mapper/vg_proxy-lv_root rd_LVM_LV=vg_proxy/lv_root rd_LVM_LV=vg_proxy/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=de-latin1-nodeadkeys rhgb quiet console=tty0 console=ttyS0,115200
initrd /initramfs-2.6.35.12-90.fc14.x86_64.img

Now you can use the virsh console command to open a shell. Example:

virsh console Fedora-Minimal

 

 

 

 

Virtualization in general, for technicans and business people.

In this article I will explain what is meant by the buzzword Virtualization and how this can improve your IT environment in the VMware/XEN/KVM context.

One thing which Virtualization is not, it’s magic. Many consultants are trying to explain it’s as a total new technology and big improvement and a must for everybody and everywhere. Of course they try to explain it this way because they want to sell it. The truth is it’s a known mechanism back from mainframe times. One real physical machine is providing more than one service to the client. And not only that it’s providing more than one service to a client, for the client it looks like this service is provided by an exclusive machine. For example with its own IP address, own mac address, exclusive CPU, memory etc. This makes it for administrators easier to handle different versions of operation systems and patch levels for special software. In many cases you don’t want one operation system to provide all your services like ERP/CRM/Mail/FileSharing/Construction Software/etc. because if there is a patch for the operation system and it’s applied, one or more products may stop working because of a incompatibility with this patch. On the other hand you need the patch because of security reasons of another product on the same machine. This happens quite often in reality.

A traditional x86 Intel based server room looks something like this diagram in the most cases:

Traditional Network without Virtualization

One ore more application servers,  a database system, a backup machine, a storage system and hopefully a firewall. This is what many organizations have today and it works. But everybody who has such a configuration knows that if there is a need for a new complexer software in the organization sooner or later someone asks you to buy a new server for that application. No matter that you have 5 of this servers and each of them is just sleeping all day long because it has this ultra fast 4 or 6 core CPU and such a big memory you can save the half world history in it, he tells you to buy a new one because the solution needs it’s own machine otherwise you will not have support.  Another bad point in this traditional way of IT architecture is the management. Each Server needs it’s own management environment, logins, performance monitoring, system monitoring, update and backup solution. This is the point where Virtualization brings you a real benefit with saving energy costs, software licenses and hardware costs.

Let me explain how Virtualization works on a simple diagram:

Virtualization basic diagram

This diagram shows you that on top of the hardware there works a peace of software here called Virtualization layer which simulates each of the virtual machines that it has it’s own hardware. The system installed in this virtual machine don’t need to know that it’s not installed on a real hardware alone. This is why nearly all software can be virtualized this way. You see if you can consolidate only 2 servers you can save nearly the half of energy and definitely the half of space in your server rack. With the CPUs we have today you can virtualize up to 10 – 12 old servers to one new big machine with for example 2 x 6 core CPUs and a lot of memory. In this case you see what potential this technology has. Turn off 10 servers and run it on just one machine. That’s not the way I would do Virtualization. It’s nice to save energy but what happens if we have a problem with our one new big server? The complete organization can not work without ERP, EMail etc. and because of this we need a cluster.

Such a cluster configuration looks something like this:

virtualized computercenter example rack diagram

Two big servers, a storage subsystem and a smaller management server. If you compare now the old configuration with the new one you can see there will be still made some points for energy efficiency. That’s not the only benefit you should have in focus, for the mature Virtualization solutions like VMware or Citrix/XEN exist a big number of tools and documentation to make the life easier for administrators and system managers. This safes time and brings better reaction times for your IT. In the old network configuration it took days and weeks to setup a new server, in the virtual environment this task takes a few minutes if still enough resources are available. All of the proven solutions on the marked bring well tested cluster functionality and mechanism to improve the availability of your servers and services. This helps you to focus better on your business and delivers a better IT service within your organization. If one of your servers needs to go in maintenance you don’t need to shutdown the services, with live migration technologies you can make the selected server free and move all the work to the working server and you don’t need to stop your production for example. This is where the Virtualization hits the business people, it is not a new cost factor of the IT, it helps you to consolidate and improve the infrastructure of your company or organization and you can realize it within a normal replacement cycle of your hardware and in most cases you will save a lot of energy costs.

Install KVM on CentOS

How to install KVM virtualization technologie on CentOS 5.4. This Howto explains step by step how to install KVM and how to create a VirtualMachine using Virtual Manager GUI.

Before you install KVM you need to verify that your CPU is compatible.

One of the following keywords needs to be in your /proc/cpuinfo: SVM (AMD) or VMX (INTEL)

Just grep /proc/cpuinfo for these keywords:

egrep 'vmx|svm' /proc/cpuinfo

If everything is right we need to install KVM:

yum install kvm

This will install a few packages.

For better console management tools install qemu:

yum install qemu

And if you want to use VirtualManager as GUI-Interface:

yum install virt-manager

Now reboot your system:

reboot

After reboot you need to load the kernel module for your processor:

AMD:

modprobe kvm-amd

INTEL:

modprobe kvm-intel

Start the libvirtd service:

service libvirtd start

and add libvirtd service to your default runlevels:

chkconfig --add libvirtd

add your user to kvm group:

usermod -G kvm -a <username>

start Virtual Machine Manager via menu or run:

virt-manager

maybe you need to enter your root password.

This windows should appear.

Now select your host and right click on it.

Select new and a wizzard will appear.

Follow the instructions and create your new virtual machine.

Choose your architecture and hypervisor.

Now select installation media.

Create a new harddisc image.

Create a new harddisc image.

Memory options for your virtual machine. For virtual CentOS installation 512MB is o.k.

Review the values and click Finish.

The image will be created and machine will be started in a new window.

Now you can install the OS. The Virtual Machine Manager window shows you all information about your running VM’s.

Here are some more information about KVM and CentOS.

If you want to use the virtual machine in the same network your host is working you need to setup a bridge device.

 

Handling virtual machine files on Linux

While i was working with Linux/KVM/Xen i made some notice for daily commands and why do it this way. Maybe someone can use this information for reducing time to wait for finished copy jobs or free unused disk space.

rsync is our friend:

Many of my virtual machines are using sparse file container to reduce the disk space they are using active. If a machine needs to be replaced and or those sparse files need to change there location to a different machine or filesystem you should use the right command to be sure your sparse file will not expand to full size on the new location.

I use rsync to do this job because it’s kicking asses. I am a friend of tools they are powerful instead of many small tools. Read the man pages of rsync and you know what i mean.

The option we are looking for in this case is -S or –sparse. This option will handle the sparse files as we want it. Our sparse file will be exactly using the active taken space like on source filesystem.

Because of the size of VM’s it’s nice to see a progress while the copy job is running, so use –progress to be sure you get the transfer rate you are expecting.

Here an example for pulling a machine file to a new machine:

rsync -avS --progress <user>@<sourcemachine>:/<directory>/<file> <destinationdirectory>/

 

Some times you maybe have an “normal” full size vm file and you need to convert it into a sparse file. In this case i prefer the way to copy the file via:

cp --sparse=always <sourcefile> <destinationfile>

or you can use rsync local as well if you prefer the one tool policy.

Be sure before you start this actions to have enough disk space and backup of you files. Sparse file can help you to reduce the footprint of your VM’s to the real needed space but you should monitor the growing of you files if you made an overcommit of your physical storage or lun. The virtual machine will run into real trouble if disk space on such a overcommited storage is full.