Unlike Vmware, we have the advantage of being able to use Logical Volumes in Linux, rather than image files. An LVM image provides better performance that a flat file because we are "closer to the bare metal" of the drive, rather than inside a file system. We can resize an LMV image using native Linux commands, rather than using a third party tool. Unfortunately, this mean cloning requires one extra step: we have to preallocate the LogVol. That should take about 10 seconds.
[root@adama ~]# lvcreate -L 5G img -n vm06f8In this example, we created the image LogVol, /dev/img/vm6f8, and replicated Dom vcl02 as vcl03. Since we were using a preallocated volume, we needed the --force. (No, it is not smart enough to make the the LogVol. Yes, I tried.)
Logical volume "vm06f8" created
[root@adama ~]# virt-clone -o vcl02 -n vcl03 \
-f /dev/img/vm06f8 --force
Cloning from /dev/img/vm05f8 to /dev/img/vm06f8
Cloning domain... | 5.0 GB 02:55
Our big problem now is that both VMs have the same hostname and IP address. Since vcl02 is down, we can bring vcl03 up, and make the changes with out an conflicts. If... You had used LVM inside vcl02, and you used a different VG name than on Dom0, then you could use kpartx to mount the root filesystem, and change the config files directly.
do both lvm need to have the same size?
ReplyDeleteI never tried, but I'm sure the clone could be bigger. Any unused space would appear to fdisk as unpartitioned. Making the clone smaller would be hit or miss, but could cause problems for the clones volume groups.
ReplyDeleteAt this point, I'm working more with Citrix Xenserver.
If you have differents sizes they "destroy" destination image and create a new one with same size of source
ReplyDeleteI clone the KVM VM using the following but it didn't give me the network interface on the destination
ReplyDeletevirt-clone --original sl6-2 \
--name sl6-3 \
--file /dev/mapper/vg_kvm-kvm5 --prompt
eth0 interface does not exists in sl6-3 I do not know how to fix the issue.
question... what if I have two lvm's for every Xen machine, for ex, storage & swap. How do I clone using two different storage devices?
ReplyDelete