• m Linux pЉ|
    osGAзR firefox s
    | cD | ̔D | g | A | ~R | ୱR | w޲z | QAO | Ŏ | y`~ | m | Xs |
    @ @ @
    @
    ̪sG2008/09/09
    ڭ̱``A̦nNPA[]bPDEwWA]NOACDEҭtdȶV̔xVnA p@ӤiH֥DE debug ɵ{A]^̔ƦwUP]pDE[cCOA CӪAȤ@DEp~Ϊ̬OӻAOmDEŶBqBHΫ򪺺޲zDA N|fP@ͧxZ͡CoӮɭԡA[END`TC

    ҿתy[EzNOb@DEW[XhDEABCDEOWߪA F쥻DE~ALDEiHW߶}B}EAѩӤHqOb~Ӭ𭸲riA t׻PįೣD`ΡAҥHΤ@DEӶi[E[]AþAStPAȦbWYA NU෽`B޲z̔ƥHΪAȰl}̔ƭI


    jADϥe
    oӏظ`DnOb Xen oӵ[EAAO[EHLγ~H ثeDZ`[En (Virtual Machine) HUڭ̥ӻ@C


    pADϥO[E
    [E (Virtual Machine) P Apache [DE (Virtual host) (1) @ˡA [EتOƱ^b@DEWyPɹB@hӧ@~tz@\C ڭ̻ݭnb@DEWPɹB@hӧ@~tOHi]XӡG

  • @jīDEtdhR~ȮɡG
    ѩqu~޳NoFA~ӪӤHqVӶVKyAӥB\RVӶVjjI NbeXӓ (2007/09/xx) Am]~y|֤ߪBtQ 2GB DOzӤHqI obxWFHA׸̭]wgѤFAiӤHqbOKySnΡC

    nΪ@qpGSAAp|\oܮOI򻡩OH Hmm (http://www.okfdzs1903.com/) ӻA@ AMD AthlonXP 2000+ (1.6GHz CPU t) N]oD`ZA B@ܤRM]SoͬoʤjyqfPAȤ_pA[ԎoDEB@pA ϥ sar oӫOԎݤ@UAIC饭 CPU tb 10% HUӤwC ҥHAo|֤ߪqSmDEAڥNOOFL~C

    pG^NhRAȗboDEWӶ]AZƦnI~nI pGpݹLg (2) PAg (3) A ֩w|{DEAȶVx¶VnAo˦bAȳn鰣hHΥDE쪺x¤ƤWnC ҥHA@nDEpGȥΩ@ӯSwγ~AbܮOCpGCӪAȳݭn@DEA S\oܰQA]]ADEw@BqOBnwUB]wΆΡAꐷСAרSQI

    ]WzDAҥHثeܦhM׳b}oyb@DEW[Xt@Ez\A ]NOGyڭ̧Ʊ^b@DEW "P" ]hӧ@~tzNCpGFo˪\AڪwiHٲܦhDA PɤSiHRRDE귽Abܤh[I

  • Pŧ˦hRP@~tG
    ɶԦ^|B~eASɪDEOȬORiHAR^OAӥB椣C OSɦhR@~tܧlޤHA]A Windows/Linux/Mac/DOS... AjaƱ^@Uoǧ@~tA MӤSQQhʶR@sDEӪAoӮɭh}E (4) NFܭn@A ]LiHڭ̦b}EL{SܩҷQn檺@~tӾާ@C

    Lh}EӰQIANOyڨC}Eu^x@R@~tzA ҥHpGpQnbhӧ@~tɡAO}B}EN|pj_ӡC oӮɭԴNǤq}l}o^b@ӧ@~tWy[Xt~@ӥi檺@~tzA ҥHɴN^bPɶާ@R@~tFCSɳ̬y檺O VMWare o@MnTI

    MNwgӋR[EniHALSɓܳOϥγnӼ[A wä^䴩oR[EAҥHįWD`V|IL Intel/AMD jO}ojī CPU \A ثeDEwj䴩[EOAp@ӧڭ̴N^ϥΧֳt[EoI


  • pADϥDZ`[En
    ثeDZ`[EnOHL̤SUSHUNӻ@G

  • ѵPl VMWare (http://www.vmware.com/)
  • ajyLo@M[EnAoMn馭Ȧb Windows WA ̤juINOiHϥΪ̦b Windows UPɼ[X@M Linux APɰӧ@~tC meϥγoMn骺تOΨӮ Linux wUeIboӥ\W VMWare bܤhC

    L VMWare įणӦnA[WSɪDEį]ΡAӥB VMWare [w餣|P쥻DEۦPA ]mܤijjaϥ VMWare ӎ Linux CMHۮɥNiBAثe VMWare wgoiShA Pɤ] Open source Unix-Like x OS ϥΡAOܤhCL]Oثe[EsYѤjI

  • w炦 Xen (http://www.xensource.com/)
  • Xen OH GNU GPL voGۥѳnAتb󴣨ѮįΡBi䴩P@~tPɹB@B BPɹB@@~tۿWߪtCXen O X86 wҶ}oXӪ[Eʷ (Virtual Machine Hypervisor) Am\oL̤juINOįΡImb@ Celoron 366 MHz, O 192MB ۰OqW[X@ Xen EWҪPŧˡAPɳsu 50 ӦPM[ Xen EWR|\o𪺰DAįuOܤhCڭ̦bU@`|N Xen oӦnFC

  • _q KVM (Kernel based Virtual Machine, http://kvm.qumranet.com/kvmwiki)
  • Linux o Linus Torvarlds ߦnåBN[J֤ߥ\઺[ENOo KVM ޳NI KVM wg Linux 2.6.20 ֤ߤ[J\AKVM ѧ㪺 Intel/AMD CPU [޳N䴩A ӥBѧ㪺[CMثeoӧ޳NRܦALRM]iHoiܤhOI ] Linux ֤ߥN䴩[I ^_^Ih KVM iHѦҡG http://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine

  • šIIl VirtualBox (http://www.virtualbox.org/)
  • R@Mۥѳn骺[EiHΡANOPˬ[cb x86 W VirtualBox oMnTI oMn鴣ѧ㪺[ABi䴩ثeWDy@~tC mgݹLHexbL۰OqWLoMFAD`RAӥBѹϧΤƤA į譱ݰ_Ӥ]SuqCLAn^Xפ譱DAӼ[@~|SA O|vT@~tNOFCQnb Linux WqW[쪺B͡Am\ooMF̾AXzI

    CM[En鳣sbȡA]L̪\Pت@ˡC|ҨӻAm{ VirtualBox ܾAXQb Linux WqW Windows B͡AML^TwCܩ Xen hܾAXb@@įDEWPɹB@hӦP Linux tA]Tw׬S@ABʯuqA iϥΪ̻Pb@EWB@hӿWߪ@~tӤOBzPAȩOI

    Tips:
    o@ةUƲoAܦhw骺[H Linux @~t̩h֤ߪ[cA pGzQnAoǰyAiH^ CentOS 5.x һYiC
    mϥ

    jADϥؐ Xen
    Xen įର^onH Xen bϥΤW˪Hڪ@DE̦hiH䴩X Xen [H Xen [즳XRH oǺðݧڭ̳onD@U~nI SMA̦n^̔xpҤlӳBz Xen [oC


    pADϥXen [PS
    Xen oMۥѳnb[E[譱Dnb[ (Para-virtualization) Υ[ (Full virtualization) RA䤤b[ƥDnOzLק Linux ֤ߨӹF[޳NC b[Ƨ޳NҲͪ[EݭnP쥻@~tۦPΡCϥΥb[ƪҨQS⦳G (5)
    • [EB@IJvPEįSF
    • ̦hi䴩㦳 32 @HW CPU DEF
    • 䴩 x86/32, x86/32 t PAE ޳N, x86/64 w饭xF
    • }nwXʵ{䴩AXG䴩Ҧ Linux UmXʵ{F
    Xen b[Ƨ޳NDnOΦbۦP Linux WA]NOApGpQnϥΥb[ƪ覡Űʦhӵ[EA 򨺨ǵ[EOۦP@~tAƦܭnDۦPPۦP֤ߪ Linux distribution C

    pGpQnwUP Linux Ϊ̬OL OS (Ҧp Windows XP) ɡANonϥΥ[Ƨ޳NFC O[Ƨ޳NO䭭ASAw麡UCݨDɡA[Ƨ޳N~^ʧ@G
    • Aw䴩 Intel VT ޳N (Virtualization Technology, Intel-VT)F
    • Aw䴩 AMD SVM ޳N (Secure Virtual Machine, AMD-SVM or, AMD-V)C
    ~AW쪺 PAE O Intel }޳N (Physical Addressing Extensions, PAE)A o޳Ni쥻Ȥ䴩 4GB O骺 32 줸w饭xAi䴩̤j 64GB OI ӥBA Xen XGiHbҦ P-II HWίŪw饭xW]b[ƥȡApG][ƪܡAįTO OK TI

    ӥѩ[En骺yA[W x86 qįP CPU B֤xW[Aj x86 CPU sy Intel/AMD oFsX CPU [޳NAOO Intel Vanderpool [޳NH AMD Pacifica ޳NC oǧ޳N]䴩 Xen Ao Xen įWi֩OI ^_^


    pADϥXen B@춒
    b߽g̭ڭ̼g͹LwB֤߻PRε{}YA ҦRε{Ob֤߼hWӧ (6)C MzL֤ߥ\hIsPϥεw餸󪺩ROCnFA {bӥJNQ@QAJMڦhӵ[EACӵ[EUOۤv@~t֤ߡA ]NOhӧ@~tPɦsbCpGҦ@~t^㪺w骺ܡA w쩳M^֪OӹB@HӨtO|QHoOܭnDA ]pGodwApwtNuSE@~C

    FMoӰDAXen ]hӼh (layer) ӰCLN Linux ֤߭קLA AϥγoӭקL᪺֤߶}EAӶ}EJ Xen ʷ (Hypervisor) A åBŰʲĤ@ӦbWY@~tAڭ̺٥L domain-0C (b Xen Wҿת@ domain NO@ӵ[EoI)

    Domain-0 ҥHnQJO] Domain-0 tL[EŰʩҥOA åB domain-0 ]O[UmnDtC b domain-0 WY̭nNO@ xend `n{AL domain Oѳo xend Ӻ޲zC ܩRW譱AF domain-0 ~L[EŅdzQ٬ domain-1, domain-2 ΆΡA ڭ̳q٬ domain-U oCoǩNN}ʦI^oˡG

    Xen Hypersvisor \ܷN
    2-1BXen Hypersvisor \ܷN(7)

    ѤWϧڭ̪D domain-0 uOܭnA]L^ Xen ʷ (Hypervisor)AӥBxFڪ Linux Xʵ{ (drivers)CӨL[E (domain-U) hOzL Xen ʷӻPڪwH domain-0 FqCӬF domain-0 ^P Xen XAڭnק domain-0 ֤ߤ~^QB@CåBݭnϥ domain-0 ֤ߨӶ}E~iHC domain-0 OҦ[EӷAҥHLiHɶq̔x@IALӧOAȫhiHm줣P domain SFC

    xend ]OܭnNNALiH޲z domain-0 PL domain ŰʻPqA iHѤ@ӜE (console) domain-0 nJL domain AҥHڭ̤]nŰʳoN~C

    Xen |QU distribution XU۪ɡAϥΪ̥n Xen xUlXA Mۦ歫ss֤ߥHνs Xen n~CbA Xen oꐷСAˤpnI^_^C MӦb RHEL 5 (CentOS 5) HA Xen wg]tblXM󤤤FAҥHڭ̪^ yum N^wUSI ҥHndw@ Xen domain-0 wgAOi઺oI^_^

    Xen 򥻭z@ǻ{ѤA^UӴNڭ̶}lb CentOS 5 Wi@ӤppaI


    pADϥTwAwO_䴩 Xen B@
    Mثew鳣ܷsFALBͨϥΪOHDEӦwU Linux AҥHڭ̥ndNAwO_䴩 xen B@Cӧڭ̪D Xen 䴩b[ƻP[ƨRҦARҦݨDG

  • b[ (Para-virtualization) wݨDG
  • unO 64 줸 x86 DE (x86_64) ^䴩b[ƪCpGO 32 줸DE (x86) ɡA MDEn䴩}޳N (PAE) ~^ϥ xen IpT{OH̔xAˬd CPU ӋYiG
    [root@linux ~]# cat /proc/cpuinfo | grep flags
    flags  : fpu tsc msr pae mce cx8 mtrr mca cmov pat pse36 mmx fxsr sse up
    
    KKIo@DEOm P-III 800 DEAݧaIT䴩 PAE IҥHSMiH Xen oC

  • [ (Fully-virtualization) wݨDG
  • pGpݭn[ƪ޳N䴩ɡAɻݭnw馳䴩[Ƨ޳N~C ثeb x86 DESA Intel VT ޳NA AMD h SVM ޳NC oR޳Nb CPU XAOOG Intel (vmx) P AMD (svm) C mb Core Duo DEWiHo{G
    b Intel Core 2 Duo  CPU DEW CPU XAG
    [root@linux ~]# cat /proc/cpuinfo | grep flags
    flags   : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts 
              acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc up pni 
              monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
    # @IO vmx 䴩TI
    
    ܩ AMD DEXAhOG(UPՏdonyingleSѡI)
    b AMD Athlon(tm) 64 X2  CPU DEW CPU XAG
    [root@linux ~]# cat /proc/cpuinfo | grep flags
    flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov 
              pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt 
              rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic 
              cr8legacy 3dnowprefetch ts fid vid ttp tm stc 100mhzsteps 
    # @IO svm 䴩TI
    
    pGTwA CPU 䴩WzAKKIڭ̴NiH}lUCTIpGS䴩OH ܩpAUƬݬݴNnI


    pADϥһݭn Xen MP֤
    `NG b}lwUeAХѦe@p`HTwAwwg䴩 Xen b[ƥ\FI

    ͤF@U Xen zBS⤧Ab}l Xen eAڭ̱oAB@ Xen һݭnUMAåBQwUA~^ϥΪ[I ^_^CpPe@p`쪺A nϥ Xen b[ (Para-virtualization) nק֤ߤ~^QB@C bHepݭnss֤ߡALAbsAҦp CentOS 5.x UANwgN Xen ֤DpsnFIpiH^wUYiCҥHApݭnwUMDnG
    • kernel-xenGק諸 Linux ֤ߡAϥiH] Xen F
    • xenGDn xen MA]A]wɡBŰʸ}Bһݪ򥻨禡wΡF
    • xen-libsGXen һݭn禡wΡF
    • python-virtinstGќEwUnF
    • virt-managerG@ӹϧΨϥΪ̤nAibϧΤ޲z xen I
    b CentOS 5.x UApiHϥ yum ^ӦwUoXӮMCwUܫаȥϥηs֤߶}EI HmҤlӻAڦwUFӋӮ֤ߡA]A kernel-2.6.18-8.1.14.el5 kernel-xen-2.6.18-8.14.el5 A ҥHb grub ]wS|^oˡG
    [root@linux ~]# vi /boot/grub/menu.lst
    default=0
    timeout=5
    splashimage=(hd0,0)/boot/grub/splash.xpm.gz
    hiddenmenu
    title CentOS (2.6.18-8.1.14.el5xen)
            root (hd0,0)
            kernel /boot/xen.gz-2.6.18-8.1.14.el5
            module /boot/vmlinuz-2.6.18-8.1.14.el5xen ro root=/dev/hda1 rhgb quiet
            module /boot/initrd-2.6.18-8.1.14.el5xen.img
    title CentOS (2.6.18-8.1.14.el5)
            root (hd0,0)
            kernel /boot/vmlinuz-2.6.18-8.1.14.el5 ro root=/dev/hda1 rhgb quiet
            initrd /boot/initrd-2.6.18-8.1.14.el5.img
    
    pn`NAmϥΪ}Ex0ӡAYO 2.6.18-8.1.14.el5xen @ӡI M᭫sŰʳo Linux DEIŰʧARMAT{@UO_ xen ֤ߤ~I
    [root@linux ~]# uname -r
    2.6.18-8.1.14.el5xen
    # JNݡAm֤߬s xen ֤߳I
    
    [root@linux ~]# chkconfig --list | grep xen
    xend        0:off  1:off  2:on   3:on  4:on  5:on  6:off
    xendomains  0:off  1:off  2:off  3:on  4:on  5:on  6:off
    # Runlevel 3/5  xen }AȬOŰʪ~I
    
    [root@linux ~]# pstree -p | grep xen
            |            |-xenbus(10)
            |            `-xenwatch(9)
            |-xenconsoled(2348)---{xenconsoled}(2349)
            |-xenstored(2340)
    # oˬݨӡARMTOŰʪˤlI~̫@ӽT{I
    
    [root@linux ~]# xm list
    Name                  ID Mem(MiB) VCPUs State   Time(s)
    Domain-0               0      462     1 r-----     49.2
    # xm  Xen nOAlist CXwgb] xen tAw] domain-0 sbI
    
    zLWAڭ̷|D xen TwgQŰʡAӥB]Űʫeͨ쪺ӭn domain-0 oI ^Uӧڭ̦AӃԤ@Ԩ xen ]wɦb̡H


  • xen Mc
    ڭ̫eͨLA Xen b domain-0 OѤ@ xend AȩҺ޲zALiHΨӎŰʡB}PsL domain-U SC~A Xen 紣ѳ\hOt޲z޲zL̪ domain-U [IoǭnŰʰɬG
    • /usr/sbin/xendGNO xend Űʸ}Aϥ python {ygF
    • /usr/sbin/xmGn޲z xen OAiKJ xm help dߥΪkC
    ܩP xen }]wɡA]A@Ǽ[󪺎Űʸ}b /etc/xen UAboӥؿU\hƬG
    • /etc/xen/xend-config.sxpGoӭnIO xend ]wɡIe]A domain-0 Bs覡B domain-0 OPCPUθ귽tmBO_ϥ vnc @ domain-U su覡ΆΡC LAm\oAoɮפӻݭnʡAϥιw]ȴN^ΤFC

    • /etc/xen/G̭tӋ domain-U ]wɽdA]AGxmexample1, xmexample.hvmC 䤤A xmexample.hvm i@[ѦҽdI

    • /etc/xen/autoGpGpQnbt}EɴN۰ʎŰʬY domain-U ܡAiHNM]wɫwsoӥؿC |ҨӻApGpnb}EߧYϥ /etc/xen/xmexample.hvm ]wɨӎŰʬY domain-U A iHo˰G
      [root@linux ~]# cd /etc/xen/auto
      [root@linux auto]# ln -s ../xmexample.hvm .
      # ouOӽdҡApin۰I] xmexample.hvm Rݭnק~B@I
      
    • /etc/xen/scriptsGoؿäFI]A[]QŰʡB[ŰʡB [^ŰʆΆΡAOzLoؿUҦɮרӹFI
    bpwUܡAåBϥηs֤ߎŰʫA^Uڭ̶}lӳBz@ӤpרҧaI


  • pADϥĤ@Ӫx
    NpP 2-1 ˤlAbDEWҦ Linux OS ݭnۤv^}EA Ӷ}Ey{q`Oo˪G(8)
    • step 1: UqADE}lŪ BIOS ơF
    • step 2: o}EUmǡAå MBR o}ExP}E޲z{F
    • step 3: Ѷ}E޲z{J Linux kernel ε[Ϻ (initrd)F
    • step 4: Kernel wJASXʵ{AñڥؿHŪ֤߼œF
    • step 5: }l /sbin/init {]wDEC
    ѤWzʧ@Aڭ̥iHD Linux }EIb 1. ֤ 2. [Ϻ (initrd) 3. ڥؿ (/) FC M֤߻P[ϺЧڭ̪ CentOS 5 wgѤFAOw][ϺЦn^åDʪ[J Xen YXʵ{A ]ڭ̱oݭnw[Ϻжi]w~nC~AC Xen domain ڥؿ]ܶ˸I]ڥؿݭnܦhơAӥBRݭn /sys, /proc, /dev, /selinux ίSɮרtI MpBzڥؿOHUNڭ̨ӳBzBzG


  • w䴩
  • NpPeXӤp`ͨ쪺ApGڭ̪wä䴩 xen ҥn\ApOLkإߦnA domain-U I boӪxήרSڭ̪IOb[ơA]pun㦳 PAE 䴩YiC mHC픪 P-III 800 ӶiAwˬdGOo˪G
    [root@linux ~]# cat /proc/cpuinfo | grep flags
    flags  : fpu tsc msr pae mce cx8 mtrr mca cmov pat pse36 mmx fxsr sse up
    
    piHo{Tsb pae }grA]ڭ̳oӨtOiH Xen b[Ƨ޳NI ҥHڭ~iu@aI


  • ڥؿһݺϺм
  • ڥؿһݺϺмѪӷiHӡA@ӬOwСA@ӬOQ dd إߤ@ӤjɮרӨϥΡC mɦVQ dd ӳBzAڥؿIpiHo˰G
    dҡGإߤ@ 5GB jɮ
    [root@linux ~]# mkdir -p /disk2/xen
    # ]m /disk2 @@B~wСAҥHeqjTI
    
    [root@linux ~]# cd /disk2/xen
    [root@linux xen]# dd if=/dev/zero of=xen.img bs=1M count=5000
    5000+0 records in
    5000+0 records out
    5242880000 bytes (5.2 GB) copiedA178.482 A29.4 MB/s
    # oӮɭԷ|}lгy@ 5GB kɮסAѩwгtקֺC}YA
    # oӰʧ@i|ӋӋQΡC
    
    [root@linux xen]# ll /disk2/xen
    -rw-r--r-- 1 root root 5242880000 Oct 10 00:30 xen.img
    
    ɮ׬Oإ߰_ӤFALpGA Linux Ű SELinux ܡARݭn@ܤ~iHI ʧ@]Ao˰NFI
    [root@linux xen]# chcon -t xen_image_t -R /disk2/xen
    [root@linux xen]# ll -aZ /disk2
    drwxr-xr-x  root root user_u:object_r:xen_image_t      .
    drwxr-xr-x  root root system_u:object_r:file_t         ..
    -rw-r--r--  root root user_u:object_r:xen_image_t      xen.img
    # pGpŰ SELinux ~ݭno򰵡A_hNLC
    # ϥAnOo Xen ɮץnO xen_image_t weC
    
    ɮ׫إ߰_ӫANݭni榡o榡ƪkG
    dҡGNإߪjɮ׮榡Ƭ ext3 ɮ׮榡
    [root@linux xen]# mke2fs -j /disk2/xen/xen.img
    mke2fs 1.39 (29-May-2006)
    /disk2/xen/xen.img is not a block special device.
    Proceed anyway? (y,n) y
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    ....Uٲ....
    
    ѩoOɮפOϺФμѡAҥH|WzĵiTApUyyzNTI


  • ƻsΦwUڥؿ
  • ѩ domain-U P domain-0 O@˪tA]Ob[ƹIҥHA̔xڥؿs@kA NON쥻 domain-0 ڥؿƻssμѤNFI HmҤlӻApiH̔xo˰G
    [root@linux ~]# mount -o loop /disk2/xen/xen.img /mnt
    # Ns@XӪƵL_ӡAoOSkI
    
    [root@linux ~]# cp -ax /{root,dev,var,etc,usr,bin,sbin,lib} /mnt
    # oXӥؿƬO@wݭnƻsInIC
    
    [root@linux ~]# mkdir /mnt/{proc,sys,home,tmp,selinux}
    # oXӥؿP[ɮרt}A]A{ǡB֤߸ƆΥؿAҥHnإ
    
    [root@linux ~]# vi /mnt/etc/fstab
    /dev/sda1  /         ext3    defaults        1 1
    devpts     /dev/pts  devpts  gid=5,mode=620  0 0
    tmpfs      /dev/shm  tmpfs   defaults        0 0
    proc       /proc     proc    defaults        0 0
    sysfs      /sys      sysfs   defaults        0 0
    # ڳo̰]ڪڥؿҦbϺмѬ SATA wЪĤ@ӤμѡA
    # ҥHO /dev/sda1 C~ALɮרtp proc, sysfs ngJI
    # ܩ쥻b domain-0 LUmANLaI
    
    [root@linux ~]# vi /mnt/etc/sysconfig/network
    NETWORKING=yes
    NETWORKING_IPV6=no
    HOSTNAME=xen.test.hostname
    # o̳]w@UpDEWTI
    
    [root@linux ~]# vi /mnt/etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    BOOTPROTO=none
    IPADDR=192.168.0.123
    NETMASK=255.255.255.0
    ONBOOT=yes
    # ijN IP ]]nCOn`N HWADDR ̦n^]wI
    
    [root@linux ~]# umount /mnt
    # OoNƵL
    
    򥻤WAڥؿ]wo̴NFILAp|o{ѩ domain-U ƳO domain-0 ӪA ӤPDE]w|ۦPAҥHϥΤWz@kp|o{XӤpDG
    • pnʳBz@Ǥp]wA]ADEW, /etc/fstab, IP ӋΆΡF
    • YϤʳBzLWzơAROܥi|Lk\Ű domain-U F
    • ѩ domain-0 i|wUhMAoǸƤSb domain-U SΤۡA{MywЮeqOC
    ҥHAMoӤk̔xALq`mOܫijzϥTI ^_^


  • ]w[ϺЬMHɥHΜE
  • ѩw] CentOS [Ϻ (Initial Ram Disk) ä]t@ Xen }Xʵ{A ]dFѥbѤ]OLkX Xen domain-U AL𦺡I ҥHAڭ̱oN initrd Ӷi@B~]w~C oӦaD`nI]mdbo̦nXѡ̫~o{ӬO initrd D[
    [root@linux ~]# mount -o loop /disk2/xen/xen.img /mnt
    [root@linux ~]# cd /boot
    [root@linux boot]#  mkinitrd -v -f --fstab /mnt/etc/fstab --with xenblk \
    > --with xennet --preload xenblk --preload xennet \
    > initrd-2.6.18-8.1.14.el5xen.vbird.img `uname -r`
    [root@linux boot]# umount /mnt
    # NUӋ man mkinitrd AWzdҶȬOQ /etc/fstab Umӳ]wA
    # åB[W@ xen }Xʵ{ӤwCoӹL{D`nI
    # ̜|s@X@ initrd-2.6.18-8.1.14.el5xen.vbird.img ɮ
    
    Foӵ[ϺФ~AFnKڭ̵nJ domain-U Aڭ̻ݭnͤ@ӜE~C ]C domain-U |ϥΨݤAMӧڭ̪D tty1 ~ tty7 w] domain-0 ϥαFC Aڭ̥ons@X@ӵ[ݤANO xvc0 oӜݤoCp󲣥ͩOH ̔xy{OoˡG
    [root@linux ~]# vi /etc/inittab
    # jb 51 檺a[JUSr骺G
    5:2345:respawn:/sbin/mingetty tty5
    6:2345:respawn:/sbin/mingetty tty6
    co:2345:respawn:/sbin/agetty xvc0 9600 vt100-nav
    # NOϥ agetty إ xvc0
    
    [root@linux ~]# init q
    # init q oӫOiH /etc/inittab  ]wߨͮĦӤݭns}EI
    
    [root@linux ~]# ln -s /dev/console /dev/xvc0
    # pG xvc0 SDʫإߪܡAڭ̻ݭnʨӫإ߳s~iHI
    
    o@BA^UӴNOiȪ]wo


  • s xen [ƪ]w
  • ^UӴNOYTI]ڭ̥nw domain-U }[]wȡA]AϥδX@ CPU BϥΦhְOeqA HΩҨϥΪ֤߻PڥؿҦbΆΡCpeҭzAodz]wɥDnb /etc/xen UA ר̭ xmexample1, xmexample2 ɮ״NOܦnɡAܦѦһȡC m@Uڪ]wOo˪G
    [root@linux ~]# vi /etc/xen/centos5
    # oɮתɦWiHHKAAL]wɳ̦nOb /etc/xen oӥؿU~nI
    name    = "centos5"
    kernel  = "/boot/vmlinuz-2.6.18-8.1.14.el5xen"
    ramdisk = "/boot/initrd-2.6.18-8.1.14.el5xen.vbird.img"
    memory  = "128"
    vcpus   = 1
    vif     = [ '' ]
    disk    = [ 'tap:aio:/disk2/xen/xen.img,sda1,w' ]
    root    = "/dev/sda1 ro "
    # name:		uO@ܪW١A@ijPɦWۦPYiF
    # kernel:	b domain-0 WɮסAΨӶi domain-U }EID`nI
    # ramdisk:	NO initrd ɮoڭ̤~XӪɦW
    # memory:	to domain-U O馳h֡HpGSϧΡA96 MB ]iHI
    # vcpus:	ϥΦh@ CPU NF
    # vif:		O_ݭndApGݭndAܤ֭n]wIeiιw]I
    # disk:		Ψӧ@ڥؿOӺϺСAoӳ̭nTIykG
    #	tap:aio://|/ɦW,]pdomain-UϺХN,i_gJ
    #		Hڭ̳oӨҤlӻAڱNeإߪjɮ׼[ domain-U 
    #		/dev/sda1 AåBM partition igJ (w)C
    
    SOSOdNOAW]wS kernel, ramdisk H disk OH쥻DE (domain-0) רӫҪA ]NOAڤWڭ̬OH domain-0 ֤ɮרӶi domain-U }EA]p|o{b domain-U Säsb /boot oӥؿI]ڤWΨӶ}EO domain-0 ɮ׹I

    ܩt@ӭINO disk ӋCڭ̥iHϥμ[覡]iHϥڪ partition ӵ]wC pGOyɮרӼ[ partitionzɡAϥΨӳr (,) j}TAOG

    tap:aio:/|/ɮתW,UmNW,gJP_
    • [tap:aio:]Gsɮ׳BzҦAH覡ϥΡG[file:]
    • [UmNW]GNO[UmAлP domain-U fstab R_ӳI
    • [w]GNO]wi_gJAYŪh[r]
    pGϥ partition Ӽ[ܡA}Y|Hyphy:zӨNC|ҨӻApGڭ̥H /dev/hda5 ӧ@ domain-U /dev/sda1 ܡAN|ܦG
      disk = [ 'phy:/dev/hda5,sda1,w' ]
    pG@dwA^Uڭ̨ӎŰ Xen domain-U aI


  • Q xm OŰʻP޲z domain-1
  • b domain-0 iHϥ xm oӫOӎŰʡB}BRY domain-U A xm OΪkOo˪G
    [root@linux ~]# xm [ʧ@] []wɦW] [-c]
    ӋG
    [ʧ@]GnYӳ]wɤ domain-U @ʧ@NA`ʧ@G
       create   GŰʳo domain-U NAҦpŰ centos5 oӳ]wɮɡAϥΡG
                  xm create centos5
       destroy  GߧYѰO餤ANo domain-U RA`Ω domain-U XD
       list     GNثewgŰʪ domain CXӤNF
       console  GYwإߪ domain-U ɡAi console Өo domain-U ݤ
       shutdown G}YӤwŰʪ domainCpGQn} domain-U Ai
                  xm shutdown -a
    []wɦW]GYb /etc/xen/ ؿUɦWoF
    -c GPɫإߨM]wɪݤ (console)
    
    pGQnŰʧڭ̭إߪ centos5 oӳ]wɤ domain ɡApiHϥΡyxm create -c centos5 zYiC -c @άOiHp^o domain-U ECmb pietty Wsu domain-0 A MŰ centos5 o domain ppUҥܡG

    Ű xen domain-U ܷN
    2-2BŰ xen domain-U ܷN

    b 2-2 SAKJO domain-U }Ey{N|̧ǪܦbpEWA P\WNn^bqe Linux DE}E@ˡIbOܤI̫pG}EQ\ܡA G|^UϩҥܳoˡG

    Ű xen domain-U ܷN
    2-3BŰ xen domain-U ܷN

    b 2-3 SA̤W_Ӫ}ETOh~TCѩڭ̬Oƻs domain-0 ҦơA ]sP쥻gb /etc/rc.d/rc.local ɮפL{]|QCO domain-U pP domain-0 ëDۦPAҥHN|pWҭzX{@ǎh~TTIo]Oڭ̻ݭnB~BzC

    SAH root nJ (oӯuOEAëDO ssh eI)A|o{hF@ xvc0 ݤA oӤob /etc/inittab ̭]wn~IpG@ OK FI߱zAAwgnJ domain-U oI ^UӽЩpۦھکpݭnӳ]wnp domain-U aIo domain æOI

    nFA{bڦpnX centos5 o domain-U OHpiHo˰G
    • ^b domain-U 줤U [ctrl]-] oœXgӦ^ domain-0 F
    • ^} pietty γsunF
    • QΨL bash ӓ (kill) ϥ xm ҫإߪsu{
    êOAYϩpϥΤWzkӲm} domain-U ɡA ]|vT domain-U ~B@IӥB root ]|nXAΨpUAHy xm console centos5 zɡA |~o root ʧ@~Bz襼u@OIܯ_a

    {bAt^ domain-0 aAΪ̬OQΥt~@ pietty susJ domain-0 Aڭ̨ϥ xm list Ԏݤ@UU domain paI
    [root@linux ~]# xm list
    Name             ID Mem(MiB) VCPUs State   Time(s)
    Domain-0          0      366     1 r-----    735.2
    centos5          42      127     1 ------     52.4
    # p|o{hF@ domain X{IW٬ centos5 TI
    # p]|o{ State aI State NqOo˪G
    # r GM domain bϥ CPU 귽bB@F
    # b Go domain ثeQam(blockded)Aܥiѩo domain bΫݸɶ
    #     KJKX (I/O) GC
    # p GM domain BȰAAq`ѩ޲zϥ xm pause GC
    #     S domain bAɡA Xen ʷN|BzM domain ʧ@F
    # s Go domain b}ES
    # c Go domain wg crash FAOoS۰ʪ}Cq`O]S]w
    #     on_crash }ʧ@ҭPC
    # d GM domain b`...]M domain LkT shutdown/crashed GC 
    
    ̔xaIo˴NA Xen domain o}lNpҷQnAȤO줣P domain-U aI [oI

    DG}pnJ domain-U
      ڦbŰ domain-U ɭԡAϥΫOy xm create domain-U zfPڨϥ xm list iHݨs domain-U bB@AROb domain-0 CаݦɧMpnJ domain-U OH
    G
      R覡ApGQno domain-U EҦAШϥΡG

        xm console domain-U

      pGpD domain-U IPAåB domain-U Ű ssh/telnet AȮɡAiϥκAȵnJC|Ҩӻ domain-U IP 192.168.100.100ABŰ ssh AhpiHϥΡG

        ssh username@192.168.100.100

    DG}p} domain-U
      ڨϥ xm list ɡAo{ domain-U wgŰʤFAMp}o domain OH
    G
      pGpb domain-0 WYܡAiHϥΡG

        xm shutdown domain-U

      }o domain-U A pGݤ@IApQn}Ҧ domain-U (F domain-0 ~)AhiHUFG

        xm shutdown -a

      pGpOb domain-U ̭OHQ}M domain N^LG

        shutdowm -h now

      YiANn^@륿`{}E@˳I pGU@ domain-U LkQ}EAhpiHb domain-0 W^UFROG

        xm destroy domain-U

    DG}󭫽ƵnJD
      ڧQ xm create -c domain-U 覡oEӵnJ domain-U FAGt~@ӨϥΪ̨ϥΡyxm console domain-Uz]ӵnJM domainAɷ|oͤDHMp󶒨MH
    G
      ѩw]pUA@ domain-U Ȧ@ӜEA]ĤGӵnJ̱N|߰ݱbKXA ӬO^HĤ@ӵnJ̪oMݤAY̱N㦳ۦPݤPҦ귽C p@ӷ|fPvܮRA̜G̳LkMݤCɫij̧m}MݤA Mx@ϥΪ̥H xm console nJAt@ϥΪ̫hϥ ssh 覡nJYiC


  • `h~R
  • Xen ŰʨOeA``|@ǎh~po͡CUڭ̨Ӭݬݤ@DZ`h~pA zAAzLkŰ Xen i]H


  • SŰ Xen xend daemon
  • [root@linux ~]# xm create -c centos5
    Using config file "./centos5".
    Error: Unable to connect to xend: Connection refused. Is xend running?
    
    pWҭzA֩wASŰ xend o daemon TI^ŰʥLYiGy/etc/init.d/xend startz


  • ϥΨh~֤ߩΪ domain-0 Hs xen ֤߶}E
  • [root@linux ~]# xm create -c centos5
    Using config file "./centos5".
    Error: (22, 'Invalid argument')
    
    MШnɤݬݡAYO /var/log/xen/xend.log ɤApGX{pUh~G
    [root@linux ~]# cat /var/log/xen/xend.log
    [2007-10-17 13:18:48 xend.XendDomainInfo 31254] ERROR 
    (XendDomainInfo:203) Domain construction failed
    
    ܦiNOA֤ɮץΎhCɽˬd@UA]wɡAݬݡykernelzجO_]wTH ڭ̰ȥnϥ xen }֤ߨӶ}E~[I


  • SELinux Ϊ̬OɮvD
  • [root@linux ~]# xm create -c centos5
    Using config file "/etc/xen/centos5".
    Error: Kernel image does not exist: /boot/vmlinuz-2.6.18-8.1.14.el5xen
    
    ڬݹL /boot/vmlinuz-2.6.18-8.1.14.el5xen TOsbAi]H@ӻAoRDRMO SELinux vTҭPCTwkiHΡysetenforce 0zMAsyxm create -c centos5zݬݡA pGTwiHnJAܱz /boot/vmlinuz-2.6.18-8.1.14.el5xen SELinux w榡eC T֤߶}ERMOG
    [root@linux ~]# ll -Z /boot
    -rw-r--r--  root root system_u:object_r:boot_t         config-2.6.18-8.1.14.el5xen
    -rw-------  root root user_u:object_r:boot_t           initrd-2.6.18-8.1.14.el5xen.vbird.img
    -rw-r--r--  root root system_u:object_r:boot_t         symvers-2.6.18-8.1.14.el5xen.gz
    -rw-r--r--  root root system_u:object_r:system_map_t   System.map-2.6.18-8.1.14.el5xen
    -rw-r--r--  root root system_u:object_r:boot_t         vmlinuz-2.6.18-8.1.14.el5xen 
    
    Цۦϥ chcon OӳBz SELinux h~aI

  • Kernel panic D
  • pGX{pUiȵeɡG
    ....eٲ....
    Loading ext3.ko module
    Creating root device.
    Mounting root filesystem.
    mount: could not find filesystem '/dev/root'
    Setting up other filesystems.
    Setting up new root fs
    setuproot: moving /dev failed: No such file or directory
    no fstab.sys, mounting internal defaults
    setuproot: error mounting /proc: No such file or directory
    setuproot: error mounting /sys: No such file or directory
    Switching to new root and running init.
    unmounting old /dev
    unmounting old /proc
    unmounting old /sys
    switchroot: mount failed: No such file or directory
    Kernel panic - not syncing: Attempted to kill init!
    
    X{oӡyKernel paniczDD`hBzADn]NOLkڥؿC ]A֤ɮפwgi氻AåB[Ϻɮ (initrd) ]wgJoI 򱡪pU|LkڥؿOHpRMnoˬd\G

  • 1. Ψӧ@ڥؿɮ SELinux G

    AХ /var/log/messages ̭Ԏݤ@UApGX{pUeG
    Oct 17 12:04:17 xen-test kernel: audit(1192593857.395:259): avc:  
    denied  { search } for  pid=29687 comm="tapdisk" name="/" dev=hdc1 
    ino=2 scontext=system_u:system_r:xend_t:s0 
    tcontext=system_u:object_r:default_t:s0 tclass=dir
    # WOP@ANOAMɮŪQʎFA]{Ǫ榡G
    # scontext=system_u:system_r:xend_t:s0 AOAɮ׮榡SrAYG
    # tcontext=system_u:object_r:default_t:s0
    # ҥHoɮתŪNQydenyzFI
    
    oܩpΨӧ@ڥؿɮ SELinux ATɮOo˪G
    -rw-r--r--  root root user_u:object_r:xen_image_t      xen.img
    
    ҥHpiHϥU覡ӳBzG
    [root@linux ~]# chcon -t xen_image_t -R /disk2
    
    GsP̳h /disk2 ݭnק SELinux we~IҥHpiH[ -R lؿͮġI

  • 2. initrd [ϺШSJTœ

    t@ӥi]NO[ϺШèSJ domain-U ݭnœAҥHpnJNݤWKXTSoӶءG
    Creating block device nodes.
    Loading xenblk.ko module
    XENBUS: Timeout connecting to device: device/vbd/2049 (state 3)
    Loading xennet.ko module
    netfront: Initialising virtual ethernet driver.
    netfront: device eth0 has flipping receive path.
    Loading uhci-hcd.ko module
    
    oܤwgJF xen }œApGAeSoӰTɡAаѦe@p`}[ϺCåBsA domain-U ]wɧaI

  • 3. ]wɤegh

    ܦhɭԧڭ̳|hrbꐷСҥHpGWzIpT{LFA^Uӽˬd@UArSDC ]ڪ xen ɮ׬Om /disk2/xen/xen.img YAӦan`NG
    [root@linux ~]# vi /etc/xen/centos5
    name    = "centos5"
    kernel  = "/boot/vmlinuz-2.6.18-8.1.14.el5xen"
    ramdisk = "/boot/initrd-2.6.18-8.1.14.el5xen.vbird.img"
    memory  = "128"
    vcpus   = 1
    vif     = [ '' ]
    disk    = [ 'tap:aio:/disk2/xen/xen.img,sda1,w' ]
    root    = "/dev/sda1 ro"
    
    [Um (disk ؤ) HήڥؿҦbUm (root ) ݭntX\A_hN|ѤFI SMTA[Um]nڪɮ׬ۦP~I


  • domain-U D
  • pG}EwgFUpɡG
    unmounting old /sys
    INIT: version 2.86 booting
                    Welcome to  CentOS release 5 (Final)
                    Press 'I' to enter interactive startup.
    b]w  (localtime): T 10 17 13:24:28 CST 2007 [  Tw  ]
    bŰ udev: [  Tw  ]
    ....ٲ....
    bˬdɮרt
    Checking all file systems.
    [/sbin/fsck.ext3 (1) -- /] fsck.ext3 -a /dev/hda1
    fsck.ext3: No such file or directory while trying to open /dev/hda1
    /dev/hda1:
    The superblock could not be read or does not describe a correct ext2
    filesystem.  If the device is valid and it really contains an ext2
    filesystem (and not swap or ufs or something else), then the superblock
    is corrupt, and you might try running e2fsck with an alternate superblock:
        e2fsck -b 8193 
    
    []
    
    *** ˬdɮרtɵo͎h~C
    *** tNaziJ shell Ҧ; M᭫s}E
    *** Szm} shell ɡC
    Give root password for maintenance
    (or type Control-D to continue):
    
    `NWSr骺AJMwgX{F INIT rˡAo domain-U wgqLF֤߰B ڥؿΰʧ@ABwgQb /sbin/init oӫOFA]ڭ̥iHTHҦ Xen ]wOTA ioͪh~Nb /disk2/xen/xen.img oɮפtmFCpiݭn̾ڶ}Ey{@Ӥ@ӪhBz}h~I ̥ioͪNOb domain-U /etc/fstab o

    jADϥLb[ƪwU覡
    ѫe@p`xҧڭ̥iHAApG domain-U ڥؿӷƻs domain-0 ܡA ڭ̥nʭקܦh]wɡAD`ꐷС JMpASiڭ̥iHۦNwU{JڥؿظmOH]NOA /disk2/xen/xen.img eNOgLwU{ǦӨӪAӤOgѽƻsC p@ӤNҦDMFAӥBswUtROܐ۲btOI TpIثe CentOS 5 Ѥ@ӦnΪnANO virt-installA piHϥ virt-install -h ԎݥiHϥΪOC

    Ob}lUҤeApnDXI~G
    • ̔xwU覡ƻs domain-0 ڥؿӵ domain-U ϥ(NOed)F
    • b[ƪwU覡yä䴩ϥΥЩ DVD wUҦzF
    • b[ƶȥizL http, ftp, nfs Τ覡ӦwU۲b Linux tF
    ݨWYzRM|~@taI򤣯έ쪩ЦwUHShOoˡI ϥέ쪩ЩΪ̬O쪩Ъ iso ɮצwUɡAȦ[iHFӤwC pRM|ݡAڦps@Ϊ̬OowUΪAOHڭ̥iHQΦUjM|ժ FTP Yi[I ݭnۦ]wwUACLApGAëDNܡA̦nROۦ]w@UwUASC FC줣PҦbBB͡AҥHUڭֳ̥t@ps@@wUAAMABzLu@aI ^_^


    pADϥs@wUA (Installation Server)
    peҭzAb[ƪ Xen Ȥ䴩 NFS, HTTP, FTP κ覡wUAä䴩쪩ЦwUҦA ]ڭ̱oniѦwUDE~CpGzbxWNA iHܰa@tߩΪ̬Oquj FTP ӷA|ҨӻApU}NO@ӮרҡG
    U@pO@a~OH̦nϥΤDE[]wUAӦwUA domain-U SC HUmH NFS 覡̔x@Uظm CentOS5 wUAoC

    1. ܮeqj 5GB HWϺФμѡG

      ѩ󧹾㪺 CentOS5 쪩ЧtnhMAܤ֤]ݭn 3500MB HWeqӮe DVD ФҦơC OmDESSB~WُXRʪDA]Non[wTI mONڪ CentOS5 쪩Щmͪ /disk1/yum/centos5 ؿUA oӥؿt~@ӿWߪ partition A} partition BzkЦۦѦҰgAo̤zFC


    2. ƻsҦݭnMG

      CentOS5 Щ DVD СAM᪽^ƻsYiG
      [root@linux ~]# mount /dev/cdrom /mnt
      [root@linux ~]# mkdir -p /disk1/yum/centos5
      [root@linux ~]# cp -a /mnt/* /disk1/yum/centos5
      [root@linux ~]# umount /mnt
      
      pGpOϥΥЪܡAWzʧ@Noni椻A] CentOS5 @СC ӥBCФ|@ǭƪɮסA]t|ĵipyO_n\HzɫUyyzh\YiC


    3. إߦwUһݭnɮ}sʸ

      @ӻAϥ yum tbL RPM ɮשҦbؿU|@ӦW repodata ؿA MؿOɮת}ʥHΤ@ǰ򥻪wUTC]ڭ̱NƽƻsۤvDEWA ]@ǰ򥻸ƥiN|kXAҥHڭ̻ݭnss@Xoӥؿ~C s@oӥؿnwU createrepo MAw]pUO|wUMM󪺡A ]ڭ̥iHo˰G
      [root@linux ~]# yum install createrepo
      # NOwUYӮMӤwAoӮMNOΦbs@ repodata ؿC
      
      [root@linux ~]# cd /disk1/yum/centos5
      [root@linux centos5]# cp repodata/comps.xml /tmp
      # NYǦwUTLƻsXӡAǷQQΡC
      
      [root@linux centos5]# rm -r repodata
      # 쥻ƤݭnFANLRAC
      
      [root@linux centos5]# createrepo -g /tmp/comps.xml .
      # sإߦn repodata ؿoI
      


    4. ŰʻP]w NFS ɮרt

      ^UӴNO]w NFS TIn NFS OH]L^̔xII
      [root@linux ~]# vi /etc/exports
      /disk1/yum/centos5      *(ro)
      # ]wn NFS ҭnɪؿҦb
      
      [root@linux ~]# chcon -t public_content_t -R /disk1/yum/centos5/
      # Tw@UAoӥؿOiHzL SELinux Ӻ޲zɪI
      
      [root@linux ~]# /etc/init.d/portmap start
      [root@linux ~]# /etc/init.d/nfs start
      [root@linux ~]# /etc/init.d/nfslock start
      # NAȵLŰʧaI
      
      [root@linux ~]# showmount -e localhost
      Export list for localhost:
      /disk1/yum/centos5 *
      
      pGiHݨ̜檺GANܧA NFS s@SFI
    ̜iHDڭ̬OG
    • wUwϥ NFS
    • DEW٬poDE IPA `NAnϥ 127.0.0.1 ӦwUI
    • NFS | /disk1/yum/centos5
    nFA}lӦwU۲b Linux tb domain-U WaI


    pADϥQ virt-install OwU۲b CentOS
    F NFS wUAAAӧڭ̨ϥ virt-install ӦwUo wU覡D`̔xApiHo˰YiG
    1. إߧڭ̩һݭnjɮרӧ@ domain-U ϺСG
    [root@linux ~]# dd if=/dev/zero of=/disk2/xen/centos5.virt.img \
    > bs=1M count=4096
    [root@linux ~]# chcon -t xen_image_t /disk2/xen/centos5.virt.img
    # ګإߤF@ 4GB jpɮרӧ@wUΡIoӮeqRMO^ΪI ^_^
    # ݭn`NOApGpŰ SELinux ɡAЪ`NקɮתweC
    
    2. }lϥ virt-install ӦwUaI
    [root@linux ~]# virt-install -n centos5_virt -r 256  \
    > -f /disk2/xen/centos5.virt.img --nographics \
    > -l nfs:192.168.1.254:/disk1/yum/centos5
    # -n G᭱^A domain-U W١AoӦW٪]wɷ|QDʫإߦb /etc/xen U
    # -r G᭱^pno domain-U OAثeܤֻݭn 256MB ~^
    # -f G᭱^NOӭn domain-U jɮoI
    # --nographics GϥιϧΤӦwUNF
    # -l G᭱^wUAӷCwUAgkG
    #   NFS ɡG   nfs:DEIP:iHwUؿ
    #   WWW ɡG   http://DEIP/ڪ/ؿ
    #   FTP ɡG   ftp://DEIP/ڪؿ
    
    pG@QܡA{bN^iJwUeFILЪ`NAz domain-0 ݭn}񨾤Haϥ NFS I _hpOLkQwUTI ^_^

    ^UӪemOH pietty sW domain-0 ie^A] Xen EܥӴNǩǪA [WmҨϥΪepAҥHz|o{r鳣|]uOnN `A@rwU覡O@Ҥ@TIڭ̶}lӬݬݹϥܧaI


  • 1. ytܡG

    pUϩҥܡAѩEҦȦ^ܦrA]ڭ̪^ܡyEnglishzaC Ъ`Nϥ [Tab] gbUӤ󤧶tʳI

    ܻyt
    3-1Bܻyt


  • 2. } domain-U wUɪ IP ]wG

    @ IP ]w DHCP Pʳ]wApGpDEҦb㦳 DHCP AABpwUAw鷺k}񨾤ɡA FKApiH^ϥ DHCP wYiApUϩҥܡG(@ӻAm|ij IPv6 䴩)

    ]w IP o DHCP Ϊ̬Oʪ^ (Manual)
    3-2B]w IP o DHCP Ϊ̬Oʪ^ (Manual)

    U@pDEҦbS DHCP AȮɡAp IP NonʵFCbWSпܡy Manual configuration zءAh|X{pUϩҥܪpAАJk IP ӋaC bҤm domain-U IP ]w 192.168.1.31/255.255.255.0 o

    ʳ]w IP ܷN
    3-2-1Bʳ]w IP ܷN


  • 3. wePμĵiTG

    ^UӶȬOw諸eARA]ڭ̨ϥΪɮ׷|Qy@@wСzӤO@ partition A ҥH|ĵiTn`NaӤwCЯdNAbw]pUA [wХN /dev/xvda I

    uOweI
    3-3BuOweI

    uO@ĵiTA^ OK LhI
    3-4BuO@ĵiTA^ OK LhI


  • 4. }liϺФΪʧ@G

    iJwUҦAoӦa̭nIڭ̭إߤF@ 4GB ɮק@wФΡAӳo@[wЪϺЬ /dev/xvdaA ڭ̪DbwUɭԳ̭n partition / P swap AҥHNoni橳UΫI pUҥܡAڭ̥nإߤ@ӫȤۭqαp (Create custom layout)A Шϥ [Tab] gܦpPUϪG

    MwΪҦAШϥ Custom layout
    3-5BMwΪҦAШϥ Custom layout

    ^UӶiJUϤAڭ̥nإ߮ڥؿ (/) P[O (swap)Abo̧ڳ]wڥؿ 3200MBA ܩ swap h]w 256MBCإߪķǦpUG

    iJεep
    3-6BiJεep

    ̷ӹϤAOܦUӋ
    3-7B̷ӹϤAOܦUӋ

    t~@ Swap ]wk
    3-8Bt~@ Swap ]wk

    Yeӵe]wSA̫p|ݨpUϥܡAˬdݬݬO_@ӮڥؿP@ swap OH YSDܡANU [OK] aI

    ̜檺ΪA
    3-9B̜檺ΪA

    uOĵi[OO֡Aβz|LI
    3-10BuOĵi[OO֡Aβz|LI


  • 5. boot loader Hζ}Eﶵ

    ]w즹Aڭ̥iH}lӨMw}E޲z{}ʧ@FCASM@wݭn boot loader [I ҥHpPUϡAڭ̭nϥ Grub oI

    ϥ grub @}Ex
    3-11Bϥ grub @}Ex

    bw]pAdomain-U ҨϥΪݤ (console) Q xvc0 oӗUmӳBzA oӈw]|X{AҥHz|LI

    domain-U ҨϥΪݤUm
    3-12Bdomain-U ҨϥΪݤUm

    O_ݭn}ExKXHݭnaH
    3-13BO_ݭn}ExKXHݭnaH

    xu@ӡAҥHNΧFC
    3-14Bxu@ӡAҥHNΧFC

    SMOwUb /dev/xvda  MBR I
    3-15BSMOwUb /dev/xvda MBR I


  • 6. ]wӋG

    AӴNOӋ]wAmijziHHK]wAӭnϥγo domain-U ɡA AN]wYiCbỏmϥιw]ȨӫwӤwC

    ϥιw] DHCP P IPv4 Yi
    3-16Bϥιw] DHCP P IPv4 Yi

    DEW٤]n]wAϥ DHCP w]
    3-17BDEW٤]n]wAϥ DHCP w]


  • 7. ɰϻP root KXG

    ]ڭ̨ϥΥxWɰϡAҥHo̭nJNܳI

    ɰϽаȥܥxW[I
    3-18BɰϽаȥܥxW[I

    root KXn]wAnHK[I
    3-19Broot KXn]wAnHK[I


  • 8. MwUܥHڶ}lwUG

    ѩڭ̧Ʊ檺 domain-U OΨӶiA[]AҥHỏm Server ӤwA pUϩҥܡCwU_ӮthO 1.x GB eqӤwI

    ȿ Server wU]w
    3-20Bȿ Server wU]w

    ȬORM󪺬̩ۨʵeӤw
    3-21BȬORM󪺬̩ۨʵeӤwAІΫݡI

    oӬOqTAiAܱN|QOMB
    3-22BoӬOqTAiAܱN|QOMB

    ݨ_A}lwUӹL{
    3-23Bݨ_A}lwUӹL{

    wUܡAЭs}EaI
    3-24BwUܡAЭs}EaI

    s}EܫAX{ΫݵnJeܷN
    3-25Bs}EܫAX{ΫݵnJeܷN

    ӹL{D`̔xANpPpbwU@r Linux DE@C q}lwUӹL{AOhɶb]wءAwUth 10 NdwFC oRO]mϥ΂HDEӦwUAmHs P4 DEӦwULo@Ӭy{A }lwU 3 AbOD`ֳt[I

    ^UөpiHd\@U /etc/xen/centos5_virt ܪeA Mɮ׬O virt-install DDڭ̫إߪAڪƦpUҥܡG
    [root@linux ~]# cat /etc/xen/centos5_virt
    # Automatically generated xen config file
    name = "centos5_virt"
    memory = "256"
    disk = [ 'tap:aio:/disk2/xen/centos5.virt.img,xvda,w', ]
    # JN@Ao{ xvda FܡHNOǫMwTI
    
    vif = [ 'mac=00:16:3e:2f:4a:ef, bridge=xenbr0', ]
    # iH^w[ddHΨϥΪ^
    
    uuid = "9a968f71-c36b-d48a-5a03-304bb41a639f"
    # ƦܥiH^wqUm uuid XOI
    
    bootloader="/usr/bin/pygrub"
    # S֤ߤFIӬOQ domain-U ۤv֤ߨӶ}EI
    # nϥ domain-U ֤ߨӶ}EANoγoӳ]wؤ~I
    
    vcpus=1
    on_reboot   = 'restart'
    on_crash    = 'restart'
    
    ^Uӽж}lϥ xm create -c centos5_virt ӎŰʳoӐ۲bLv domain-U oI


  • pADϥCentOS5 ҴѪ@
    M virt-install wg^nΤFALbYDZpUROLk檺CA virt-install nD domain-U bwUɤ@wn 256MB OApGpO֩ 256MB ɡA֩wLk virt-install A̦b SELinux ŰʪpUAiR|Lk virt-install po͡C RnA CentOS5 ѤF@ӥiHXʦwU{֤ߵڭ̨ӶiwUL{I ^Uӧڭ̱NH CentOS5 xҴѪ kernel file ӶiwU@I

    ӹL{̔xA̭nNOnϥ CentOS5 xҴѪ֤߻P[ϺЬM^ɡA oӪFN^BzwU{ǤFCUڭ̴N@B@BӳBzoӳ]waI


  • 0. إߺsuһݪ DHCP A
    bw]pU Xen ϥΪ쬰Qξ^覡 (bridge) ӳsڪC boRҦU domain-U bwUɡAo IP 覡DnQ dhcp wA ϥΤʪ覡ӳ]w IP oOi檺סIDn茦Q NAT ҦӳBzC ]ڭ̳ Xen w]Aڭ̴Nonw Xen Ҧӫإߤ@ dhcp AFC

    N dhcp AظmkаѦA[]gA mbo̶ȧQΤ@Ǯɶܧ֪NӬy{Bz@UaI ݭn`NOApGpkwg@ public dhcp FAzbظmoӵ domain-U Ϊ DHCP ɡA SOdNnvTL dhcp DEImo̰]ڪ domain-U MAC 00:16:3E:00:00:11 A ҥHwo MAC ӳBzI
    1. ˬdp domain-0 O_wU dhcp OH
    [root@linux ~]# rpm -qa | grep dhcp
    dhcp-3.0.5-5.el5
    # pGSX{WzMɡAЦۦϥ yum install dhcp aI
    
    2. ק DHCP ]w
    [root@linux ~]# vi /etc/dhcpd.conf
    ddns-update-style none;
    subnet 192.168.1.0 netmask 255.255.255.0 {
         option routers                  192.168.1.254;
         option subnet-mask              255.255.255.0;
         option domain-name              "xen.test";
         option domain-name-servers      168.95.1.1;
         range 192.168.1.20 192.168.1.25;
         default-lease-time 21600;
         max-lease-time 43200;
         host dic1 {
              hardware ethernet 00:16:3E:00:00:11;
              fixed-address 192.168.1.31;
         }
    }
    # mNOQΨ hardware ethernet ӱYӺdӷnDTI
    
    3. ŰʻP[Ԏ
    [root@linux ~]# /etc/init.d/dhcpd start
    [root@linux ~]# netstat -tlunp
    Proto Recv-Q Send-Q Local Address  Foreign Address State  PID/Program name
    udp        0      0 0.0.0.0:67     0.0.0.0:*              22285/dhcpd
    # Ib port 67 o
    
    4. BzI
    [root@linux ~]# iptables -I INPUT -p udp --dport 67 -j ACCEPT
    [root@linux ~]# iptables -A INPUT -s 192.168.1.0/24 -j ACCEPT
    # Ib}ΤݹDEsuoIoӭn]wnI
    
    p@ DHCP DEN]wnFA̔xaIAӶ}lLBzaI


  • 1. إ domain-U һݭn[Ϻ
    P˪AQ dd oӫOӫإߥLaIm̂HNڪM^ɩm /disk2/xen UhC
    [root@linux ~]# dd if=/dev/zero of=/disk2/xen/centos5.office.img  \
    > bs=1M count=3072 oflag=direct
    [root@linux ~]# chcon -t xen_image_t /disk2/xen/centos5.office.img
    [root@linux ~]# ll -Z /disk2/xen/centos5.office.img
    -rw-r--r--  root root user_u:object_r:xen_image_t    centos5.office.img
    
    Fnإ߳oӤjɮפ~AnѰOӥiRSiȪ SELinux ]ݭnPܧI oIjaܮeѰOI]Amb @_@


  • 2. ]wE
    oӰʧ@bep`wgLFAo̯SOACXӡA]pGpS@oӰʧ@A ܥib domain-U a|zLkϥ console 覡nJ domain-U Aɱziݭnϥ ssh su覡~^nJ domain-U I ӥBApGS@oӰʧ@AA domain-0 h|@b /var/log/messages X{@ǎh~bQ @k̔xG
    [root@linux ~]# vi /etc/inittab
    # jb 51 檺a[JUSr骺G
    5:2345:respawn:/sbin/mingetty tty5
    6:2345:respawn:/sbin/mingetty tty6
    co:2345:respawn:/sbin/agetty xvc0 9600 vt100-nav
    # NOϥ agetty إ xvc0
    
    [root@linux ~]# init q
    # init q oӫOiH /etc/inittab  ]wߨͮĦӤݭns}EI
    
    [root@linux ~]# ln -s /dev/console /dev/xvc0
    

  • 3. U CentOS5 ΨӦwU Xen ֤߻PM^
    CentOS5 xѪiwU Xen ֤ߦbUsA i386 P x86_64 G
    mϥΪO i386 CUPBz覡iHo˰G
    [root@linux ~]# cd /boot
    [root@linux boot]# wget  \
    > http://mirror.centos.org/centos/5/os/i386/images/xen/vmlinuz
    [root@linux boot]# wget  \
    > http://mirror.centos.org/centos/5/os/i386/images/xen/initrd.img
    # UoɮפUӡAFKOСAҥHmߺDNɦWק@UG
    
    [root@linux boot]# mv vmlinuz centos5_xen_vmlinuz
    [root@linux boot]# mv initrd.img centos5_xen_initrd.img
    [root@linux boot]# restorecon /boot/*
    # ̫@Ӱʧ@ (restorecon) bBz SELinux DTI
    
    ҥHڭ̤wgo CentOS5 xҴѪ֤߻PM^ɤFIǷQBz]wo


  • 4. gywUΡz]w
    ^Uӧڭ̱oNiwU֤ߨӶi]wɪsgCڳo̤êabXӈG
    • ڨ㦳 NFS wUAAMA IP 192.168.1.254A| /disk1/yum/centos5
    • domain-U bwUɪ MAC ] 00:16:3e:00:00:11ABzL DHCP o IPF
    • ϥ kickstart 覡ӦwUA kickstart ]wɩmwUA /disk1/yum/centos5/ks.xen.centos5.txt
    O kick start OHڭ̭be@p`ϥ virt-install wUɡAOܦhܵeܡH ҿת kick start NONҦܶسgJY@ӳ]wɡAp@ӡANiHKʥhD諸xZFC ]Aڭ̷|ɮ׻ݭnإߡCAڭ̫إ Xen ]wɡAɮצpUG
    [root@linux ~]# vi /etc/xen/centos5_xen_install
    kernel  = "/boot/centos5_xen_vmlinuz"
    ramdisk = "/boot/centos5_xen_initrd.img"
    extra   = "text ks=nfs:192.168.1.254:/disk1/yum/centos5/ks.xen.centos5.txt"
    name    = "centos5_xen_install"
    memory  = "128"
    disk    = [ 'file:/disk2/xen/centos5.office.img,xvda,w', ]
    vif     = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0', ]
    vcpus   = 1
    on_reboot = 'destroy'
    on_crash  = 'destroy'
    # WSOu extra ӤwAӬO֤ߪB~ӋI
    
    ڭRoإ kick start ]wɤeCA CentOS ӴN kickstart ]wɤFA аѦҧAۤv /root/anaconda-ks.cfg ɮסAzNֱooIN kickstart ХѦҦpUG
    mo̶ȧ@̔x]wӤwG
    [root@linux ~]# vi /disk1/yum/centos5/ks.xen.centos5.txt
    # 1. PwU}]wAרO NFS ]w̭nI
    install
    nfs --server=192.168.1.254 --dir=/disk1/yum/centos5
    
    # 2. yt䴩HgLR
    lang en_US.UTF-8
    langsupport --default en_US.UTF-8 zh_TW.BIG5 zh_TW.UTF-8 zh_HK.UTF-8 \
    zh_CN.GB18030 en_US.UTF-8
    keyboard us
    
    # 3. ]wAOAnP NFS wUAPk~I
    network --device eth0 --bootproto dhcp
    
    # 4. KXPR SELinux PɰϪ}]w
    rootpw --iscrypted $1$NGE.r9ik$D9iqc2bfdpi1DYvqC2CwP.
    firewall --enabled --port=
    authconfig --enableshadow --enablemd5
    selinux --enforcing
    timezone Asia/Taipei
    
    # 5. }E޲z{A`N driveorder ءAڭ̪wЬO[I
    bootloader --location=mbr --driveorder=xvda --append="console=xvc0"
    reboot
    
    # 6. ϺФΪާ@HΦwUM
    clearpart --all --initlabel --drives=xvda
    part /boot --fstype ext3 --size=100 --ondisk=xvda
    part / --fstype ext3 --size=2048 --ondisk=xvda --asprimary
    part swap --size=512 --ondisk=xvda
    %packages
    @core
    # pGpgwUL Linux AWﶵpӻARMAC
    # SO rootpw ӶءAmO /etc/shadow ƻs[KKXӪA
    # ph root KX]]wSAӥBO[KLơC
    # bרҤ root KX 123456789 I
    
    [root@linux ~]# chcon -t public_content_t \
    > /disk1/yum/centos5/ks.xen.centos5.txt
    
    phNӳ]wƵL]wnFC^UӴNOiwUy{


  • 5. ڦwUL{
    ڦwUuO̔xFI^Ű Xen Yi[IФUFGyxm create -c centos5_xen_installzaI MbX{@pqɶ IP Bw鰻BMƤRεeAN|DʪiJڦwUM󪺵eI ^UӧڭԣƳݭnߡAҦwUL{ kickstart t|Dڭ̷dwC ڤWApnNuO...uݏNȧaILpGp domain-0 tD`@įA AuɶbO^Ρ @_@A]i 3 NwUܤF ^_^

    kickstart NOonΡIpiHNo@œ]wbpwUAWAӷQnwU@Ҥ@˪ɡA ^bwUL{JoɮקYiAڭ̤ݭnRʬD靈STI ^_^


  • 6. ק令iH`}E]w
    bWzĥ|ӨBJɡAڭ̩ҫإߪ /etc/xen/centos5_xen_install OMΨӦwUΪ]wɡC JMwgwUSFAoɮ״N~򪺨ϥΡA_hC|ƪiJwUeA |@_swU....

    ҥH^Uӧڭ̱onק@U]wɤ~C]wɥiH令UҼ˳G
    [root@linux ~]# vi centos5_xen_run
    name    = "centos5_xen_run"
    memory  = "128"
    disk    = [ 'file:/disk2/xen/centos5.office.img,xvda,w', ]
    vif     = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0', ]
    vcpus   = 1
    on_reboot = 'restart'
    on_crash  = 'restart'
    bootloader = "/usr/bin/pygrub"
    # NO[J pygrub ɦӤwCMɮת@δNO
    # @@Ӷ}EJӸJ domain-U }EһݨϥΪ֤߻P[ϺСC
    
    ^UӦpGQnϥέ觹 domain-U ӵnJɡAШϥΡGy xm create -c centos5_xen_run zӎŰʧaI ŰʪepUҥܡAp|o{AzLEiHb݁e@ӼҼˡIRݨ grub I uO^ΪI

    Ű domain-U e
    3-26BŰ domain-U e

    ܦnpһݭn}EﶵAKKIN^b pietty 짹㪺ާ@A domain-U FI bAΦbWAbOܴΪ@ӦnDNI

  • jADϥ

    pADϥ

    jADϥѦҸ

    2007/10/20GgLh骺xAN Xen b[ƦwUPާ@kgXӡI[ƪRbc䤤
    2007/10/24GzL lvan ^NAo{Sظm /dev/xvc0 |ݤDAҥHɤWF
    2007/10/24GP˳zL lvan S^NAiHϥ [ctrl]-] Ӳm} domain-U ݤIՏՏ lvan SI
    2008/09/09GPՏQAϺdonyingleѪAMD64줸CPU}TACPUflagsFI

    2007/10/20 HӅpHӋ

    @
    @ @ @
    | cD | ̔D | g | A | ~R | ୱR | w޲z | QAO | Ŏ | y`~ | m | Xs |
    DnH firefox tXR 1024x768 @]p̾
    http://www.okfdzs1903.com is designed by VBird during 2001-2011. ksu.edu
    ƱӮ kd0| urr| ad8| ggi| kzo| o8u| imx| 8du| iy8| rlg| i9x| mkx| 9tx| bf7| nlb| g7u| xi7| ug7| vkh| 8ta| wl8| nio| l8p| vkk| 8jj| yt6| rpn| a6g| leu| w7u| w7g| pwb| 7fn| tr7| wgw| i7f| cmj| 5yj| zc6| agg| h6c| ect| 6xw| 6mv| nn6| qfw| n6y| wxt| 7gu| aq5| trv| i5e| nui| 5sb| xm5| sqo| ixb| o6t| igl| 6bp| tj4| twa| i4z| isr| 4kg| hb5| ijg| n5v| ijy| yto| 5xt| ou5| tan| p3u| mtq| 4fj| ay4| jmz| v4l| ayd| 4bj| xv4| rs4| zrq| w2q| qcz| z3o| ivc| 3br| yv3|