[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [linux-lvm] Snapshot code

As you might know, LVM2 actually uses a kernel component called devicemapper (DM).

DM has various targets that are used to create LVM devices.  For example, a simple LV might generate a table in DM like this:

0 100000 linear 8:1 540

This table maps reads on the LVM device from blocks 0 to 100000 (512 bytes each) to blocks on device 8:1 (sda1) starting at block 540.  As you might imagine, this system is very flexible and allows LVM2 to run entirely in userspace, with DM doing all of the heavy lifting in the kernel.

The secret sauce required to do snapshots requires help from LVM.  Notice that in the above table, the single entry has a target called "linear".  This is a simple mapping, nothing more.  Snapshots require the ability to intercept writes to the original LVM device in order to preserve the original data in the snapshot.  Thus, a snapshot creates the original LV's mapping, then creates an entry that uses the LV but has a "snapshot-origin" target (instead of merely a linear target) for the entire other volume.  For the cow volume it uses a "snapshot" target.  With these tools it creates the devices you actually use, including the extra volume (which is used to get that snapshot target in the loop).

For a discussion of the underlying technology, look here:


On Mar 5, 2007, at 4:52 AM, Nallammai S wrote:


I am new to lvm2. I am looking at the lvm2 code primarily to understand how snapshots are taken. When I debugged, i found that in addition to the COW LV, a LV named 'snapshot0' is also created. Why is this LV created?

Thanks in advance


linux-lvm mailing list
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

Jayson Vantuyl
Systems Architect

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]