LoginSignup
0
0

More than 5 years have passed since last update.

CentOS7でKVM(仮想環境)を構築⑤ 仮想マシンのクローン作成

Posted at

KVMも簡単に仮想マシンのクローンが作成できます。


クローンする仮想マシンをシャットダウンします。

# virsh shutdown vm1
Domain vm1 is being shutdown

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     vm1                            shut off


--auto-cloneを指定すると、デフォルトパス/var/lib/libvirt/images/-cloneという名前で保存されます。

# virt-clone --original vm1 --name vm2 --auto-clone
Allocating 'vm1-2-clone.qcow2'                                                             |  30 GB  00:00:00

Clone 'vm2' created successfully.

# ll
total 2781472
-rw-------. 1 root root  1414660096 May 12 20:40 vm1-2-clone.qcow2
-rw-------. 1 root root 32217432064 May 12 20:34 vm1-2.qcow2

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     vm1                            shut off
 -     vm2                            shut off


サイズを確認すると、Thinで作成されるようです。Thickのオプションらしき--nonsparseをしても結果は変わりませんでした。謎。


Macアドレスはデフォルトでランダム書き換えするもよう。

Fixed MAC address for the guest; If this parameter is omitted, or the value "RANDOM" is specified a suitable address will be randomly generated. Addresses are applied sequentially to the networks as they are listed in the original guest XML.

# virsh dumpxml vm1 | grep -i "mac address"
      <mac address='52:54:00:3c:53:c1'/>
# virsh dumpxml vm2 | grep -i "mac address"
      <mac address='52:54:00:e9:d3:c0'/>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0