[linux-lvm] how to convert a disk containing a snapshot to a snapshot lv?
Zdenek Kabelac
zdenek.kabelac at gmail.com
Wed Dec 22 10:40:27 UTC 2021
Dne 21. 12. 21 v 17:12 Tomas Dalebjörk napsal(a):
> Thanks for explaining all that details about how a snapshot is formatted on
> the COW device.
> I already know that part.
>
Well your messaging is then somewhat confusing.
> I am more interested in how the disk containing the COW data can be merged
> back to an LV volume.
> The second part only mentioned that it is possible, but not which steps are
> involved.
>
> As documented in the manual.
> To split a snapshot from its origin (our words detach) one can use:
> lvconvert --splitsnapshot vg/s1
> Right?
>
> To reverse that process, according to the manual; one can use:
> lvconvert -s vg/s1
> Right?
>
> But as I mentioned before, this requires that the vg/s1 exists as an object in
> the LVM metadata.
> What if you are on a new server, that does not have vg/s1?
> How to create that object or whatever you like to call this on the server?
> The only way I got it is to use the
> vgextend
> lvcreate
> lvconvert --splitsnapshot
>
> And now reattach it, so that the actual merge can happen.
> The object should exist now, so that the command: lvconvert -s vg/s1 can work
>
There is no problem with reattaching existing COW to any other LV -
it's plain 'lvconvert -s -Zn -c xxx vg/origin vg/snapcow'
this will rejoin former origin with former COW volume and avoids 'zeroing'
metadata stored on COW.
But to have this usable - there must have been NO write access to the origin
between the moment your snapshot was 'split' and 'reattached'
and it's documented in 'man lvconvert'
> Or how can the object vg/s1 be created so that it can be referenced to by the
> lvconvert command?
> The disk is formated as a COW device, and contains all of the data.
> So how hard can it be to just reattach that volume to an empty or existing LV
> volume on the server?
There is no problem with this - however your provided case just shown you
have very small amount of data stored in snapshot.
So while snapshot has large size - it's been mostly unoccupied with data - so
any merge into 'clean' origin is kind of meaningless in this particular case.
> If it works on same server, why can't it work on any other new servers, as the
> COW device contains ALL the data needed (we make sure it contains all the data)
>
> If you want to give it a try, just create a snapshot on a specific device
> And change all the blocks on the origin, there you are, you now have a cow
> device containing all data needed.
> How to move this snapshot device to another server, reattach it to an empty lv
> volume as a snapshot.
I'm aware how this works - being lvm2 developer...
I'm just trying to explain there is better and simpler way how to reach your
goal.
Simply take a 'time consistent' snapshot of your origin.
(So it does not change while you take a 'dd' copy)
Take a 'DD' copy of such stable snapshot to a new LV.
And restore this 'copied' LV on your 2nd. server.
I simply don't follow why would you want to complicate all of this with
snapshot merging - makes no sense and just cause a massive slowdown....
Regards
Zdenek
More information about the linux-lvm
mailing list