≡ Menu

KVM virt-manager: Install CentOS As Guest Operating System

Now, you have installed the KVM software and required drivers on the host operating systems. You also configured bridged based networking which will provide direct access to the Internet. It is time to create your first guest operating systems. For demonstration purpose you will install CentOS Linux v5.5 using the Internet using virt-manager GUI tool.

The virt-manager is the easiest way to install guest operating system using CDROM or Internet. It is a a desktop tool for managing virtual machines. It provides the ability to control the lifecycle of existing machines (bootup/shutdown,pause/resume,suspend/restore), provision new virtual machines, manage virtual networks, access the graphical console of virtual machines, and view performance statistics. You need to use this tool locally or remotely over the ssh session.

Step # 1: Download CentOS Linux Network Installation CD

Visit the official website and grab CentOS network installation disk and store it in /opt or /tmp directory. The wget command can be used to download an ISO file quickly:
# cd /tmp
# wget http://mirrors.hns.net.in/centos/5.5/isos/x86_64/CentOS-5.5-x86_64-netinstall.iso

Step #2: Creating CentOS Linux Guests With virt-manager

Type the following command at local server
# virt-manager
OR run virt-manager remotely over the ssh session, enter:
# ssh -X -C root@kvmserver42.nixcraft.in
# virt-manager

Sample outputs:

Fig.01: Creating A Virtualized Guest With virt-manager GUI Tool

Fig.01: Creating A Virtualized Guest With virt-manager GUI Tool


Next, click the New button to create a new guest and just follow on screen instructions. The following is the wizard based installation procedure:

Fig.02: New guest wizard to install CentOS Linux

Fig.02: New guest wizard to install CentOS Linux

Fig.03: Name the KVM virtual machine

Fig.03: Name the KVM virtual machine

Fig.04: Define virtualization method

Fig.04: Define virtualization method (full virtualization due to Intel VT)

Fig.05: Define installation method (CDROM/Network/HTTP/NFS etc)

Fig.05: Define installation method (CDROM/Network/HTTP/NFS etc)

Fig.06: Local media installation via CDROM or ISO image

Fig.06: Local media installation via CDROM or ISO image

Fig.07: KVM Storage setup (network [must be mounted] or local or block disk)

Fig.07: KVM Storage setup (network iscsi/nfs must be mounted or local or block disk)

Fig.08: KVM Set Virtual network (NAT) or Shared physical device (bridge br0 or br1)

Fig.08: KVM Set Virtual network (NAT) or Shared physical device (bridge br0 or br1)

Fig.09: KVM Guest VM Memory and CPU Allocation Setup

Fig.09: KVM Guest VM Memory and CPU Allocation Setup

Fig.10: KVM VM setup done and you can start guest installation

Fig.10: KVM VM setup done and you can start guest installation

Within minutes you will see a vnc window and with guest operating system installation process as follows:

Fig.11: KVM - guest operating system installation procedures started using vnc

Fig.11: KVM - guest operating system installation procedures started using vnc

