7.1 前提:
[root@room8pc205 ~]# virsh undefine centos7.0 //取消定義模闆虛拟機node,讓模闆固定
域 centos7.0 已經被取消定義
[root@room8pc205 ~]# cd /var/lib/libvirt/images/
[root@room8pc205 images]# ls #在這裡面是可以找到node.qcow2這個檔案的
7.2 建立虛拟機
7.2.1 利用後端模闆建立前端盤
[root@room8pc205 images]# qemu-img create -f qcow2 -b node.qcow2 node1.img 30g
Formatting 'node1.img', fmt=qcow2 size=32212254720 backing_file='node.qcow2' encryption=off cluster_size=65536 lazy_refcounts=off
[root@room8pc205 images]# ls -lh node1.img
-rw-r--r-- 1 root root 193K 7月 19 14:38 node1.img
7.3 編寫xml配置檔案
[root@room8pc205 ~]# sed 's,demo,node1,' demo.xml >/etc/libvirt/qemu/node1.xml
生成完成後虛拟機建立完畢
7.4 定義虛拟機
[root@room8pc205 ~]# virsh define /etc/libvirt/qemu/node1.xml
定義域 mode1(從 /etc/libvirt/qemu/node1)
7.5 利用vish檢視虛拟機
[root@room8pc205 ~]# virsh list --all
Id 名稱 狀态
----------------------------------------------------
- node1 關閉