[linux-lvm] Examining a snapshot

Roger Lucas roger at planbit.co.uk
Wed Sep 27 14:07:29 UTC 2006

Hi Nick,

Mark McLoughlin has done a lot of work on a neat "lvmerge" utility, but lvmerge isn't merged with the main LVM utilities yet....
When it does arrive, this will definitely be the "way to go".

In the meantime, however...

Prashanth Radhakrishnan did a load of work on this some time ago and very kindly sent me a copy of his code when I asked him.  It
had one issue which I resolved to do with the COW block device not being opened in O_DIRECT mode.

The resulting "show-cow.c" will dump a list of all the 8K blocks that have been stored in the snapshot.  You can easily modify this
to provide the data in whatever format you want.
I have also combined this with a block copy function to allow a LV snapshot to be merged back into its parent.  It is NOT as clean
or efficient as Mark McLoughlin's version, but it is simple and easy to understand.  The comments in each of the programs will
explain how it is working.

All supplied without warranty, blah blah, but feel free to drop me an e-mail (on- or off-list) if you have any questions or problems
with them.

To compile them:

	gcc -O2 -Wall show-cow.c -o show-cow
	gcc -O2 -Wall lvmerge-snap2lv.c -o lvmerge-snap2lv

Best regards,


> -----Original Message-----
> From: linux-lvm-bounces at redhat.com [mailto:linux-lvm-bounces at redhat.com] On Behalf Of Nick Wright
> Sent: 27 September 2006 03:57
> To: linux-lvm at redhat.com
> Subject: [linux-lvm] Examining a snapshot
> Hi all,
> I have a backup strategy in place where I use snapshots to determine
> the difference between yesterday and today. I then copy those blocks
> that have changed to a target machine and apply the difference to a
> remote copy of the entire block device.
> Currently this involves doing a complete comparison between a logical
> volume and its snapshot to find the blocks that have changed. I know
> that internally, LVM already has the information about which blocks
> have been altered -- these are what are stored in the snapshot after
> all.
> Is it possible for me to get that information somehow? Some pointers
> getting me started on this would be of great help to me -- especially
> if theres a simple way to do so already in place before I go delving
> into source code etc...
> Thanks
> Nick
> _______________________________________________
> linux-lvm mailing list
> linux-lvm at redhat.com
> https://www.redhat.com/mailman/listinfo/linux-lvm
> read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: show-cow.c
URL: <http://listman.redhat.com/archives/linux-lvm/attachments/20060927/55c217f7/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: lvmerge_snap2lv.c
URL: <http://listman.redhat.com/archives/linux-lvm/attachments/20060927/55c217f7/attachment-0001.c>

More information about the linux-lvm mailing list