how to clone a VM on LVM to another in KVM?

8,977

You can use LVM volumes as targets for the copy without a problem

virt-clone -o source_system --name new_system --file /dev/vg_kvm/lv_disk2

should do the trick. It handles the source block device (instead of a file) as well.

Share:
8,977

Related videos on Youtube

shgnInc
Author by

shgnInc

Updated on September 18, 2022

Comments

  • shgnInc
    shgnInc almost 2 years

    On a Debian wheezy i installed KVM for virtualization and install some VMs on it. I use separate LVM disks because of its performance for my VMs disk.

    Now i need to clone one of them in new LVM disk. I searched too much for it and i found virt-clone, but unfortunately The virt-clone just clone Vms with disk in files and cannot clone LVM disks. I think it is possible by dd like so:

    dd if=/dev/vg_kvm/lv_disk1 of=/dev/vg_kvm/lv_disk2
    

    Is there any more optimize solution? How can i clone my VM which is installed on a LVM disk to a new LVM disk?

    • shgnInc
      shgnInc about 10 years
      What was wrong with my question for down vote it?
  • shgnInc
    shgnInc about 10 years
    If i do so, Is there any problem for network-UUID and VM-UUID? If so, how to solve it?
  • FooBee
    FooBee about 10 years
    No, there is not. Please read the virt-clone man page. Cite: Elements which require uniqueness will be updated to avoid a clash between old and new guests. What has this to do with whether you use a file or a LVM volume as a target anyway? Either virt-clone handles this correctly or it doesn't, but it wouldn't make a difference depending on the target device. Remember: A block device is a file, that's one of the core principles of Unix: Devices are files.