To start with Virtualization I can say it is the one of the most helpful technology known to man. The basics which make it a great technology is the feature that user can have more than one machine at the cost of one single machine.
Or for a software guy he can get a number of machines to test his development.
In Virtualization we have 2 different types.
They are ->
* Full Virtualization.
* Para Virtualization.
Full Virtualization, in computer science, is a Virtualization technique used to implement a certain kind of virtual machine environment: one that provides a complete simulation of the underlying hardware. The result is a system in which all software capable of execution on the raw hardware can be run in the virtual machine. In particular, this includes all operating systems. (This is different from other forms of Virtualization – which allow only certain or modified software to run within a virtual machine.)
Some examples of such are VMware/QEMU/KVM.
Para Virtualization, In computing, paravirtualization is a Virtualization technique that presents a software interface to virtual machines that is similar but not identical to that of the underlying hardware.
Paravirtualization may allow the virtual machine monitor (VMM) to be simpler or virtual machines that run on it to achieve performance closer to non-virtualized hardware. However, operating systems must be explicitly ported to run on top of a paravirtualized VMM.
And according to me I personally prefer this due to its feature of not using too much of RAM and other resources, as it uses host's resources and that too when required.
Some examples of such are XEN/OpenVZ.
In terms of how to do virtualization it can be done through GUI or Command line. I prefer Command line for doing the job.
I will start explaining this hoping that you have QEMU installed.
qemu-img create -f raw image.img 5G
This will create a blank image named image.img you can define the size of the image by changing the 5G option to any size.
Now it's time to boot it with a cdrom to give it an Operating System. To do this you need either a CDROM on host machine o an ISO image.
If you have an ISO image then enter this command ->
qemu -cdrom linux/windows.iso -hda image.img -m 600 -boot d
Where linux/windows.iso is your ISO image, image.img is the disk image you just created,-m 600 is the RAM you want to allocate to the Virtual Machine and -boot d is to tell the Virtual Machine to boot from the CDROM.
After the installation is over then run the Virtual Machine with the following command ->
qemu -hda image.img -m 600 -net tap -net nic
Where -net tap tell it to connect to a virtual interface(tap device -- tap0/tap1 etc) on the host and -net nic defines 1 network card present on the Virtual Machine.
And if you don't know how to configure tap device you can refer my next post which will be TAP/TUN.
Under this I will go on with XEN, to have virtualization with xen you need to have the kernel which supports XEN virtualization.
I now suppose that you have upgraded your kernel to support XEN.
To start with XEN you must be familiar with two terms which we will be using a number of times.
* dom0 -> this refers to the host on which the Virtual Machine or the domU is situated.
* domU -> this refers to the guest machine which we are going to create now.
Now if you have upgraded your kernel of the host machine to support XEN, this means yours dom0 is ready.
And it's time to create domU but before that just reboot your machine to boot into the upgraded kernel.
Creating - domU
File Based Setup of Virtual Disk
* mkdir -p /home/haps/
* dd if=/dev/zero of=/home/haps/diskimage.img bs=1024k count=5000
* dd if=/dev/zero of=/home/haps/swapimage.img bs=1024k count=512
* mkfs.ext3 /home/haps/diskimage.img
* mkswap /home/haps/swapimage.img
* mount -o loop /home/haps/diskimage.img /mnt
Debootstrap New OS onto Virtual Disk
* debootstrap --arch i386 lenny /mnt http://ftp.de.debian.org/debian/
* mv /mnt/lib/tls /mnt/lib/tls.disabled
* cp /etc/apt/sources.list /mnt/etc/apt/
* vi /mnt/etc/apt/sources.list
* cp -a /lib/modules/2.6.16-1-xen-k7/ /mnt/lib/modules/
* cp /etc/resolve.conf /mnt/etc/
* cp /etc/network/interfaces /mnt/etc/network/
* vi /mnt/etc/network/interfaces (and make it look like this)
#To use Specific IP address - edit the /mnt/etc/network/interfaces manually.
#To use DHCP, edit and include the following:
# The loopback network interface
iface lo inet loopback
# The primary network interface
iface eth0 inet dhcp
* vi /mnt/etc/hostname
* vi /mnt/etc/fstab (and make it look like this)
proc /proc proc defaults 0 0
/dev/sda1 / ext3 defaults 0 0
/dev/sda2 none swap sw 0 0
Setup domU Xen Config
* vi /etc/xen/haps (and make it look like this)
kernel = "/boot/vmlinuz-2.6.16-1-xen-k7"
ramdisk = "/boot/initrd.img-2.6.16-1-xen-k7"
memory = 192
name = "haps"
vif = ['bridge=xenbr0']
ip = "ip 192.168.1.5"
gateway = "ip add"
netmask = "255.255.0.0"
root = "/dev/sda1 rw"
* ln -s /etc/xen/haps /etc/xen/auto/haps
//link in the config file so that the Virtal Machine starts on Bootup of Dom0
Run and Update DomU
* xm create haps -c
// CTRL + ] Gets out of the Console
All going well you should see domU booting up. Login as "root" with no password. Execute the following commands to update:
* apt-get update
* apt-get upgrade
* apt-get install module-init-tools //for iptables
* apt-get install iptables
* iptables -L
For other commands on xen do
Hope this helps a lot of people.