1. 程式人生 > >linux 下的KVM 虛擬機

linux 下的KVM 虛擬機

machine lock graph -a ebo html 安裝 disk linux

linux 下的kvm的使用

  1. cpu開啟VT

  2. 安裝kvm套件

  3. 添加br0橋接網口

  4. 創建虛擬機磁盤,或者在安裝虛擬機的時候創建該磁盤。

  5. 安裝虛擬機

  6. 使用虛擬機

  7. 使用安裝的虛擬機磁盤做原始鏡像來啟動新的虛擬機

    1. 關閉安裝的虛擬機

    2. 復制安裝的虛擬機磁盤

    3. 重新define 一個虛擬機的xml文件,具體內容如下:


    4. <domain type='kvm'>
          <name>vm01</name>
          <memory>4096000</memory>
          <currentMemory>4096000</currentMemory>
          <vcpu>2</vcpu>
      
         <os>
            <type arch='x86_64' machine='pc'>hvm</type>
            <boot dev='hd'/> 
         </os>
      
         <features>
           <acpi/>
           <apic/>
           <pae/>
         </features>
      
         <clock offset='localtime'/>
         <on_poweroff>destroy</on_poweroff>
         <on_reboot>restart</on_reboot>
         <on_crash>destroy</on_crash>
         <devices>
           <emulator>/usr/libexec/qemu-kvm</emulator>
      
           <disk type='file' device='disk'>
            <driver name='qemu' type='qcow2'/>
             <source file='/storage/instance/vm01/centos6.6.qcow2'/>
             <target dev='hda' bus='ide'/>
           </disk>
      
           <disk type='file' device='disk'>
            <driver name='qemu' type='qcow2'/>
             <source file='/storage/instance/vm01/disk.qcow2'/>
             <target dev='hdb' bus='ide'/>
           </disk>
      
           <disk type='file' device='cdrom'>
             <source file='/iso/CentOS-6.6-x86_64-bin-DVD1.iso'/>
             <target dev='hdc' bus='ide'/>
             </disk>
      
           <interface type='bridge'>
            <source bridge='br0'/>
           </interface>
      
          <input type='mouse' bus='ps2'/>
           <graphics type='vnc' port='-1' autoport='yes' listen = '0.0.0.0' keymap='en-us'/>
         </devices>
       </domain>
    5. 啟動剛創建的虛擬機

    6. 大功告成

linux 下的KVM 虛擬機