cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Etc


Reference














.

middleware:virtualization:kvm:guest_replication.html



KVM : How to replicate Guest OS (create new mac address)

Method1

# virsh list --all
# virt-clone -o server1 -n server2 -f /var/lib/libvirt/images/server2.img
# diff /etc/libvirt/qemu/dev-cent01.xml /etc/libvirt/qemu/dev-cent02.xml


Method2

Step1 : Copy Image

# cd /var/lib/libvirt/images/
# cp server1.img server2.img


Step2 : Copy XML File

# cd /etc/libvirt/qemu/
# cp server1.xml server2.xml
# vi server2.xml

(abbr)
    <name>server2</name>
    <uuid>xx.xxx-xx-xx</uuid>

        <source file='/var/lib/libvirt/images/server2.img/'>

        <mac address='xx'/>
(abbr)

How to create new uid.

[root@centos7 ~]# uuidgen
c1222343-561f-4a06-80a2-b2dbde45be12
[root@centos7 ~]#

How to create new mac address.

[root@centos7 ~]# vi macgen.py
-----------------------------------------------
#!/usr/bin/python
# macgen.py script to generate a MAC address for Red Hat Virtualization guests
#
import random
#
def randomMAC():
	mac = [ 0x00, 0x16, 0x3e,
		random.randint(0x00, 0x7f),
		random.randint(0x00, 0xff),
		random.randint(0x00, 0xff) ]
	return ':'.join(map(lambda x: "%02x" % x, mac))
#
print randomMAC()

-----------------------------------------------
[root@centos7 ~]# chmod 755 macgen.py
[root@centos7 ~]# ./macgen.py
26:a7:3a:99:c9:9e
[root@centos7 ~]#


Step3 : registration new virtual machine




middleware/virtualization/kvm/guest_replication.html.txt ยท Last modified: 2019/06/22 by admin

Page Tools