This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 638188 - RFE: Provide a way to lazily clone an LV
RFE: Provide a way to lazily clone an LV
Status: NEW
Product: LVM and device-mapper
Classification: Community
Component: lvm2 (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: LVM and device-mapper development team
Depends On:
  Show dependency treegraph
Reported: 2010-09-28 09:16 EDT by Richard W.M. Jones
Modified: 2016-10-11 19:06 EDT (History)
13 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
rule-engine: lvm‑technical‑solution?
rule-engine: lvm‑test‑coverage?

Attachments (Terms of Use)

  None (edit)
Description Richard W.M. Jones 2010-09-28 09:16:33 EDT
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
Comment 1 Alasdair Kergon 2010-10-28 17:39:07 EDT
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 17:42:20 EDT
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 18:16:17 EDT
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-06 21:38:21 EST
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 05:36:04 EST
(In reply to comment #8)
> Is it worth combining the sequence into another script/command?

Yes!  lvclone ...?

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