Fedora 13 14 Xen Installation

Embed Size (px)

Citation preview

  • 8/18/2019 Fedora 13 14 Xen Installation

    1/19

    Fedora 13/14 Xen 4.0 Tutorial

    This is a step-by-step tutorial how to install Xen hypervisor 4.0.1 and the long-term maintained Linux pvops domkernel 2.6.32.x on Fedora 13 (x86_64) Linux. As a default Fedora 13 includes Xen 3.4.3 RPMs, but this tutor

    explains how to install the newer Xen 4.0.1 version from src.rpm package. Pvops dom0 kernel will be fetch

    from git repository and compiled from sources. You'll also make your F13 system ready for compiling Xen fro

    sources and doing Xen development and testing.

     Note that this tutorial disables various security features to make sure everything works well without unexpec problems! After getting everything to work OK you should enable SElinux, iptables firewall etc. Follow t

    tutorial step-by-step and you'll get a working system.

    The steps below also work for Fedora 14 (As of 4th Feb 2011). Fedora 14 includes Xen 4.0.2 rpm binaries in

    default repositories. Fedora 15 includes Xen 4.1.1 rpm binaries in the default repositories.

    Hardware used in this tutorial:

      Intel Core2 Quad CPU.

      8 GB of RAM.

     

    SATA harddisk (AHCI mode).  DVDROM drive.

      Intel NIC (e1000), DHCP for Internet access.

    For generic information about Xen 4.0 release please see Xen4.0 wiki page.

    This tutorial is verified to work on 30th of October 2010.

    Fedora 13 installation

    Download 64bit Fedora 13 x86_64 install CD (1/5) or DVD. Burn it to CDR/DVDR. I used the CD1 method.

      Boot your computer from the CD or DVD.

      If booting from CD1: When the Fedora bootloader starts, press TAB to enter additional boot options and

    add "askmethod" option to install from network URL (http/ftp mirror).

      Install Fedora in an usual way.

       Note about a bug in the F13 installer: After selecting "Basic Storage Devices" for installation and clickin Next the installer stalls/hangs for many minutes.. just wait patiently and it'll continue. After that the

    "Finding storage devices" window pops up and that also takes a long time before it continues.. this probably only happens on certain hardware configurations.

      Note about disk partitioning: Make /boot partition the primary (first) partition and choose the

    filesystem type as "ext3" (not "ext4" - which is the default), and make it big enough, say 2 GB, to f

    all the development debug-enabled kernels and big initrd-images caused by debug-enabled kernelmodules. Then as a second partition create LVM PV (Physical Volume) and create LVM Volume

    Group on it. Then create your root (/) partition on the volume group. It should be at least 40 GB to

    fit all the development tools and source trees. I used "ext4" for the root filesystem. Create your sw

    partition as an LVM volume aswell. 

      Important note about LVM volume group setup: You must (should) leave free space in the LVM

    volume group for storing guest virtual disks!!

      See this F13 installer screenshot for disk partitioning and LVM setup example:

  • 8/18/2019 Fedora 13 14 Xen Installation

    2/19

     

      I set the hostname to be "f13.localdomain". This hostname is needed later on in this tutorial to fix

    "/etc/hosts" file contents.

      Choose the "Minimal" installation method and "Customize Later". All the required software will beinstalled after the initial installation. There's no need to add additional software repositories during the

    installation.

     

    When the installation is done reboot the computer and wait for Fedora to start up.

    Configuration after installation

    This step contains some common settings to configure in the newly installed system.

    After the installation login as "root" from the console.

    Enable automatic start of networking and start the network (it's disabled as a default):

    # chkconf i g net wor k on

    # / et c/ i ni t . d/ net wor k star t

    After starting the network you can log in from the network using ssh, if you prefer remotely configuring andsetting up things. Use "ifconfig" to check the IP of the newly installed system (if using dhcp).

    Then we continue and install some commonly used and needed tools:

    # yum i nst al l scr een vi m wget t cpdump nt p nt pdat e man smar t mont ool s et htool

    Enable and start ntpd to keep time synchronized:

    # chkconf i g nt pd on

  • 8/18/2019 Fedora 13 14 Xen Installation

    3/19

    # chkconf i g nt pdat e on# / et c/ i ni t . d/ nt pdat e start# / et c/ i ni t . d/ nt pd star t

    Edit "/boot/grub/grub.conf" and modify "timeout=10" and comment out the "hiddenmenu" option, so it'll look

    like:

    # grub. conf gener at ed by anaconda#

    # Not e t hat you do not have to rerun grub af t er maki ng changes t o thi s f i l e# NOTI CE: You have a / boot par t i t i on. Thi s means t hat# al l ker nel and i ni t r d pat hs ar e r el at i ve t o / boot / , eg.# r oot ( hd0, 0)# ker nel / vml i nuz- ver si on r o r oot =/ dev/ mapper / vg_f 13- l vroot# i ni t r d / i ni t r d- [ gener i c-] ver si on. i mg#boot =/ dev/ sdadef aul t =0t i meout=10spl ashi mage=( hd0, 0) / gr ub/ spl ash. xpm. gz#hi ddenmenut i t l e Fedor a ( 2. 6. 33. 3- 85. f c13. x86_64)

    r oot ( hd0, 0)ker nel / vml i nuz- 2. 6. 33. 3- 85. f c13. x86_64 ro r oot =/ dev/ mapper / vg_f 13- l vroot

    r d_LVM_LV=vg_f 13/ l vr oot r d_LVM_LV=vg_f 13/ l vswap r d_NO_LUKS r d_NO_MD r d_NO_DMLANG=en_US. UTF- 8 SYSFONT=l at ar cyr heb- sun16 KEYTABLE=f i r hgb qui et

    i ni t r d / i ni t r amf s- 2. 6. 33. 3- 85. f c13. x86_64. i mg

    After fixing the timeout you're able to choose which kernel to boot during system startup. As a default (in F13)

    you don't get to choose the kernel - grub menu will be skipped.

    Edit "/etc/selinux/config" and disable it. We want to make sure we don't get problems from too strict selinux

     policies at this point:

    # Thi s f i l e cont r ol s t he st ate of SELi nux on t he system.# SELI NUX= can take one of t hese t hree val ues:

    # enf or ci ng - SELi nux secur i t y pol i cy i s enf or ced.# per mi ssi ve - SELi nux pr i nt s war ni ngs i nst ead of enf or ci ng.# di sabl ed - No SELi nux pol i cy i s l oaded.SELI NUX=di sabl ed# SELI NUXTYPE= can t ake one of t hese t wo val ues:# t arget ed - Tar get ed pr ocesses are pr otect ed,# ml s - Mul t i Level Secur i t y pr ot ect i on.SELI NUXTYPE=t ar geted

    Fix "/etc/hosts" by adding an entry for the hostname you specified during installation. You'll get all kinds of wei

    errors if there's no hostname/fqdn entry in hosts-file:

    127. 0. 0. 1 l ocal host l ocal host . l ocal domai n l ocal host 4 l ocal host 4. l ocal domai n4: : 1 l ocal host l ocal host . l ocal domai n l ocal host 6 l ocal host 6. l ocal domai n6127. 0. 0. 1 f 13 f 13. l ocal domai n

    Install "xorg-x11-xauth" to be able to use X11 forwarding over ssh session:

    # yum i nst al l xor g- x11- xaut h

    Install all the latest Fedora package updates, security fixes etc:

    # yum updat e

  • 8/18/2019 Fedora 13 14 Xen Installation

    4/19

    At the time of writing "yum update" needed to fetch around 85 MB of package updates from the Fedora mirrors

    Disable the Fedora default iptables firewall (make sure your network is secure, ie. your network has a firewall):

    # / et c/ i ni t . d/ i pt abl es stop# chkconf i g i pt abl es of f

    Disable ksmtuned so that it won't flood the console with errors (it's not compatible with Xen currently):

    # / et c/ i ni t . d/ ksmt uned st op# chkconf i g ksmt uned of f

    And at this point it's best to reboot the system, to get the newest kernel in use, and make sure everything works s

    far. Before booting it's good to check "/boot/grub/grub.conf" and verify correct (newest) kernel is the default and

    then reboot:

    # r eboot

    After the system reboots it's good to verify the firewall got disabled properly and there are no iptables rules in usanymore:

    # i pt abl es - L - n - vChai n I NPUT (pol i cy ACCEPT 99 packet s, 11467 byt es)pkt s bytes t arget pr ot opt i n out sour ce dest i nat i on

    Chai n FORWARD ( pol i cy ACCEPT 0 packet s, 0 byt es)pkt s bytes t arget pr ot opt i n out sour ce dest i nat i on

    Chai n OUTPUT ( pol i cy ACCEPT 97 packet s, 9805 bytes)pkt s bytes t arget pr ot opt i n out sour ce dest i nat i on

    Also verify SElinux is disabled:

    # get enf or ceDi sabl ed

     Now all the basic setup is done and you can move forward.

    Installing Xen 4.0.1 from RPMs

    For Fedora 14, RPMs are pre-compiled. As such, it is possible to do yum i nstal l xen to get all the necessary x

    components.

    The latest and greatest updates are available for download fromhttp://koji.fedoraproject.org/koji/packageinfo?packageID=7 In theory, the RPMs can work with Fedora 13,

    however, this has not been tested.

    Installing packages required for compiling Xen from sources

    For more information about installing Xen 4.0 from sources please see Xen4.0 wiki page.

    Install required development tools and libraries:

    # yum gr oupi nst al l "Devel opment Li br ar i es"# yum gr oupi nst al l "Devel opment Tool s"

    At the time of writing these downloads were around 100 MB and 105 MB in size.

  • 8/18/2019 Fedora 13 14 Xen Installation

    5/19

    Then install some additional packages required for building Xen from sources and running it:

    # yum i nst al l t r ansf i g wget t exi 2ht ml l i bai o- devel dev86 gl i bc- devel e2f spr ogs- devel gi t kmki ni t r d i asl xz- devel bzi p2- devel pci ut i l s- l i bs pci ut i l s- devel SDL- devel l i bX11- develgtk2- devel br i dge- ut i l s PyXML qemu- common qemu- i mg mercur i al

    At the time of writing these downloads were around 98 MB in size.

    You also need to install 32bit version of glibc-devel, it's required as well:

    # yum i nst al l gl i bc- devel . i 686

     Now all the required packages are installed and you can move forward.

    Building Xen 4.0.1 rpm binaries from src.rpm source package

    You can get the xen src.rpm source package from Fedora koji, or any Fedora 14 (or rawhide) FTP/HTTP mirror

    (http://ftp.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/releases/14/Everything/source/SRPMS/xen-

    4.0.1-6.fc14.src.rpm), or from: http://pasik.reaktio.net/fedora/xen-4.0.1-6.fc14.src.rpm .

    Fedora Xen 4.0.1-6 rpm contains some backported bugfixes from upcoming Xen 4.0.2.

    Download and install the src.rpm source package:

    # wget ht t p: / / pasi k. r eakt i o. net / f edor a/ xen- 4. 0. 1- 6. f c14. sr c. r pm# r pm - i xen- 4. 0. 1- 6. f c14. src. r pm

    Then rebuild the source package to generate binary rpms:

    # cd / r oot / r pmbui l d/ SPECS# r pmbui l d - bb xen. spec

    After a while when the build process finishes you should see output like:

    Wr ot e: / r oot / r pmbui l d/ RPMS/ x86_64/ xen- 4. 0. 1- 6. f c13. x86_64. r pmWr ot e: / r oot / r pmbui l d/ RPMS/ x86_64/ xen- l i bs- 4. 0. 1- 6. f c13. x86_64. r pmWr ot e: / r oot / r pmbui l d/ RPMS/ x86_64/ xen- r unt i me- 4. 0. 1- 6. f c13. x86_64. r pmWr ot e: / r oot / r pmbui l d/ RPMS/ x86_64/ xen- hyper vi sor- 4. 0. 1- 6. f c13. x86_64. r pmWr ot e: / r oot / r pmbui l d/ RPMS/ x86_64/ xen- doc- 4. 0. 1- 6. f c13. x86_64. r pmWr ot e: / r oot / r pmbui l d/ RPMS/ x86_64/ xen- devel - 4. 0. 1- 6. f c13. x86_64. r pmWr ot e: / r oot / r pmbui l d/ RPMS/ x86_64/ xen- l i censes- 4. 0. 1- 6. f c13. x86_64. r pmWr ot e: / r oot / r pmbui l d/ RPMS/ x86_64/ xen- debugi nf o- 4. 0. 1- 6. f c13. x86_64. r pm

    Install the newly built rpms:

    # cd / r oot / r pmbui l d/ RPMS/ x86_64/# r pm - Uvh *4. 0. 1- 6*. r pmPr epar i ng. . . ########################################### [ 100%]

    1: xen- l i censes ########################################### [ 13%]2: xen- l i bs ########################################### [ 25%]3: xen- hyper vi sor ########################################### [ 38%]4: xen- r unt i me ########################################### [ 50%]5: xen ########################################### [ 63%]6: xen- devel ########################################### [ 75%]7: xen- doc ########################################### [ 88%]8: xen- debugi nf o ########################################### [ 100%]

  • 8/18/2019 Fedora 13 14 Xen Installation

    6/19

    Download or compile Linux 2.6.32.x pvops Xen dom0 kernel

    For more information about pvops dom0 kernels please see XenParavirtOps wiki page.

    Fedora developer M A Young is building binary "xendom0" kernel rpms for Fedora. You can get the kernel rpm

    from his site:

      http://repos.fedorapeople.org/repos/myoung/dom0-kernel/ 

    As of 14th Apr 2011, the compiled kernels were last updated on 24th March 2011, and were built for

    Fedora 13 according to the filename. However, they should work on Fedora 14. You can compile the kern

    yourself to get the latest updates, or choose to download the kernel RPMs.

    Download the kernel from xen.git and checkout the long-term maintained 2.6.32.x branch:

    # gi t c l one gi t : / / gi t . ker nel . or g/ pub/ scm/ l i nux/ ker nel / gi t / j er emy/ xen. gi t l i nux- 2. 6- xen# cd l i nux- 2. 6- xen# gi t checkout - b xen/ st abl e- 2. 6. 32. x or i gi n/ xen/ st abl e- 2. 6. 32. x

     Note! If "git clone" fails, it's most probably caused by a network problem on your end. Some broken firewalls, n

    routers, and proxies cause problems with the git clone.

    Example output from git:

    [ r oot @f 13 ker nel ] # gi t cl one gi t : / / gi t . ker nel . or g/ pub/ scm/ l i nux/ ker nel / gi t / j er emy/ xen. gi tl i nux- 2. 6- xenCl oni ng i nt o l i nux- 2. 6- xen. . .r emot e: Count i ng obj ect s: 1748126, done.r emot e: Compr essi ng obj ects: 100% ( 292844/ 292844) , done.Recei vi ng obj ect s: 100% ( 1748126/ 1748126) , 359. 40 Mi B | 34. 70 Mi B/ s, done.r emot e: Total 1748126 ( del t a 1452892) , r eused 1733298 ( del t a 1439822)Resol vi ng del t as: 100% ( 1452892/ 1452892) , done.

    [ r oot@f 13 ker nel ] # cd l i nux- 2. 6- xen/

    [ r oot @f 13 l i nux- 2. 6- xen] # gi t checkout - b xen/ st abl e- 2. 6. 32. x or i gi n/ xen/ st abl e- 2. 6. 32. xBr anch xen/ st abl e- 2. 6. 32. x set up to t r ack remot e br anch xen/ st abl e- 2. 6. 32. x f r om or i gi n.Swi t ched t o a new br anch ' xen/ st abl e- 2. 6. 32. x'

    [ r oot@f 13 l i nux- 2. 6- xen] #

    Check the latest changes in the branch (git changelog):

    # gi t l og | l ess

    Download the reference config-file for the 2.6.32.x kernel. Also run "oldconfig" to adapt the configuration tocurrent kernel version (if it's different):

    # wget - O . conf i g ht t p: / / pasi k. r eakt i o. net / xen/ pv_ops- dom0- debug/ conf i g- 2. 6. 32. 25- pvops-dom0- xen- st abl e- x86_64# make ol dconf i g

    Note the example config-file above is DEBUG-enabled possibly causing big performance hits, so don't use

    for performance testing! 

    Then build the kernel. Replace "4" in "-j4" by the number of physical CPU cores you have, to speed up the

    compilation:

  • 8/18/2019 Fedora 13 14 Xen Installation

    7/19

    # make cl ean# make - j 4 bzI mage && make - j 4 modul es

    After successful compilation install the the kernel modules and the kernel itself. In this example we assume the

    kernel version is "2.6.32.25":

    # make modul es_i nst al l# depmod - a 2. 6. 32. 25# cp - a arch/ x86/ boot / bzI mage / boot / vml i nuz- 2. 6. 32. 25

    # cp - a Syst em. map / boot / Syst em. map- 2. 6. 32. 25# cp - a . conf i g / boot / conf i g- 2. 6. 32. 25# cd / boot# dr acut i ni t r amf s- 2. 6. 32. 25. i mg 2. 6. 32. 25

    Don't worry about the warnings from dracut. Dracut might take a couple of minutes to execute. Example dracut

    output:

    [ r oot@f 13 boot ] # dr acut i ni t r amf s- 2. 6. 32. 25. i mg 2. 6. 32. 25gr ep: / usr / share/ pl ymout h/ t hemes/ . pl ymout h/ . pl ymout h. pl ymout h: No such f i l e or di r ect ory The def aul t pl ymout h pl ugi n ( ) doesn' t exi st[ r oot@f 13 boot ] #

    Prepare to reboot into Xen

    And finally set up a new grub entry to boot the Xen hypervisor with the pvops dom0 kernel, by editing

    "/boot/grub/grub.conf", make it look like this:

    # grub. conf gener at ed by anaconda## Not e t hat you do not have to rerun grub af t er maki ng changes t o thi s f i l e# NOTI CE: You have a / boot par t i t i on. Thi s means t hat# al l ker nel and i ni t r d pat hs ar e r el at i ve t o / boot / , eg.# r oot ( hd0, 0)# ker nel / vml i nuz- ver si on r o r oot =/ dev/ mapper / vg_f 13- l vroot

    # i ni t r d / i ni t r d- [ gener i c-] ver si on. i mg#boot =/ dev/ sdadef aul t =0t i meout=10spl ashi mage=( hd0, 0) / gr ub/ spl ash. xpm. gz#hi ddenmenut i t l e Fedor a ( 2. 6. 33. 6- 147. 2. 4. f c13. x86_64)

    r oot ( hd0, 0)ker nel / vml i nuz- 2. 6. 33. 6- 147. 2. 4. f c13. x86_64 r o r oot =/ dev/ mapper / vg_f 13- l vroot

    r d_LVM_LV=vg_f 13/ l vr oot r d_LVM_LV=vg_f 13/ l vswap r d_NO_LUKS r d_NO_MD r d_NO_DMLANG=en_US. UTF- 8 SYSFONT=l at ar cyr heb- sun16 KEYTABLE=f i r hgb qui et

    i ni t r d / i ni t r amf s- 2. 6. 33. 6- 147. 2. 4. f c13. x86_64. i mgt i t l e Fedor a ( 2. 6. 33. 3- 85. f c13. x86_64)

    r oot ( hd0, 0)ker nel / vml i nuz- 2. 6. 33. 3- 85. f c13. x86_64 ro r oot =/ dev/ mapper / vg_f 13- l vrootr d_LVM_LV=vg_f 13/ l vr oot r d_LVM_LV=vg_f 13/ l vswap r d_NO_LUKS r d_NO_MD r d_NO_DMLANG=en_US. UTF- 8 SYSFONT=l at ar cyr heb- sun16 KEYTABLE=f i r hgb qui et

    i ni t r d / i ni t r amf s- 2. 6. 33. 3- 85. f c13. x86_64. i mgt i t l e Fedor a Xen 4. 0 wi t h Li nux 2. 6. 32. 25 pvops dom0

    r oot ( hd0, 0)ker nel / xen. gz dom0_mem=1024M l ogl vl =al l guest _l ogl vl =al lmodul e / vml i nuz- 2. 6. 32. 25 r o r oot =/ dev/ mapper / vg_f 13- l vroot nomodesetmodul e / i ni t r amf s- 2. 6. 32. 25. i mg

    Make sure the "root=/dev/mapper/vg_f13-lvroot" parameter matches what you have for the normal Fedora kerneentries above! You need to make the "root=" parameter be correct for your setup/installation.

  • 8/18/2019 Fedora 13 14 Xen Installation

    8/19

    Verify that Xen services/daemons are properly configured to start automatically:

    # chkconf i g - - l i st | gr ep xenxenconsol ed 0: of f 1: of f 2: of f 3: on 4: on 5: on 6: of fxend 0: of f 1: of f 2: of f 3: on 4: on 5: on 6: of fxendomai ns 0: of f 1: of f 2: of f 3: on 4: on 5: on 6: of fxenst or ed 0: of f 1: of f 2: of f 3: on 4: on 5: on 6: of f

    And now you're ready to boot into Xen.

    # r eboot

    When the system restarts select the Xen entry from Grub boot menu! We didn't change the default grub ent

    yet.

    Verifying the Xen setup after reboot

    When your system is done rebooting log in as root and run the following commands to verify everything is

    working properly.

    Xen hypervisor information:

    [ r oot @f 13 ~] # xm i nf ohost : f 13. l ocal domai nr el ease : 2. 6. 32. 25versi on : #3 SMP Sat Oct 30 15: 24: 53 EEST 2010machi ne : x86_64nr _cpus : 4nr _nodes : 1cor es_per _socket : 4t hr eads_per _core : 1cpu_mhz : 2826hw_caps :bf ebf bf f : 20100800: 00000000: 00000940: 0408e3f d: 00000000: 00000001: 00000000vi r t _caps : hvmt ot al _memory : 8190f r ee_memor y : 7076node_t o_cpu : node0: 0- 3node_t o_memor y : node0: 7076node_t o_dma32_mem : node0: 3259max_node_i d : 0xen_maj or : 4xen_mi nor : 0xen_ext r a : . 1xen_caps : xen- 3. 0- x86_64 xen- 3. 0- x86_32p hvm- 3. 0- x86_32 hvm- 3. 0- x86_32p hvm3. 0- x86_64xen_schedul er : credi t

    xen_pagesi ze : 4096pl at f orm_par ams : vi r t _st ar t =0xf f f f 800000000000xen_changeset : unavai l abl exen_commandl i ne : dom0_mem=1024M l ogl vl =al l guest _l ogl vl =al lcc_compi l er : gcc ver si on 4. 4. 4 20100630 ( Red Hat 4. 4. 4- 10) ( GCC)cc_compi l e_by : r ootcc_compi l e_domai n :cc_compi l e_dat e : Sat Oct 16 00: 13: 54 EEST 2010xend_conf i g_f ormat : 4

    Xen domain (vm) list:

    # xm l i s t

  • 8/18/2019 Fedora 13 14 Xen Installation

    9/19

    Name I D Mem VCPUs St at e Ti me( s)Domai n- 0 0 1017 4 r - - - - - 23. 1

    Make sure the "Mem" field for Domain-0 is around the same amount that you specified in grub.conf in

    "dom0_mem" parameter.

    Dom0 Linux kernel version:

    # uname - a

    Li nux f 13. l ocal domai n 2. 6. 32. 25 #3 SMP Sat Oct 30 15: 24: 53 EEST 2010 x86_64 x86_64 x86_64GNU/ Li nux

    The basic setup is now done. You should now go back to the grub menu file and change the def aul t =0 line to

    read def aul t =2 (or whatever line your new entry is at) to automatically boot into Xen.

    Installing libvirtd and graphical virt-manager

    If you want to install new Xen guests (virtual machines) with the graphical virt-manager GUI, install it like this:

    # yum i nstal l vi r t - manager l i bvi r t vi r t - vi ewer

     Note that libvirt (libvirtd) is also required for text-based guest VM network installations!

    Verify "libvirtd" is set to automatically start so the "virbr0" bridge nat/dhcp service provided by dnsmasq works

    ok for guest (vm) network installations. Also start it now:

    # chkconf i g - - l i s t l i bvi rt dl i bvi rt d 0: of f 1: of f 2: of f 3: on 4: on 5: on 6: of f

    # / etc / i ni t . d/ l i bvi r t d star t

    Verify there's the "virbr0" bridge and "dnsmasq" process running:

    # brct l showbr i dge name br i dge i d STP enabl ed i nt erf acesvi r br0 8000. 000000000000 yes

    # ps aux | grep - i dnsmasqnobody 1966 0. 0 0. 0 12784 708 ? S 23: 27 0: 00 / usr / sbi n/ dnsmasq - -s tr i ct - or der - - bi nd- i nt erf aces - - pi d- f i l e=/ var/ run/ l i bvi r t / net work/ def aul t . pi d - - conf - f i l e- - l i st en- addr ess 192. 168. 122. 1 - - except - i nt er f ace l o - - dhcp- r ange192. 168. 122. 2, 192. 168. 122. 254 - - dhcp- l ease- max=253

    Verify the IP settings libvirtd/dnsmasq configured for the "virbr0" network interface:

    # i f conf i g vi r br 0vi r br0 Li nk encap: Et hernet HWaddr 12: 57: 62: 0E: 3F: 9E

    i net addr: 192. 168. 122. 1 Bcast : 192. 168. 122. 255 Mask: 255. 255. 255. 0UP BROADCAST RUNNI NG MULTI CAST MTU: 1500 Met r i c: 1RX packet s: 0 er r ors: 0 dr opped: 0 over r uns: 0 f r ame: 0 TX packet s: 8 er r or s: 0 dropped: 0 over r uns: 0 car r i er : 0col l i si ons: 0 t xqueuel en: 0RX bytes: 0 ( 0. 0 b) TX bytes: 933 ( 933. 0 b)

    Also verify libvirtd/dnsmasq has added the required iptables NAT rule ("MASQUERADE") to enable Internet

    access from the virbr0 bridge:

  • 8/18/2019 Fedora 13 14 Xen Installation

    10/19

    # i pt abl es - t nat - L - n - vChai n PREROUTI NG ( pol i cy ACCEPT 23 packet s, 5301 bytes)pkt s bytes t arget pr ot opt i n out sour ce dest i nat i on

    Chai n POSTROUTI NG ( pol i cy ACCEPT 116 packet s, 8764 bytes)pkt s bytes t arget pr ot opt i n out sour ce dest i nat i on

    0 0 MASQUERADE al l - - * * 192. 168. 122. 0/ 24 ! 192. 168. 122. 0/ 24Chai n OUTPUT ( pol i cy ACCEPT 116 packet s, 8764 bytes)pkt s bytes t arget pr ot opt i n out sour ce dest i nat i on

    And that IP forwarding (routing) is enabled:

    # cat / pr oc/ sys/ net / i pv4/ i p_f or war d1

     Note that to run the graphical virt-manager you don't have to run X server on the Xen system (dom0), you can ruvirt-manager in dom0 but tunnel the X11 GUI over ssh and display the graphical tools on your remote

    workstation/laptop!

    Using ssh X11 forwarding

    Install "xorg-x11-xauth" on your Fedora 13 Xen system to be able to use X11 forwarding over ssh session from

    your desktop/laptop:

    # yum i nst al l xor g- x11- xaut h

    If you're connecting from a Linux workstation/laptop enable ssh X11 forwarding like this:

    # ssh - X r oot@

    If you're using Putty on Windows you need to enable X11 forwarding in Putty settings, and also install X-server

    Windows, such as Xming, and start it before trying to run graphical applications from ssh session.

    This is what you should see when logging in for the first time with ssh, when X11 forwarding is enabled in yourssh client. Note the ssh server system (Fedora 13 Xen host) needs to have "xorg-x11-xauth" rpm package installe

    Last l ogi n: Mon Aug 23 21: 50: 49 2010 f r om / usr / bi n/ xaut h: creat i ng new aut hor i t y f i l e / r oot / . Xaut hor i t y

     Now you can run graphical (X11) applications and the GUI will be displayed on your local workstation/laptop Xtunneled over the secure ssh connection. Try running "virt-manager", or any other graphical (X11) tool as an

    example.

    Installing new Xen guests using graphical virt-manager GUI

    Virt-manager is not part of Xen, but it's developed by Redhat and included in Fedora, and it can be used to mana

    Xen hypervisor, among others. Before trying to install new guests using virt-manager make sure you read the

    chapter above about installing virt-manager and related packages.

    We're going to use LVM volumes to store the Xen guest virtual disks. In this example we're going to install

    CentOS 5.5 x86 (32bit) Xen PV guest.

    First verify the name of your LVM volume group. The LVM volume group was set up during Fedora 13 (Xen

    dom0 host) installation.

    [ r oot@f 13 ~] # vgdi spl ay

  • 8/18/2019 Fedora 13 14 Xen Installation

    11/19

      - - - Vol ume gr oup - - -VG Name vg_ f 13System I DFor mat l vm2Met adat a Ar eas 1Met adat a Sequence No 4VG Access r ead/ wr i t eVG St atus r esi zabl eMAX LV 0Cur LV 3

    Open LV 2Max PV 0Cur PV 1Act PV 1VG Si ze 463. 75 Gi BPE Si ze 32. 00 Mi B Tot al PE 14840Al l oc PE / Si ze 2944 / 92. 00 Gi BFr ee PE / Si ze 11896 / 371. 75 Gi BVG UUI D 5dsak7- VN89- zMFT- 9Zi U- XGhY- s5i s- u1vCUw

    In this example the LVM volume group is called "vg_f13" and it has 371.75 GB of free space in it.

     Now let's create a new LVM volume to store the virtual machine virtual disk. Size of the new LVM volume will be 20 GB:

    [ r oot @f 13 ~] # l vcreat e - ncent os55 - L20G / dev/ vg_f 13Logi cal vol ume "cent os55" cr eat ed

    Verify the newly created LVM volume:

    [ r oot @f 13 ~] # l vdi spl ay / dev/ vg_f 13/ cent os55- - - Logi cal vol ume - - -LV Name / dev/ vg_f 13/ cent os55VG Name vg_ f 13

    LV UUI D dP41hL- B0MI - Fy4R- ScCI - 0w7K- 2cf V- r uJ RG2LV Wr i t e Access r ead/ wr i t eLV St at us avai l abl e# open 0LV Si ze 20. 00 Gi BCurr ent LE 640Segment s 1Al l ocat i on i nher i tRead ahead sect or s aut o- cur r ent l y set t o 256Bl ock devi ce 253: 2

    Then let's start the graphical virt-manager. First make sure your ssh X11 forwarding is working properly.

    [ r oot@f 13 ~] # vi r t - manager &[ 1] 2126

    And then virt-manager window will show up on your graphical desktop.

  • 8/18/2019 Fedora 13 14 Xen Installation

    12/19

     

    Start the installation from virt-manager:

      Right-click "localhost (Xen)"

      Choose "New"

      Enter the name for the guest: centos55

      Choose: "Network install (HTTP, FTP, or NFS)"

     

    Enter the CentOS mirror URL: http://ftp.funet.fi/pub/mirrors/centos.org/5.5/os/i386/   Click Forward

      Accept the default values for RAM and VCPUs (512 MB and 1 vcpu) and click Forward.

      Choose "Select managed or other existing storage"

      Enter the path to the LVM volume to the text field or choose browse: /dev/vg_f13/centos55

      click Forward

      Choose/open "Advanced options"

      Change "Architecture" to "i686" as we're installing 32bit PAE guest VM.

      Make sure the Network selection has "Virtual network 'default': NAT" selected (it is as a default).

      Virt-type should be "xen (paravirt)"

      Click Finish.

     

    "Creating virtual machine" window opens, and virt-manager fetches the kernel/initrd from the mirror site   New window opens with the guest VM console in it, and the CentOS5 installer starts.

      Choose "dhcp" for IPv4 networking and you'll get private IP from the dnsmasq service running in dom0.

     Network connections from the guest VM will be NATed to the internet.

  • 8/18/2019 Fedora 13 14 Xen Installation

    13/19

    CentOS 5 installer starts in the text mode and asks for the language, keyboard and network settings:

    When the CentOS5 installer is running you can verify the networking by checking the bridge status:

    [ r oot@f 13 ~] # xml i st

    Name I D Mem VCPUs St at e Ti me( s)Domai n- 0 0 1017 4 r - - - - - 267. 8cent os55 1 512 1 - b- - - - 17. 9

    [ r oot@f 13 ~] # brct l showbr i dge name br i dge i d STP enabl ed i nt erf acesvi rbr0 8000. f ef f f f f f f f f f yes vi f 1. 0

    Here you can see the guest called "centos55" has ID 1. Interface "vif1.0" (the first network interface of the guest

    with ID 1) is attached to the bridge "virbr0" - the bridge that dnsmasq is serving and providing DHCP server and

     NAT service.

    You can verify the private NAT IP assigned to the "centos55" guest VM from "/var/log/messages":

    [ r oot@f 13 ~] # grep dnsmasq- dhcp / var/ l og/ messagesSep 4 23: 28: 05 f 13 dnsmasq- dhcp[ 1929] : DHCP, I P r ange 192. 168. 122. 2 - - 192. 168. 122. 254,l ease t i me 1hSep 4 23: 59: 44 f 13 dnsmasq- dhcp[ 1929] : DHCPDI SCOVER( vi r br0) 00: 16: 36: d4: 07: b7Sep 4 23: 59: 44 f 13 dnsmasq- dhcp[ 1929] : DHCPOFFER( vi r br0) 192. 168. 122. 144 00: 16: 36: d4: 07: bSep 4 23: 59: 44 f 13 dnsmasq- dhcp[ 1929] : DHCPREQUEST( vi r br0) 192. 168. 122. 14400: 16: 36: d4: 07: b7Sep 4 23: 59: 44 f 13 dnsmasq- dhcp[ 1929] : DHCPACK(vi r br0) 192. 168. 122. 144 00: 16: 36: d4: 07: b7

    When the installer is finished downloading files from the mirror site it'll start the graphical phase of the

    installation:

  • 8/18/2019 Fedora 13 14 Xen Installation

    14/19

     

    Install CentOS 5 as usual.

    Installing new Xen guests using the command line virt-install

    Virt-install is not part of Xen, but it's developed by Redhat and included in Fedora, and it can be used to install

    new Xen guests, among others.

    Check the virt-manager examples above for all the basic LVM usage tips and how to install required packages.

    virt-install gets installed automatically when you install virt-manager and related packages as shown in the

    examples above.

    In this example we're going to install Fedora 13 x86 (32bit) Xen PV guest using the command line virt-install to

    First we'll create a new LVM volume to be used as the virtual disk for the F13 Xen guest:

    [ r oot @f 13 ~] # l vcreat e - nf 13 - L40G / dev/ vg_f 13Logi cal vol ume "f 13" cr eated

     Next make sure you have the ssh X11 forwarding enabled, since the command below will open graphical VNCwindow for the guest console to show the graphical Fedora installer.

    Start the Fedora 13 installation using virt-install. Specify the newly created LVM volume as the guest virtual dis

    ("-f" parameter):

    [ r oot @f 13 ~] # vi r t - i nst al l - n f 13 - r 768 - - vcpus=1 - f / dev/ vg_f 13/ f 13 - - vnc - p - l"ht t p: / / f t p. f unet . f i / pub/ mi r r or s/ f edor a. r edhat . com/ pub/ f edor a/ l i nux/ r el eases/ 13/ Fedor a/ i 38/ os"

    Example output from virt-install:

  • 8/18/2019 Fedora 13 14 Xen Installation

    15/19

    [ r oot @f 13 ~] # vi r t - i nst al l - n f 13 - r 768 - - vcpus=1 - f / dev/ vg_f 13/ f 13 - - vnc - p - l"ht t p: / / f t p. f unet . f i / pub/ mi r r or s/ f edor a. r edhat . com/ pub/ f edor a/ l i nux/ r el eases/ 13/ Fedor a/ i 38/ os"St ar t i ng i nst al l . . .Ret r i evi ng f i l e . t reei nf o. . .| 2. 8 kB 00: 00 . . .Ret r i evi ng f i l e vml i nuz- PAE. . .| 6. 7 MB 00: 02 . . .Ret r i evi ng f i l e i ni t rd- PAE. i mg. . .| 74 MB 00: 01 . . .

    Cr eati ng domai n. . .| 0 B 00: 01

    And then graphical window opens where you can see Fedora 13 installer booting up.

    Select IPV4 networking with DHCP in the Fedora installer. Note about disk partitioning for the guest VM: It'sgood to make the "/boot" partition "ext3" to avoid problems with pygrub loading the kernel from the guest. Xen

    4.0.1 properly supports ext4 /boot with pygrub, but you never know if you need to move the image to older

    systems lacking ext4 support.

    After the installer files have been downloaded the graphical phase of the Fedora 13 installer starts:

  • 8/18/2019 Fedora 13 14 Xen Installation

    16/19

     

    Install Fedora 13 as usual.

    Installing Ubuntu 10.04 LTS (Lucid Lynx) Xen PV guest using the Ubuntu text installer

    Ubuntu 10.04 can be installed as Xen PV guest using the default text-based installer included in the Ubuntu

    distribution.

    First create a new LVM volume to store the guest virtual disk:

    [ r oot @f 13 ~] # l vcreat e - nubunt u01 - L20G / dev/ vg_f 13Logi cal vol ume "ubunt u01" cr eat ed

    Then download the official Ubuntu Xen guest configuration file:

    [ r oot @f 13 ubunt u] # wget ht t p: / / f i . ar chi ve. ubunt u. com/ ubunt u/ di st s/ l uci d/ mai n/ i nst al l er -amd64/ cur r ent / i mages/ netboot / xen/ xm- debi an. cf g- - 2010- 09- 05 01: 53: 38- - ht t p: / / f i . ar chi ve. ubunt u. com/ ubunt u/ di st s/ l uci d/ mai n/ i nst al l er -amd64/ cur r ent / i mages/ netboot / xen/ xm- debi an. cf gResol vi ng f i . archi ve. ubunt u. com. . . 130. 230. 54. 102, 2001: 708: 310: 54: : 102Connect i ng t o f i . archi ve. ubunt u. com| 130. 230. 54. 102| : 80. . . connect ed.HTTP r equest sent , awai t i ng r esponse. . . 200 OKLengt h: 7618 ( 7. 4K) [ t ext / pl ai n]Savi ng t o: “xm- debi an. cf g”

    100%[ ======================================>] 7, 618 - - . - K/ s i n 0. 008s2010- 09- 05 01: 53: 38 ( 911 KB/ s) - “xm- debi an. cf g” saved [7618/ 7618]

    And rename it to "ubuntu01.cfg":

    [ r oot@f 13 ubuntu]# mv xm- debi an. cf g ubuntu01. cf g[ r oot @f 13 ubunt u]#

    Then edit "ubuntu01.cfg" with your favourite text editor and make it look like this (among other stuff in it):

    memor y = 1024name = "ubunt u01"vcpus = 1

  • 8/18/2019 Fedora 13 14 Xen Installation

    17/19

    vi f = [ ' mac=00: 16: 36: 64: 3d: f 3, br i dge=vi r br 0' ]di sk = [ ' phy: vg_f 13/ ubunt u01, xvda, w' ]

    Modify the mac address to be unique.

    Then find a line in "ubuntu01.cfg" that says "bootloader=pygrub" and add proper path ("/usr/bin/pygrub") to it:

    i f not xm_vars . env. get ( ' i nstal l ' ) :boot l oader ="/ usr / bi n/ pygr ub"

    el se:

    Already modified configuration file is available as a reference from:

    http://pasik.reaktio.net/fedora/f13xen4tutorial/ubuntu01.cfg .

    Then start the Ubuntu installer:

    xm creat e - f ubunt u01. cf g - c i nst al l =t r uei nstal l - ker nel ="ht t p: / / f i . ar chi ve. ubunt u. com/ ubunt u/ di sts/ l uci d/ mai n/ i nstal l er -amd64/ cur r ent / i mages/ netboot / xen/ vml i nuz"i nst al l - r amdi sk="ht t p: / / f i . ar chi ve. ubunt u. com/ ubunt u/ di st s/ l uci d/ mai n/ i nst al l er -amd64/ cur r ent / i mages/ net boot / xen/ i ni t r d. gz"

    i nst al l - mi r r or ="ht t p: / / f i . ar chi ve. ubunt u. com/ ubunt u"

    All of the above command needs to be on a single line. Replace the mirror site URLs with your local mirror.

    Ubuntu 10.04 text installer starts:

    Install as usual. Choose DHCP for networking.

  • 8/18/2019 Fedora 13 14 Xen Installation

    18/19

     

  • 8/18/2019 Fedora 13 14 Xen Installation

    19/19

     

    When the installation finishes the Ubuntu guest VM will shut down. After installation you can start the Ubuntu

    guest like this:

    xm creat e - f ubunt u01. cf g - c

    First you'll see the pygrub menu which allows you to choose which Ubuntu kernel to boot, and then you'll get to

    the normal Xen PV guest text console and see the Ubuntu kernel booting. You can exit from the console by

     pressing ctrl+] or ctrl+5.