Installation guide

Appendix A. The Device Mapper
84
1. A device with a linear mapping containing the original mapping table of the source volume.
2. A device with a linear mapping used as the copy-on-write (COW) device for the source volume;
for each write, the original data is saved in the COW device of each snapshot to keep its visible
content unchanged (until the COW device fills up).
3. A device with a snapshot mapping combining #1 and #2, which is the visible snapshot volume.
4. The "original" volume (which uses the device number used by the original source volume), whose
table is replaced by a "snapshot-origin" mapping from device #1.
A fixed naming scheme is used to create these devices, For example, you might use the following
commands to create an LVM volume named base and a snapshot volume named snap based on that
volume.
# lvcreate -L 1G -n base volumeGroup
# lvcreate -L 100M --snapshot -n snap volumeGroup/base
This yields four devices, which you can view with the following commands:
# dmsetup table|grep volumeGroup
volumeGroup-base-real: 0 2097152 linear 8:19 384
volumeGroup-snap-cow: 0 204800 linear 8:19 2097536
volumeGroup-snap: 0 2097152 snapshot 254:11 254:12 P 16
volumeGroup-base: 0 2097152 snapshot-origin 254:11
# ls -lL /dev/mapper/volumeGroup-*
brw------- 1 root root 254, 11 29 ago 18:15 /dev/mapper/volumeGroup-base-real
brw------- 1 root root 254, 12 29 ago 18:15 /dev/mapper/volumeGroup-snap-cow
brw------- 1 root root 254, 13 29 ago 18:15 /dev/mapper/volumeGroup-snap
brw------- 1 root root 254, 10 29 ago 18:14 /dev/mapper/volumeGroup-base
The format for the snapshot-origin target is as follows:
start length snapshot-origin origin
start
starting block in virtual device
length
length of this segment
origin
base volume of snapshot
The snapshot-origin will normally have one or more snapshots based on it. Reads will be mapped
directly to the backing device. For each write, the original data will be saved in the COW device of
each snapshot to keep its visible content unchanged until the COW device fills up.
The format for the snapshot target is as follows:
start length snapshot origin COW-device P|N chunksize