Friday, April 22, 2011

Virtualization with CentOS and VirtualBox in Window 7

It's difficult to test "Virtualization" if you don't have powerful server.
But, you can test "Virtualization" using Sun Virtual Box.

It means installation CentOS Linux server guest OS inside CentOS virtual machine using VirtualBox.

In short, it's nesting virtual machines using Xen in Virtual Box.  Well, as usual go, browse and search in Internet. Most are not recommend and I'm really interested to test.

The purpose of installation is how CentOS virtualization works with Xen and it's not for production.

So, read on below if you are on the same boat as me.

I am using CentOS 5.5 and install it in Sun VirtualBox. I think this will be easy for you as well. Just download DVD ISO file from www.centos.org using from direct link or torrent.
  • After all CentOS is up and running in VirtualBox, type to following command to install Xen kernel.
  • yum install kernel-xen xen
  • Make sure that "VT-x/AMD-V, Nested Paging, PAE/NX is enabled in virtual machine as in below picture.























  • After successfully installation of Xen kernel, system need to reboot. On reboot, press Enter key when there is boot menu pops up and select "Xen Kernel"
  • To permanently start Xen kernel when system boots up, edit the grub.conf file and select the new kernel in first place.
  • There are two types of virtualization as follows;
  • Full-virtualization: hardware is emulated to the extent that unmodified guest operating systems can run on the virtualization platform. Normally, this means that various hardware devices are emulated.
  • Paravirtualization: in paravirtualization the guest operating system is ported to the hypervisor, a layer sitting between the hardware and virtualized systems. Because this normally doesn't require full device emulation or dynamic recompiling to catch privileged instructions, paravirtualization often performs at a near-native speed.
  • As the lab that I'm going to is going to use Virtual machine, this lab is for "paravirtualization".
  • After installation Xen and upgrade kernel, it's ready to create Xen domain.
  • Create a new Xen guest as follow;
  • virt-install --paravirt --name cent01 --ram 256 --file /vm/cent01.img --file-size 10 --nographic --localtion http://192.168.0.55/pub
  • Before you execute previous command, you have to mount the CentOS image and create as public directory.
  • The reasons is you can't mount virutal machine CD Drive as you are using Virtual Machine and not real hardware.
  • To mount CentOS image as to appear in website, execute the following command
  • mount -o loop /CentOS.iso /var/www/html/pub
  • Make sure to install Apache in your Virutal Machine first and create pub directory.
  • Finally, Xen guest will create and start installation.
  • After complete installation, you can clone the Xen guest as follow.
  • virt-clone --original cent01 --name clonecent01 --file /vm/clonecent01.img
For more information about CentOS virtualization, go and browse at http://www.centos.org/docs/5/html/Virtualization-en-US/

7 comments:

  1. So, let me try to understand this. You're running Oracle VirtualBox on your Windows 7 OS machine, and you have a CentOS 5.5 that is a guest on VirtualBox and within CentOS 5.5, you are running Xen?

    ReplyDelete
  2. Hi Carl,
    Yes, you are right. Sun VirtualBox on Window 7, and CentOS 5.5 as Guest OS and..within it, I install Xen and install another CenOS5.5.

    ReplyDelete
  3. Hi Myo Gyi...one more thing. What kind of CPU and motherboard are you using? The reason I am asking is because I was trying to do the same thing you were doing, and I had some problems. It seems my laptop which is an Intel I3 (M370) does have VT-x support but not VT-d. My BIOS has virtualisation enabled. I couldn't get my Xen to run on the CentOS 5.6 client. I could not find "vmx" when I did a "grep vmx /proc/cpuinfo." Of course, you are using 5.5, so I am not sure if that is the problem or not. I am wondering if Xen depends on VT-d as well. Anyway...thanks for your response.

    ReplyDelete
  4. Hi Carl,
    My laptop is Dell Inspiron N4010 with Core i3, M380 @2.53 GHz with 4GB RAM.
    I try to grep vmx/proc/cpuinfo and haven't seen any info.
    By the way, did you select Xen Kernel when CentOS load? As you know that default will start from base kernel.
    Here is "uname-a" output.
    Linux centos55 2.6.18-194.32.1.el5xen #1 SMP.
    Hope this will help.

    ReplyDelete
  5. Hi Myo Gyi,

    Thanks for your response. I checked your chip against Intel, and your chip has VT-x and VT-d support. My chip only has VT-x support. I did select the Xen kernel before boot up. When you boot up your laptop, can you check if you get the following message:

    (XEN) I/O virtualisation disabled
    ..
    ..
    (XEN) xenoprof: Initialization failed. Intel processor family 6 model 37 is not supported

    You can check the above command by doing a "xm dmesg" command.

    Because your cpu supports VT-d, this is the reason why XEN is working for you.

    ReplyDelete
  6. Hi Carl,
    Yes, I also got these lines. See below.

    (XEN) System RAM: 944MB (967228kB)
    (XEN) Xen heap: 9MB (10060kB)
    (XEN) Domain heap initialised: DMA width 32 bits
    (XEN) PAE enabled, limit: 16 GB
    (XEN) Processor #0 6:5 APIC version 20
    (XEN) Processor #1 6:5 APIC version 20
    (XEN) IOAPIC[0]: apic_id 2, version 17, address 0xfec00000, GSI 0-23
    (XEN) Enabling APIC mode: Flat. Using 1 I/O APICs
    (XEN) Using scheduler: SMP Credit Scheduler (credit)
    (XEN) Detected 2506.363 MHz processor.
    (XEN) , L1 D cache: 32K
    (XEN) I/O virtualisation disabled
    (XEN) CPU0: Intel(R) Core(TM) i3 CPU M 380 @ 2.53GHz stepping 05
    (XEN) Booting processor 1/1 eip 90000
    (XEN) , L1 D cache: 32K
    (XEN) CPU1: Intel(R) Core(TM) i3 CPU M 380 @ 2.53GHz stepping 05
    (XEN) Total of 2 processors activated.
    (XEN) ENABLING IO-APIC IRQs
    (XEN) -> Using new ACK method
    (XEN) Platform timer overflows in 2 jiffies.
    (XEN) Platform timer is 1.193MHz PIT
    (XEN) Brought up 2 CPUs
    (XEN) xenoprof: Initialization failed. Intel processor model 37 for P6 class family is not supported

    ReplyDelete
  7. Hi Myo Gyi,

    Your output looks like mines. I guess I'll have to do some more research on this. Thanks for your reponse.

    ReplyDelete