lvsync

Logical Volume Sync Tool


Keywords
lvm, sync, dd
License
Other
Install
pip install lvsync==201407.4

Documentation

lvsync

Logical Volume Sync Tool

Example

Task:
We need to migrate logical volume (e.g. used by virtual machine) from host1 to host2 with minimal downtime.
Logical volume path (host1): /dev/vg/disk1 (e.g. size: 10G)

Solution:

  • Create lvm-snapshot on running virtual machine:
    lvcreate -s disk1-snap -L 1G vg/disk1

  • Create new logical volume on remote host2 with the same or bigger size:
    lvcreate -s disk1-mgr -L 10G vg

  • Send the new snapshot to remote host2 using dd or just run:
    lvsync /dev/vg/disk1-snap root@host2:/dev/vg/disk1-mgr

     At first you need to send created snapshot to remote server.
     Type 'no' if you have already sent volume manually.
     Command: dd if=/dev/vg/disk1-snap bs=1M | pv -ptrb | ssh root@host2 dd of=/dev/vg/disk1-mgr bs=1M
     Run sync? [yes/no]: yes
     
  • Then you have to shut down virtual machine and run script again to sync only chunks with changed data: lvsync /dev/vg/disk1-snap root@host2:/dev/vg/disk1-mgr

     At first you need to send created snapshot to remote server.
     Type 'no' if you have already sent volume manually.
     Command: dd if=/dev/vg/disk1-snap bs=1M | pv -ptrb | ssh root@host2 dd of=/dev/vg/disk1-mgr bs=1M
     Run sync? [yes/no]: no
     
     Found 2672 changed chunks.
     Send chunks to remote volume? [yes/no]: yes
     

Links

Based on https://github.com/mpalmer/lvmsync