Now, just follow on screen installation instructions and install CentOS as per your requirements. The above procedure can be repeated for MS-Windows, OpenBSD, FreeBSD and all other supported guest operating systems.

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 16 comments… add one }

  • Ashley October 8, 2010, 4:57 pm

    Hmm, running this on Ubuntu 10.04 as host. Get as far as Installation method during the CentOS install and we stop. Choose Local CDRom and it can’t find it. Choose Hard Drive and only the new virtual drives are seen – cannot see host machine drives to pick up the ISO file from.

    (That’s apart from the fact that on Ubuntu a lot of the virtualisation option screens don’t match up to your images – but that’s only a by the by.)

    • nixCraft October 8, 2010, 5:26 pm

      Ubuntu host has an updated cutting edge version of KVM so images will not match exactly. This tutorial is tested and used on RHEL / CentOS based systems only. Having said that there should not be *any problem* for installing Debian or Ubuntu as host and any guest. Just put your centos guest cd/dvd into actual drive and click on use CDROM/DVD option > Forward and it should work. If you’ve more question I suggest you use our forum @ nixcraft.com.

  • Ashley October 8, 2010, 7:38 pm

    Erm yes. I was rather trying to avoid having to burn the iso onto disc. Which is why I was interested in your article. Thanks anyway

    • Thomas Schweikle October 18, 2010, 11:36 am

      Just copy your bootable iso-images into /var/lib/libvirt/images they’ll show up and are accessible while creating a new VM.

  • Khan Md Ashraf October 27, 2010, 3:11 am

    Thanks for the great KVM HOWTO.
    I have a few questions to ask.
    I am running CentOS 5.5 x86_64 on a HP Blade . I have installed all the KVM packages as detailed in your HOWTO. But the host shows me a booted xen kernel. Linux 2.6.18-194.17.1.el5xen #1 SMP Wed Sep 29 13:30:21 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
    Also virt-manger shows me a running instance of a xen guest Domain-0. On trying to create a new virtual instance I am allowed only a paravirtualised instance and not a fully virtualised one since virt-manger claims that the hardware does not support full virtualisation.
    The CPU is a Intel(R) Xeon(R) CPU E5310 @ 1.60GHz Quad Core
    The output of grep vmx /proc/cpuinfo is “fpu tsc msr pae cx8 apic mtrr cmov pat clflush acpi mmx fxsr sse sse2 ss ht syscall lm constant_tsc pni vmx ssse3 cx16 lahf_lm”
    All help appreciated
    Ashraf

    • Khan Md Ashraf October 27, 2010, 2:30 pm

      I figured what was wrong after pursuing the issue on googacle :)
      First time setting up virtualisation. Done it with virtualbox only till date.
      KVM does not need a specialised kernel like Xen does. It runs off the mainline kernel.
      This article clued me in on that http://blog.codemonkey.ws/2008/05/truth-about-kvm-and-xen.html
      My installation was booting the xen kernel and therefore I was having above issues.
      So I edited my /boot/grub/menu.lst to boot the mainline kernel and in virt-manager I deleted the Xen connection.
      Restarted virt-manager and am ready to go.
      Ashraf

  • Khan Md Ashraf October 31, 2010, 11:53 am

    Still stymied. This processor even though it supports virtualisation at the hardware level seems to have a problem with/within the kernel. I have no idea about this. I am unable to setup full virtualisation of any sort. Even VirtualBox claims it can run only a 32bit OS and not the 64bit that I want to.

    • Andrew December 9, 2011, 10:55 am

      I know this is an old thread, but for the benefit of others, I would suggest that you need to enable virtualisation in the BIOS

      • cod3fr3ak February 8, 2012, 4:15 am

        Yep. Two things:
        1. Make sure you are using the mainline kernel.
        2. Make sure your bios has the virtualization bits set.

        I ran into the same issue when i started playing a few months back.

  • harry March 21, 2011, 4:47 am

    hi,
    I cant run virt-manager remotely over the ssh session, I tried :
    # ssh -X -C root@kvmserver42.nixcraft.in
    # virt-manager
    but I rece’ error msg stating
    root@ubox:~# virt-manager
    ERROR:root:Unable to initialize GTK: could not open display
    Traceback (most recent call last):
    File “/usr/share/virt-manager/virt-manager.py”, line 413, in
    main()
    File “/usr/share/virt-manager/virt-manager.py”, line 289, in main
    raise RuntimeError(_(“Unable to initialize GTK: %s”) % str(e))
    RuntimeError: Unable to initialize GTK: could not open display
    Traceback (most recent call last):
    File “/usr/share/virt-manager/virt-manager.py”, line 420, in
    _show_startup_error(str(run_e), “”.join(traceback.format_exc()))
    File “/usr/share/virt-manager/virt-manager.py”, line 61, in _show_startup_error
    import gtk
    File “/usr/lib/pymodules/python2.6/gtk-2.0/gtk/__init__.py”, line 69, in
    _init()
    File “/usr/lib/pymodules/python2.6/gtk-2.0/gtk/__init__.py”, line 57, in _init
    warnings.warn(str(e), _gtk.Warning)
    gtk.GtkWarning: could not open display
    am just a newbie, please guide !! host: Ubuntu 10.04 Desktop version guest1: ubuntu server guest2:win2k3 server
    THANKS!!

  • remco March 24, 2011, 5:20 pm

    Hi,

    I have follow this howto and stuck on starting virt-manager i get a error:

    Traceback (most recent call last):
    File “/usr/share/virt-manager/virt-manager.py”, line 376, in ?
    _show_startup_error(str(run_e), “”.join(traceback.format_exc()))
    File “/usr/share/virt-manager/virt-manager.py”, line 52, in _show_startup_error
    import gtk
    File “/usr/lib64/python2.4/site-packages/gtk-2.0/gtk/__init__.py”, line 76, in ?
    _init()
    File “/usr/lib64/python2.4/site-packages/gtk-2.0/gtk/__init__.py”, line 64, in _init
    _gtk.init_check()
    RuntimeError: could not open display

    It seems a vnc error but yum install vnc gtk-vnc didn’t help?

    Some one know how to solved this issue?

    System centos 64bits 5.5

    greetz

  • Anand Gupta June 22, 2011, 1:29 am

    Hi,

    Have you ever tried gluster based storage for VM files ? I have been trying to do so, however doesn’t seem to be working. DomU hangs when i try to do an install, and even kvm isn’t working

    gluster 3.2
    centos 5.6

    Thanks

  • scott September 1, 2011, 10:31 pm

    Hi,

    I’m getting a ‘no hypervisor options available’ message in virt-manager under CentOS 6.

    Has anyone run in to that?

    I have an Intel i5 second gen proc.

    Thanks,

    Scott

  • lawrence September 9, 2011, 5:26 pm

    Same issue when tried to run virt-manager, as shown below
    Traceback (most recent call last):
    File “/usr/share/virt-manager/virt-manager.py”, line 376, in ?
    _show_startup_error(str(run_e), “”.join(traceback.format_exc()))
    File “/usr/share/virt-manager/virt-manager.py”, line 52, in _show_startup_error
    import gtk
    File “/usr/lib64/python2.4/site-packages/gtk-2.0/gtk/__init__.py”, line 76, in ?
    _init()
    File “/usr/lib64/python2.4/site-packages/gtk-2.0/gtk/__init__.py”, line 64, in _init
    _gtk.init_check()
    RuntimeError: could not open display

    Any help is very much appreciated.

    lawrence

    • cod3fr3ak February 8, 2012, 4:17 am

      Are you trying to access a headless box?

      If so, you need to forward your display. If you have windows, there is an app (free) called Xming.

  • Yuleisa February 7, 2012, 2:34 pm

    I’m hianvg the same CD problem. I tried Anonymous’ add hardward solution. I can’t select ‘Normal Disk Partition’ as it is unavailable. I am running 64 bit if that helps.

Leave a Comment