peetaur

lvm snapshot test - does a huge size snapshot ever die

Jun 13th, 2013
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.56 KB | None | 0 0
  1. lvm snapshot test - does a snapshot ever take more space than the LV?
  2.  
  3. test 1 - snapshot same size as volume
  4. create lv
  5. fill it up
  6. snapshot it
  7. delete files
  8. fill again
  9. delete files
  10. fill again
  11. etc. until it overflows. Watch the size.
  12.  
  13.  
  14. lvcreate -L 500MB -n test testvg
  15. mkfs.ext4 /dev/testvg/test
  16. mount /dev/testvg/test /mnt/test
  17.  
  18. cp -a ~/archive/software/ubuntu/ test
  19.  
  20. df test
  21. Filesystem 1K-blocks Used Available Use% Mounted on
  22. /dev/mapper/testvg-test 487652 487652 0 100% /mnt/test
  23.  
  24. lvcreate --snapshot testvg/test -L 800MB -n testsnap /dev/sda4
  25.  
  26. lvs
  27. LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
  28. test testvg owi-aos-- 500.00m
  29. testsnap testvg swi-a-s-- 500.00m test 0.00
  30. lvscan
  31. ACTIVE Original '/dev/testvg/test' [500.00 MiB] inherit
  32. ACTIVE Snapshot '/dev/testvg/testsnap' [500.00 MiB] inherit
  33.  
  34. rm -r test/ubuntu/
  35. cp -a ~/archive/software/openSUSE/ test/
  36.  
  37. df test
  38. Filesystem 1K-blocks Used Available Use% Mounted on
  39. /dev/mapper/testvg-test 487652 487652 0 100% /mnt/test
  40.  
  41. lvdisplay
  42.  
  43. --- Logical volume ---
  44. LV Path /dev/testvg/testsnap
  45. LV Name testsnap
  46. VG Name testvg
  47. LV UUID PmGbQ9-ggC1-ev92-zOW4-xNsu-XpH8-hdPSSD
  48. LV Write Access read/write
  49. LV Creation host, time peter, 2013-06-13 10:27:47 +0200
  50. LV snapshot status active destination for test
  51. LV Status available
  52. # open 0
  53. LV Size 500.00 MiB
  54. Current LE 125
  55. COW-table size 500.00 MiB
  56. COW-table LE 125
  57. Allocated to snapshot 95.22%
  58. Snapshot chunk size 4.00 KiB
  59. Segments 1
  60. Allocation inherit
  61. Read ahead sectors auto
  62. - currently set to 1024
  63. Block device 253:1
  64.  
  65. rm -r test/openSUSE/
  66.  
  67. lvdisplay
  68.  
  69. --- Logical volume ---
  70. LV Path /dev/testvg/testsnap
  71. LV Name testsnap
  72. VG Name testvg
  73. LV UUID PmGbQ9-ggC1-ev92-zOW4-xNsu-XpH8-hdPSSD
  74. LV Write Access read/write
  75. LV Creation host, time peter, 2013-06-13 10:27:47 +0200
  76. LV snapshot status active destination for test
  77. LV Status available
  78. # open 0
  79. LV Size 500.00 MiB
  80. Current LE 125
  81. COW-table size 500.00 MiB
  82. COW-table LE 125
  83. Allocated to snapshot 95.24%
  84. Snapshot chunk size 4.00 KiB
  85. Segments 1
  86. Allocation inherit
  87. Read ahead sectors auto
  88. - currently set to 1024
  89. Block device 253:1
  90.  
  91. cp -a ~/archive/software/FreeBSD/ test
  92.  
  93. lvdisplay
  94.  
  95. --- Logical volume ---
  96. LV Path /dev/testvg/testsnap
  97. LV Name testsnap
  98. VG Name testvg
  99. LV UUID PmGbQ9-ggC1-ev92-zOW4-xNsu-XpH8-hdPSSD
  100. LV Write Access read/write
  101. LV Creation host, time peter, 2013-06-13 10:27:47 +0200
  102. LV snapshot status active destination for test
  103. LV Status available
  104. # open 0
  105. LV Size 500.00 MiB
  106. Current LE 125
  107. COW-table size 500.00 MiB
  108. COW-table LE 125
  109. Allocated to snapshot 95.32%
  110. Snapshot chunk size 4.00 KiB
  111. Segments 1
  112. Allocation inherit
  113. Read ahead sectors auto
  114. - currently set to 1024
  115. Block device 253:1
  116.  
  117.  
  118. umount test
  119. dd if=/dev/zero of=/dev/testvg/test bs=4M
  120.  
  121. lvdisplay
  122. /dev/testvg/testsnap: read failed after 0 of 4096 at 524222464: Input/output error
  123. /dev/testvg/testsnap: read failed after 0 of 4096 at 524279808: Input/output error
  124. /dev/testvg/testsnap: read failed after 0 of 4096 at 0: Input/output error
  125. /dev/testvg/testsnap: read failed after 0 of 4096 at 4096: Input/output error
  126.  
  127. mount /dev/testvg/testsnap test2
  128. mount: /dev/mapper/testvg-testsnap: can't read superblock
  129.  
  130. so in conclusion, it is *difficult* to overflow it, but with dd on the source volume, it destroys the snapshot. So I still wouldn't trust this.
  131. test 2 - snapshot larger than volume
  132.  
  133. mkfs.ext4 /dev/testvg/test
  134. mount /dev/testvg/test /mnt/test
  135. cp -a ~/archive/software/ubuntu/ test
  136.  
  137. lvremove testvg/testsnap
  138. lvcreate --snapshot testvg/test -L 800MB -n testsnap /dev/sda4
  139. lvs
  140. LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
  141. test testvg owi-aos-- 500.00m
  142. testsnap testvg swi-a-s-- 800.00m test 0.00
  143.  
  144. mount /dev/testvg/testsnap /mnt/test2
  145. ls test2
  146. lost+found ubuntu
  147.  
  148. umount test
  149. dd if=/dev/zero of=/dev/testvg/test bs=4M
  150.  
  151. lvs
  152. LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
  153. test testvg owi-a-s-- 500.00m
  154. testsnap testvg swi-aos-- 800.00m test 62.75
  155.  
  156. ls test2
  157. lost+found ubuntu
  158.  
  159. lvdisplay
  160. --- Logical volume ---
  161. LV Path /dev/testvg/testsnap
  162. LV Name testsnap
  163. VG Name testvg
  164. LV UUID 5f8tXe-lIR9-aGcv-N2Z7-t6mL-UykX-J483zC
  165. LV Write Access read/write
  166. LV Creation host, time peter, 2013-06-13 10:34:56 +0200
  167. LV snapshot status active destination for test
  168. LV Status available
  169. # open 1
  170. LV Size 500.00 MiB
  171. Current LE 125
  172. COW-table size 800.00 MiB
  173. COW-table LE 200
  174. Allocated to snapshot 62.75%
  175. Snapshot chunk size 4.00 KiB
  176. Segments 1
  177. Allocation inherit
  178. Read ahead sectors auto
  179. - currently set to 1024
  180. Block device 253:1
  181.  
  182. in conclusion: this seems to work fine. So there is probably some overhead that needs to be included when calculating the snapshot size to be more likely that it can be 'long lived'
Advertisement
Add Comment
Please, Sign In to add comment