LVM2 migration

meto

Member
Apr 6, 2010
96
0
6
I always use LVM for my VMs becouse of outstanding performance, but always I had trouble with migrating those VMs. I thought that with KVM (I used XenServer) that would be different, but it isn't unfortunately... And why is that? I did some digging and found really easy and convenient way of moving LVM disks between hosts (not only KVM but any). All you need to do is to is pipe dd to other server via ssh. Short how to do an offline migration in Proxmox VE of VMs using LVM as storage. I assume that you have servers in cluster.

  1. Mark your LVM storage as shared.
  2. Log on SSH of the source host and identify disk which you want to move (via WebUI or lvdisplay).
  3. Add LV on target server:
    Code:
    ssh root@target "lvcreate --addtag pve-vm-101 -L25G -n vm-101-disk-1 pve"
    Remember to add the tag, since it's necessary for Proxmox to add more LVM disks and discover their number.
  4. Copy LV over SSH:
    • on 1Gbps network*:
      Code:
      dd if=/dev/pve/vm-101-disk-1 | ssh -2 -o "Compression no" root@target "dd of=/dev/pve/vm-101-disk-1 bs=100M"
    • on 100Mbps network:
      Code:
      dd if=/dev/pve/vm-101-disk-1 | ssh -2 -o "Compressionlevel 1" root@target "dd of=/dev/pve/vm-101-disk-1 bs=100M"
      *My tests have shown that on gigabit networks the speed of compressing data is overperformed by network speeds.
  5. Use WebUI to migrate that VM, everything should be OK.

Am I missiong something? I tried also using nc, but you lose encryption which is bad for transferring raw drive content.

Why Proxmox can’t use that schema to do an offline migration of LVM disks instead of using qm? I think it would be very nice feature, and you can presume that post to be feature request.

--edit1
I've just found out that you were using similar config for Windows VMs (http://pve.proxmox.com/wiki/Migrati...ical_machine_to_a_VM_logical_volume_using_SSH). Mi solution has one (in my mind very important) advantage - it doesn's save any image, which wold require double disk space which is not possible in most real case scenarios.

Has anyone tried to use migrate directly from qm? [http://www.linux-kvm.org/page/Migration#Example_.2F_HOWTO] Does it support LVM?
 
Last edited:
This implementation should be very simple. Basically you should just execute something like:

vzdump --stdout $VMID | ssh root@$OTHER_NODE "qmrestore --storage $OTHER_STORAGE_NAME - $VMID"
 
Merci it woked nicely !!!
Thanks again for your help for the LVM migration !!!!!
 
This implementation should be very simple. Basically you should just execute something like:

vzdump --stdout $VMID | ssh root@$OTHER_NODE "qmrestore --storage $OTHER_STORAGE_NAME - $VMID"

kubucek,

do you know how to do this using netcat instead of SSH?
 

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!