Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 33bc227e4e48ddadcf2eacb381c19df338f0a6c8 74 lines 2.9 kB view raw
1Device-mapper snapshot support 2============================== 3 4Device-mapper allows you, without massive data copying: 5 6*) To create snapshots of any block device i.e. mountable, saved states of 7the block device which are also writable without interfering with the 8original content; 9*) To create device "forks", i.e. multiple different versions of the 10same data stream. 11 12 13In both cases, dm copies only the chunks of data that get changed and 14uses a separate copy-on-write (COW) block device for storage. 15 16 17There are two dm targets available: snapshot and snapshot-origin. 18 19*) snapshot-origin <origin> 20 21which will normally have one or more snapshots based on it. 22Reads will be mapped directly to the backing device. For each write, the 23original data will be saved in the <COW device> of each snapshot to keep 24its visible content unchanged, at least until the <COW device> fills up. 25 26 27*) snapshot <origin> <COW device> <persistent?> <chunksize> 28 29A snapshot of the <origin> block device is created. Changed chunks of 30<chunksize> sectors will be stored on the <COW device>. Writes will 31only go to the <COW device>. Reads will come from the <COW device> or 32from <origin> for unchanged data. <COW device> will often be 33smaller than the origin and if it fills up the snapshot will become 34useless and be disabled, returning errors. So it is important to monitor 35the amount of free space and expand the <COW device> before it fills up. 36 37<persistent?> is P (Persistent) or N (Not persistent - will not survive 38after reboot). 39The difference is that for transient snapshots less metadata must be 40saved on disk - they can be kept in memory by the kernel. 41 42 43How this is used by LVM2 44======================== 45When you create the first LVM2 snapshot of a volume, four dm devices are used: 46 471) a device containing the original mapping table of the source volume; 482) a device used as the <COW device>; 493) a "snapshot" device, combining #1 and #2, which is the visible snapshot 50 volume; 514) the "original" volume (which uses the device number used by the original 52 source volume), whose table is replaced by a "snapshot-origin" mapping 53 from device #1. 54 55A fixed naming scheme is used, so with the following commands: 56 57lvcreate -L 1G -n base volumeGroup 58lvcreate -L 100M --snapshot -n snap volumeGroup/base 59 60we'll have this situation (with volumes in above order): 61 62# dmsetup table|grep volumeGroup 63 64volumeGroup-base-real: 0 2097152 linear 8:19 384 65volumeGroup-snap-cow: 0 204800 linear 8:19 2097536 66volumeGroup-snap: 0 2097152 snapshot 254:11 254:12 P 16 67volumeGroup-base: 0 2097152 snapshot-origin 254:11 68 69# ls -lL /dev/mapper/volumeGroup-* 70brw------- 1 root root 254, 11 29 ago 18:15 /dev/mapper/volumeGroup-base-real 71brw------- 1 root root 254, 12 29 ago 18:15 /dev/mapper/volumeGroup-snap-cow 72brw------- 1 root root 254, 13 29 ago 18:15 /dev/mapper/volumeGroup-snap 73brw------- 1 root root 254, 10 29 ago 18:14 /dev/mapper/volumeGroup-base 74