virt-clone 克隆虚拟机

virt-clone 用法

virt-clone --original <源虚拟机名称> -n <新虚拟机名称> -f <新磁盘文件路径>
--original  -o <源虚拟机名称>:要克隆的源虚拟机名称或ID。
--name      -n <新虚拟机名称>:新克隆虚拟机的名称。
--file      -f <新磁盘文件路径>:指定新虚拟机所用的新磁盘文件路径。

关闭需要克隆的虚拟机

virsh shutdown ctyun-2.0.1-01
Domain ctyun-2.0.1-01 is being shutdown

查看源虚拟机块设备信息

virsh domblklist ctyun-2.0.1-01
 Target   Source
-----------------------------------------------
 vda      /data/ctyunos/ctyun-01_system.qcow2
 vdb      /data/ctyunos/ctyun-01_data.qcow2
 hda      -

克隆虚拟机

virt-clone -o ctyun-2.0.1-01 -n ctyun-2.0.1-03 -f /data/ctyunos/ctyun-2.0.1-03_system.qcow2 -f /data/ctyunos/ctyun-2.0.1-03_data.qcow2
Allocating 'ctyun-2.0.1-03_system.qcow2'                                                             |  10 GB  00:01:36     
Allocating 'ctyun-2.0.1-03_data.qcow2'                                                               |  20 GB  00:00:00     

Clone 'ctyun-2.0.1-03' created successfully.

查看虚拟机

virsh list --all
 Id   Name             State
---------------------------------
 -    ctyun-2.0.1-01   shut off
 -    ctyun-2.0.1-03   shut off

运行虚拟机

virsh start ctyun-2.0.1-03
posted @ 2025-02-12 09:03  小吉猫  阅读(96)  评论(0)    收藏  举报