Moving disk image from one KVM machine to another

From Proxmox VE
Revision as of 20:14, 24 October 2010 by Capripot (talk | contribs)
Jump to navigation Jump to search

1.- Find out what disk image you want to migrate and wich tags it has with the command:

lvs -o +lv_tags

This will give you something like:

:~# lvs -o +lv_tags
  LV            VG             Attr   LSize   Origin Snap%  Move Log Copy%  Convert LV Tags   
  data          pve            -wi-ao  38.12G                                                 
  root          pve            -wi-ao  16.75G                                                 
  swap          pve            -wi-ao   8.38G                                                 
  vm-101-disk-1 pve-compartido -wi-a-  80.00G                                       pve-vm-101
  vm-102-disk-1 pve-compartido -wi-ao  35.00G                                       pve-vm-102
  vm-104-disk-2 pve-compartido -wi-a-  50.00G                                       pve-vm-104
  vm-105-disk-1 pve-compartido -wi-ao  50.00G                                       pve-vm-105
  vm-106-disk-1 pve-compartido -wi-ao  22.00G                                       pve-vm-106
  vm-108-disk-1 pve-compartido -wi-ao  32.00G                                       pve-vm-108
  vm-108-disk-2 pve-compartido -wi-ao 150.00G                                       pve-vm-108
  vm-113-disk-1 pve-compartido -wi-ao   2.00G                                       pve-vm-113
  vm-113-disk-2 pve-compartido -wi-ao   2.00G                                       pve-vm-113
  vm-108-disk-3 pve-pulpo      -wi-a- 300.00G                                       pve-vm-108
  vm-108-disk-4 pve-pulpo      -wi-a-  50.00G                                       pve-vm-108

2.- Once you know exactly wich disks want to migrate and the volume group they are allocated to and their tags, we delete de tags from the disks and then add the tags for the new VM with a command like:

lvchange --deltag @pve-vm-108 pve-pulpo/vm-108-disk-3 pve-pulpo/vm-108-disk-4

In this example, I am moving vm-108-disk3 and vm-108-disk-4 from VM 108 to VM 101.

3.- Next, we add the tag for VM 101 to both disks:

lvchange --addtag @pve-vm-101 pve-pulpo/vm-108-disk-3 pve-pulpo/vm-108-disk-4

4.- as a convenience, it's better to rename the disk images to reflect the machine they belong to:

lvrename pve-pulpo/vm-108-disk-3 pve-pulpo/vm-101-disk-1
lvrename pve-pulpo/vm-108-disk-4 pve-pulpo/vm-101-disk-2

5.- Now, using Proxmox Web Admin, we can delete the disks from the "old VM" and on the new one, we'll have the disks as "unused", so we can add them.

Credits : From kawarmc in Proxmox Forums