1 ============================== 2 Device-mapper snapshot support 3 ============================== 4 5 Device-mapper allows you, without massive data 6 7 - To create snapshots of any block device i.e 8 the block device which are also writable wi 9 original content; 10 - To create device "forks", i.e. multiple dif 11 same data stream. 12 - To merge a snapshot of a block device back 13 device. 14 15 In the first two cases, dm copies only the chu 16 changed and uses a separate copy-on-write (COW 17 storage. 18 19 For snapshot merge the contents of the COW sto 20 the origin device. 21 22 23 There are three dm targets available: 24 snapshot, snapshot-origin, and snapshot-merge. 25 26 - snapshot-origin <origin> 27 28 which will normally have one or more snapshots 29 Reads will be mapped directly to the backing d 30 original data will be saved in the <COW device 31 its visible content unchanged, at least until 32 33 34 - snapshot <origin> <COW device> <persistent? 35 [<# feature args> [<arg>]*] 36 37 A snapshot of the <origin> block device is cre 38 <chunksize> sectors will be stored on the <COW 39 only go to the <COW device>. Reads will come 40 from <origin> for unchanged data. <COW device 41 smaller than the origin and if it fills up the 42 useless and be disabled, returning errors. So 43 the amount of free space and expand the <COW d 44 45 <persistent?> is P (Persistent) or N (Not pers 46 after reboot). O (Overflow) can be added as a 47 to allow userspace to advertise its support fo 48 snapshot status. So supported store types are 49 50 The difference between persistent and transien 51 snapshots less metadata must be saved on disk 52 memory by the kernel. 53 54 When loading or unloading the snapshot target, 55 snapshot-origin or snapshot-merge target must 56 suspend the origin target could result in data 57 58 Optional features: 59 60 discard_zeroes_cow - a discard issued to th 61 maps to entire chunks to will zero the corr 62 the snapshot's exception store. 63 64 discard_passdown_origin - a discard to the 65 down to the snapshot-origin's underlying de 66 copy-out to the snapshot exception store be 67 target is bypassed. 68 69 The discard_passdown_origin feature depends 70 feature being enabled. 71 72 73 - snapshot-merge <origin> <COW device> <persi 74 [<# feature args> [<arg>]*] 75 76 takes the same table arguments as the snapshot 77 works with persistent snapshots. This target 78 "snapshot-origin" target and must not be loade 79 is still present for <origin>. 80 81 Creates a merging snapshot that takes control 82 stored in the <COW device> of an existing snap 83 procedure, and merges these chunks back into t 84 has started (in the background) the <origin> m 85 will continue while I/O is flowing to it. Cha 86 deferred until the merging snapshot's correspo 87 merged. Once merging has started the snapshot 88 the "snapshot" target, will return -EIO when a 89 90 91 How snapshot is used by LVM2 92 ============================ 93 When you create the first LVM2 snapshot of a v 94 95 1) a device containing the original mapping ta 96 2) a device used as the <COW device>; 97 3) a "snapshot" device, combining #1 and #2, w 98 volume; 99 4) the "original" volume (which uses the devic 100 source volume), whose table is replaced by 101 from device #1. 102 103 A fixed naming scheme is used, so with the fol 104 105 lvcreate -L 1G -n base volumeGroup 106 lvcreate -L 100M --snapshot -n snap volumeGr 107 108 we'll have this situation (with volumes in abo 109 110 # dmsetup table|grep volumeGroup 111 112 volumeGroup-base-real: 0 2097152 linear 8:19 113 volumeGroup-snap-cow: 0 204800 linear 8:19 2 114 volumeGroup-snap: 0 2097152 snapshot 254:11 115 volumeGroup-base: 0 2097152 snapshot-origin 116 117 # ls -lL /dev/mapper/volumeGroup-* 118 brw------- 1 root root 254, 11 29 ago 18:15 119 brw------- 1 root root 254, 12 29 ago 18:15 120 brw------- 1 root root 254, 13 29 ago 18:15 121 brw------- 1 root root 254, 10 29 ago 18:14 122 123 124 How snapshot-merge is used by LVM2 125 ================================== 126 A merging snapshot assumes the role of the "sn 127 merging. As such the "snapshot-origin" is rep 128 "snapshot-merge". The "-real" device is not c 129 device is renamed to <origin name>-cow to aid 130 merging snapshot after it completes. The "sna 131 COW device to the "snapshot-merge" is deactiva 132 --refresh); but if it is left active it will s 133 134 A snapshot will merge into its origin with the 135 136 lvconvert --merge volumeGroup/snap 137 138 we'll now have this situation:: 139 140 # dmsetup table|grep volumeGroup 141 142 volumeGroup-base-real: 0 2097152 linear 8:19 143 volumeGroup-base-cow: 0 204800 linear 8:19 2 144 volumeGroup-base: 0 2097152 snapshot-merge 2 145 146 # ls -lL /dev/mapper/volumeGroup-* 147 brw------- 1 root root 254, 11 29 ago 18:15 148 brw------- 1 root root 254, 12 29 ago 18:16 149 brw------- 1 root root 254, 10 29 ago 18:16 150 151 152 How to determine when a merging is complete 153 =========================================== 154 The snapshot-merge and snapshot status lines e 155 156 <sectors_allocated>/<total_sectors> <metadat 157 158 Both <sectors_allocated> and <total_sectors> i 159 During merging, the number of sectors allocate 160 smaller. Merging has finished when the number 161 is zero, in other words <sectors_allocated> == 162 163 Here is a practical example (using a hybrid of 164 165 # lvs 166 LV VG Attr LSize Origin S 167 base volumeGroup owi-a- 4.00g 168 snap volumeGroup swi-a- 1.00g base 18. 169 170 # dmsetup status volumeGroup-snap 171 0 8388608 snapshot 397896/2097152 1560 172 ^^^^ metad 173 174 # lvconvert --merge -b volumeGroup/snap 175 Merging of volume snap started. 176 177 # lvs volumeGroup/snap 178 LV VG Attr LSize Origin S 179 base volumeGroup Owi-a- 4.00g 180 181 # dmsetup status volumeGroup-base 182 0 8388608 snapshot-merge 281688/2097152 1104 183 184 # dmsetup status volumeGroup-base 185 0 8388608 snapshot-merge 180480/2097152 712 186 187 # dmsetup status volumeGroup-base 188 0 8388608 snapshot-merge 16/2097152 16 189 190 Merging has finished. 191 192 :: 193 194 # lvs 195 LV VG Attr LSize Origin S 196 base volumeGroup owi-a- 4.00g
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.