Need help on moving disk image from one KVM machine to another

kawarmc

New Member
Jun 15, 2009
28
3
3
Hi guys:

I need to assign the Disk of a virtual machine to another one and I don't know how to do it. I know how to do it when the disks are on qcow2 or raw images on disk, but actually all my VMs have their disks stored on a SAN thru iscsi and then on a LVM group, so I cannot just rename or move the devices... at least I don't really know how to do it.

Any ideas on how to perform this task?

Thank you in advance.
 
Hi guys:

I need to assign the Disk of a virtual machine to another one and I don't know how to do it. I know how to do it when the disks are on qcow2 or raw images on disk, but actually all my VMs have their disks stored on a SAN thru iscsi and then on a LVM group, so I cannot just rename or move the devices... at least I don't really know how to do it.

Any ideas on how to perform this task?

Thank you in advance.

Hi kawarmc,
if i understood you right, you should only delete the disk in the first kvm-guest and then edit the conf-file of the second kvm-guest and add the disk:

Code:
vi /etc/qemu-server/104.conf
# add a line like this for a second disk
ide1: vg_fibrechannel:vm-110-disk-2

But you must remember this. Perhaps you should rename the lv.

If you need similtanous access from both nodes, you need a clusterfilesystem.

Udo
 
Sorry for not answering sooner...

I don't need simultaneous access from both machines, I just need to assign the disk to another machine. What I don't know is to rename the lv and if that could affect pve in any way.

Thank you.
 
Hi,
i have make just a test - but be sure, to have a valid backup!!

To change the first disk of vm 124 to the second disk of 123:
delete the disk in vm 124 (it's shows as unused image).

As root in the shell on your proxmox-server:
Code:
lvdisplay
...
  --- Logical volume ---
  LV Name                /dev/i1svg/vm-124-disk-1
  VG Name                i1svg
  LV UUID                6dOG8G-v7xq-Rtgy-1v5C-XqpT-E80Z-xY2B6f
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                10.00 GB
  Current LE             1280
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:6

# lvrename /dev/i1svg/vm-124-disk-1 /dev/i1svg/vm-123-disk-2
  Renamed "vm-124-disk-1" to "vm-123-disk-2" in volume group "i1svg"

add in /etc/qemu-server/123.conf (depends on your storagename)

Code:
ide1: iscsi1-sata-vol1-vg:vm-123-disk-2

but you see in vm124 the disk (iscsi1-sata-vol1-vg:vm-123-disk-2) as not used image.
I think not, that pve will affected... but perhaps can Tom or Dietmar say more.

Udo
 
Thanks Udo:

I tried that before posting but the disk image still shows in the original VM as unused disk. Because of that I thought I was not using the lvrename correctly...

I don't know if pve keeps track of the disk images of the VMs somewhere apart from qemu-server/xxx.conf or if I need to restart iSCSI or LVM in order to re-attach the device...
 
Then I don't know why it keeps the disk as an unused disk on the ole machine.

I'll keep tring things to try to find out
 
I didn't try to restart apache2, but I restarted pvedaemon with same results

I'm going to try to restart apache and see what happens
 
OK, it's solved.

It was my mistake, I didn't remove the tags because of a misspelling of the command line options of lvchange. I thought I did but I made a mistake on the command line.

Now it works.

But let me write the whole process here just in case someone needs it and as a reminder for myself :)

----

1.- Find out what disk image you want to migrate and wich tags it has with the command:
Code:
lvs -o +lv_tags
This will give you something like:
Code:
:~# 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:
Code:
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:
Code:
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:
Code:
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.

Thank you all for your help.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!