KVM虛擬機克隆(6)

常用克隆方法:

   1.virt-clone

   2.複製配置文件及磁盤文件


1.1

[root@localhost images]# virsh list --all
 Id    名稱                         狀態
----------------------------------------------------
 -     v1                             關閉
[root@localhost images]# virt-clone -o v1 -n v2 -f /var/lib/libvirt/images/v2.img
正在分配 'v2.img'                                                           |  20 GB     03:26    
Clone 'v2' created successfully.
[root@localhost images]#
[root@localhost images]# virsh list --all
 Id    名稱                         狀態
----------------------------------------------------
 -     v1                             關閉
 -     v2                             關閉
[root@localhost images]#


virt-clone -o源虛擬機 -n新虛擬機 -f新虛擬機磁盤位置


剩下的就是進入虛擬機修改hostname,IP地址。


2.1

複製虛擬機配置文件cp /etc/libvirt/qemu/v1.xml /etc/libvirt/qemu/v3.xml

複製磁盤文件cp /var/lib/libvirt/images/v1.img /var/lib/libvirt/images/v3.img


修改配置文件v3.xml:

<name>

<uuid>  可刪除

<disk>     <source>   磁盤路徑

<mac address>

<graphics>


重新定義新虛擬機:

virsh define /etc/libvirt/qemu/v3.xml


virsh start v3


登陸虛擬機修改 IP,hostname 即可。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章