Account Links: Cart | Your Account | Logout

Skip to content

Red Hat Knowledgebase

Red Hat Knowledgebase Search:

Updated Within the Last:

New Solutions within the last day New Solutions within the last week New Solutions within the last month

Browse by topics:


Click to View a Topic
Red Hat Enterprise Linux > Red Hat Enterprise Linux 5 Beta > Issue <<  3 of 23 >>

Solution Tools:


Email a Solution Postcard Printer version Submit a comment on this answer Update notifications Request an answer Back

Article Reference

Article ID: 9742
Last update: 11-16-07
Issue:
How can I make a clone of a virtual guest operating system in Red Hat Enterprise Linux 5?
Resolution:

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:

  • The name of the guest (from "guest01" to "guest02"
  • The MAC address of the guest on the "vif =" line
  • The UUID of the guest

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.


How well did this entry answer your question?


good wrong incomplete out of date
Red Hat Enterprise Linux > Red Hat Enterprise Linux 5 Beta > Issue <<   3  of  23  >>