United States (change)
Shortcuts: Downloads Fedora Red Hat Network
Account Links: Cart Your Account Logout
The virtualization platform in Red Hat Enterprise Linux 5 does not include a built-in feature for making a clone of a guest operating system. However, it is simple to achieve this by using traditional disk copying methods. The two best choices are to use dd" to make a copy of the guest's disk file, or to use the snapshot feature of LVM if the guest is on its own logical volume.
This article will focus on the LVM snapshot method. Before installing the first guest, a logical volume of 5000 MB was created:
lvcreate -L 5000 -n guest01 VG0
Where "VG0" is the name of the volume group and "guest01" is the name of the logical volume. During the guest creation process, /dev/VG0/guest01 was entered as the partition to use for the guest's storage space. The name "guest01" was also used as the system name of the guest.
After the guest installation is complete, the guest operating system is installed on /dev/VG0/guest01 and the configuration file that stores the guest's information for the hypervisor is housed in /etc/xen/guest01. Cloning this guest involves two steps: copying the guest's disk and creating a new configuration file.
To clone the disk, make a snapshot of the logical volume using the following command:
lvcreate -L 5000 -s -n guest02 /dev/VG0/guest01
There should now be a second logical volume in VG0 that contains the exact same data as the first:
[root@localhost ~]# lvscan ACTIVE Original '/dev/VG0/guest01' [4.91 GB] inherit ACTIVE Snapshot '/dev/VG0/guest02' [4.91 GB] inherit
In order to make the hypervisor aware of this new guest, a new configuration file must be created. To do this, make a copy of the original configuration file:
# cp /etc/xen/guest01 /etc/xen/guest02
Then, edit the new file, /etc/xen/guest02. In order for the guest to function the following lines must be changed:
Other parameters can also be changed as desired (the amount of memory for example). The MAC and the UUID are both random numbers. It is sufficient to simply change a few digits of each. Or, a utility that creates random MAC and UUID numbers can be used.
The new guest can now be started with the command:
#xm create guest02
The guest should immediately appear in the virt-manager GUI window and can now be used as any other guest.