中国建设教育协会官方网站,天津建设工程竣工备案公示网站,公司企业邮箱注册流程,花店网页设计首页图克隆主要是对磁盘文件进行操作。
1#xff09;完整克隆
a、拷贝虚拟机磁盘文件 b、生成虚拟机配置文件 centos7-2 291b0480-955a-45e2-a001-690fded69d1b c、导入xml并启动
[rootcentos8 ~]# virt-clone -o centos7 --auto-clone ERROR 要克隆的域必须已经关闭。 [rootcent…克隆主要是对磁盘文件进行操作。
1完整克隆
a、拷贝虚拟机磁盘文件 b、生成虚拟机配置文件 centos7-2 291b0480-955a-45e2-a001-690fded69d1b c、导入xml并启动
[rootcentos8 ~]# virt-clone -o centos7 --auto-clone ERROR 要克隆的域必须已经关闭。 [rootcentos8 ~]# virsh destroy centos7 Domain ‘centos7’ destroyed
[rootcentos8 ~]# virt-clone -o centos7 --auto-clone ‘centos2-clone.qcow2’ 15% [ ] 102 MB/s | 1.5 GB 00:01:25 正在分配 ‘centos2-clone.qcow2’ | 10 GB 00:00:13
成功克隆 ‘centos7-clone’。 [rootcentos8 ~]# ll /opt 总用量 9477500 -rw------- 1 root root 1633353728 2月 27 14:03 centos2-clone.qcow2 #比centos2少个快照所以文件大小要比centos2小 -rw-r–r-- 1 root root 1887109120 2月 27 14:03 centos2.qcow2 [rootcentos8 ~]# virsh list --all
Id 名称 状态
centos7 关闭centos7-clone 关闭 修改虚拟机名称
[rootcentos8 ~]# virsh domrename centos7-clone centos7-2 Domain successfully renamed
[rootcentos8 ~]# virsh list --all
Id 名称 状态
centos7 关闭centos7-2 关闭 将克隆的虚拟机跟原先的虚拟机xml文件导出来查看其两者的区别在哪里 [rootcentos8 opt]# virsh dumpxml centos7 centos7.xml [rootcentos8 opt]# virsh dumpxml centos7-3 centos7-3.xml [rootcentos8 opt]# vimdiff centos7.xml centos7-3.xml 1、虚拟机name 2、uuid不同 3、source file的磁盘文件不同 4、虚拟机的mac地址不同 手动完整克隆虚拟机 1、拷贝虚拟机的磁盘文件 cp centos7.qcow2 centos7-clone.qcow2 2、拷贝虚拟机xml配置文件 cp centos7.xml centos7-clone.xml 3、修改name、磁盘文件路径 4、将uuid删掉下次启动虚拟机时会自动生成新的uuid 5、将mac删掉下次启动虚拟机时会自动生成新的 6、导入虚拟机virsh define centos7-clone.xml 7、启动虚拟机virsh start centos7-clone
2链接克隆
a、基于源磁盘文件、生成链接磁盘文件 [rootcentos8 opt]# qemu-img create -f qcow2 -F qcow2 -b centos2-clone.qcow2 centos3.qcow2
Formatting ‘centos3.qcow2’, fmtqcow2 cluster_size65536 extended_l2off compression_typezlib size10737418240 backing_filecentos2-clone.qcow2 backing_fmtqcow2 lazy_refcountsoff refcount_bits16
[rootcentos8 opt]# qemu-img info centos3.qcow2 image: centos3.qcow2 file format: qcow2 virtual size: 10 GiB (10737418240 bytes) disk size: 196 KiB cluster_size: 65536 backing file: centos2-clone.qcow2 backing file format: qcow2 Format specific information: compat: 1.1 compression type: zlib lazy refcounts: false refcount bits: 16 corrupt: false extended l2: false
b、生成虚拟机配置文件 c、导入xml并启动 以上两步合并一条命令
[rootcentos8 opt]# virt-install --virt-type kvm --os-typelinux --os-variant rhel7.4 --name centos7-3 --memory 1024 --vcpus 1 --disk /opt/centos3.qcow2 --boot hd --network networkdefault --graphics vnc,listen0.0.0.0 --noautoconsole