Linux – LVM2: How to copy snapshots

clonecopylinuxlvmsnapshot

I read What does an LVM2 Snapshot contain? and LVM Snapshot confusion.

What I'm trying to figure out is if there is a way to create a copy of an LVM snapshot for use with different Xen VMs. I know that it isn't built into LVM (yet), but I was wondering if it might (or might not) work like this:

  1. Create Logical Volume LV1
  2. Create Snapshot1 of LV1 (100MB)
  3. Create Snapshot2 of LV1 (100MB)
  4. dd if=Snapshot1 of=Snapshot2
  5. Use Snapshot1 and Snapshot2 both for R/W operations with Xen, use LV1 read-only.

Would it work or would it fail horribly in hard-to-detect ways? Any other suggestions to approach this? I guess that I could also create a second Logical Volume LV2 and copy the content of Snapshot2, but that would take up more space for PEs.

Solution:

In the meantime I found a way to do it using LVM2 thin volumes: https://wiki.gentoo.org/wiki/LVM#LVM2_Thin_Snapshots

Best Answer

The idea may be reasonable but dd is the killer for all efforts. You will not get neither speed nor space-saving.

With differential coping at least space-saving may available. Can try lvmsync to do It.

Another option is ZFS (zfsonlinux) where you can do clones from snapshots. But I am not sure about ZVOL perfomance on Linux.