步驟一
將原本那台虛擬機器的xml檔案匯出
#virsh dumpxml myVM > myVM_new.xml
步驟二
檢查匯出xml
#cat myVM_new.xml
顯示內容大致如下
<domain type='kvm'>
<name>UD1142</name>
<uuid>f9801f25-c66f-fc8d-d529-0ace42ad6b0f</uuid>
<memory>700000</memory>
<currentMemory>299008</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='i686' machine='pc-0.12'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/UD11042.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<interface type='bridge'>
<mac address='52:54:00:4d:40:c4'/>
<source bridge='br0'/>
<target dev='vnet0'/>
<model type='virtio'/>
</interface>
<console type='pty'>
<target port='0'/>
</console>
<console type='pty'>
<target port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<video>
<model type='cirrus' vram='9216' heads='1'/>
</video>
</devices>
</domain>
註1.
<name>UD1142</name>
不能重複要改掉
註2.
<uuid>f9801f25-c66f-fc8d-d529-0ace42ad6b0f</uuid>
整行刪除
註3.
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/UD11042.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/UD11042.img'/>
<target dev='vda' bus='virtio'/>
</disk>
這邊是設定在虛擬機器的映像檔
driver的type如果是raw代表一次到位
如果映像檔是vmdk的格式 則要改成type='vmdk'
<source file='/var/lib/libvirt/images/UD11042.img'/>是指映像檔的檔案位置
KVM的映像檔相容vmdk格式
註4.
<mac address='52:54:00:4d:40:c4'/>
mac不能重複
註5.
註5.
<graphics type='vnc' port='-1' autoport='yes'/>
如果要用vnc遠端桌面功能,則可把port改成5900,再把autoport改成no。(若有多台機器,則port要設成不一樣)
如果要用vnc遠端桌面功能,則可把port改成5900,再把autoport改成no。(若有多台機器,則port要設成不一樣)
步驟三
將/var/lib/libvirt/images底下的原始映像檔複製一份,並更改檔名。
步驟四
由虛擬主機設定檔(xml檔) 產生虛擬主機
#virsh define myVM_new.xml
步驟四
由虛擬主機設定檔(xml檔) 產生虛擬主機
#virsh define myVM_new.xml
No comments:
Post a Comment