Bug 638188 - RFE: Provide a way to lazily clone an LV
Summary: RFE: Provide a way to lazily clone an LV
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: LVM and device-mapper
Classification: Community
Component: lvm2
Version: 2.02.166
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
: ---
Assignee: LVM and device-mapper development team
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-09-28 13:16 UTC by Richard W.M. Jones
Modified: 2018-07-21 20:09 UTC (History)
13 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2018-07-21 20:09:26 UTC
Embargoed:
rule-engine: lvm-technical-solution?
rule-engine: lvm-test-coverage?


Attachments (Terms of Use)

Description Richard W.M. Jones 2010-09-28 13:16:33 UTC
Description of problem:

I usually use the following commands to clone a virtual machine:

  # lvcreate -L 16G -n NewGuest VG
  # dd if=/dev/VG/OldGuest of=/dev/VG/NewGuest bs=1M

The problem is that the 'dd' takes a long time to complete, and
the new VM is of course not usable until it does.  Creating a snapshot
is a possibility for some situations, but for many what I really
want is a true copy (in particular, the new guest may be heavily
written to and get a large delta from the original).

It strikes me that it should be possible to implement a lazy
copy at the dm level, one where the copy is immediately available
(reads from the copy refer to the original, writes to either the
original or the copy cause the block to be copied, and the rest
of the blocks are copied in the background).

I talked to agk about this and he suggested:
<@agk> it's a feature that visegrips is working on
<@agk> based on - create a mirror, then split it
<@agk> - or you want the copy to be usable immediately -
  in which case we need to add a temp snapshot layer to that
<@agk> we've got all the components needed to do that
<@agk> they just need joining together in the right way into
  a device stack & lvm command

The proximate need for this is to reimplement the 'virt-clone'
command and make it fast.

Version-Release number of selected component (if applicable):

$ rpm -q lvm2
lvm2-2.02.73-2.fc13.x86_64

Comment 1 Alasdair Kergon 2010-10-28 21:39:07 UTC
I forgot - Jon already did this!

To clone vg1/lvol0 to vg1/lvol2 try:

lvconvert -m1 /dev/vg1/lvol0 
lvconvert --splitmirrors 1 -n lvol2 /dev/vg1/lvol0

Comment 2 Alasdair Kergon 2010-10-28 21:42:20 UTC
Then if you don't want to wait, we need to add a snapshot to the --splitmirrors mechanism, that disappears when it's complete.

Comment 3 Richard W.M. Jones 2010-10-28 22:16:17 UTC
That's great.  Is this available in a form that we can
use now (with the mechanism hidden inside a "virt-clone"-
type tool)?

Comment 8 Alasdair Kergon 2011-12-07 02:38:21 UTC
Is it worth combining the sequence into another script/command?  Else I guess we can close this.

Comment 9 Richard W.M. Jones 2011-12-07 10:36:04 UTC
(In reply to comment #8)
> Is it worth combining the sequence into another script/command?

Yes!  lvclone ...?

Comment 10 Mike Snitzer 2018-07-21 20:09:26 UTC
This bug should probably get closed.. very niche usecase that is unnecessary to do as suggested (with a "lazy clone").

I'd suggest using thinp:
1) either from the start, and then you'll be able to do highly scalable snapshots of snapshots, etc.
2) use an external origin with thinp -- this is useful if you have old logical volumes that you'd like to be able to snapshot (also capable of snapshots of snapshots).

Closing (we now have this, its called: LVM thin provisioning, we didn't quite have it back in 2011 when this BZ was opened)


Note You need to log in before you can comment on or make changes to this bug.