Advertisement
Guest User

Untitled

a guest
May 26th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. # Move the root filesystem from single disk to a RAID 1 without downtime
  2.  
  3. root$ df -h
  4. Filesystem Size Used Avail Use% Mounted on
  5. devtmpfs 7.7G 0 7.7G 0% /dev
  6. tmpfs 7.7G 0 7.7G 0% /dev/shm
  7. tmpfs 7.7G 8.8M 7.7G 1% /run
  8. tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
  9. /dev/mapper/vg-root 5.2G 1.4G 3.5G 29% /
  10. /dev/sdb1 922M 143M 732M 17% /boot
  11. tmpfs 1.6G 0 1.6G 0% /run/user/0
  12.  
  13.  
  14. # Create RAID 1: /dev/md0 = (/dev/sda, /dev/sdc)
  15.  
  16. root$ sudo mdadm --create /dev/md0 --auto md --level=1 --raid-devices=2 /dev/sda /dev/sdc
  17. mdadm: Note: this array has metadata at the start and
  18. may not be suitable as a boot device. If you plan to
  19. store '/boot' on this device please ensure that
  20. your boot-loader understands md/v1.x metadata, or use
  21. --metadata=0.90
  22. Continue creating array? y
  23. mdadm: Defaulting to version 1.2 metadata
  24. mdadm: array /dev/md0 started.
  25.  
  26.  
  27. root$ cat /proc/mdstat
  28. Personalities : [raid1]
  29. md0 : active raid1 sdc[1] sda[0]
  30. 2930134464 blocks super 1.2 [2/2] [UU]
  31. [>....................] resync = 0.2% (6527104/2930134464) finish=395.1min speed=123312K/sec
  32. bitmap: 22/22 pages [88KB], 65536KB chunk
  33.  
  34. unused devices: <none>
  35.  
  36.  
  37. root$ mdadm --examine /dev/sd[ac]
  38. /dev/sda:
  39. Magic : a92b4efc
  40. Version : 1.2
  41. Feature Map : 0x1
  42. Array UUID : 812f8b4b:eec3b59b:c5f0f680:c525b1aa
  43. Name : n0s0:0 (local to host n0s0)
  44. Creation Time : Thu May 16 01:10:45 2019
  45. Raid Level : raid1
  46. Raid Devices : 2
  47.  
  48. Avail Dev Size : 5860268976 (2794.39 GiB 3000.46 GB)
  49. Array Size : 2930134464 (2794.39 GiB 3000.46 GB)
  50. Used Dev Size : 5860268928 (2794.39 GiB 3000.46 GB)
  51. Data Offset : 264192 sectors
  52. Super Offset : 8 sectors
  53. Unused Space : before=264112 sectors, after=48 sectors
  54. State : active
  55. Device UUID : 3222008a:8b67b467:5d7a89d0:000b55dc
  56.  
  57. Internal Bitmap : 8 sectors from superblock
  58. Update Time : Thu May 16 01:12:50 2019
  59. Bad Block Log : 512 entries available at offset 24 sectors
  60. Checksum : ff7a421c - correct
  61. Events : 25
  62.  
  63.  
  64. Device Role : Active device 0
  65. Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
  66. /dev/sdc:
  67. Magic : a92b4efc
  68. Version : 1.2
  69. Feature Map : 0x1
  70. Array UUID : 812f8b4b:eec3b59b:c5f0f680:c525b1aa
  71. Name : n0s0:0 (local to host n0s0)
  72. Creation Time : Thu May 16 01:10:45 2019
  73. Raid Level : raid1
  74. Raid Devices : 2
  75.  
  76. Avail Dev Size : 5860268976 (2794.39 GiB 3000.46 GB)
  77. Array Size : 2930134464 (2794.39 GiB 3000.46 GB)
  78. Used Dev Size : 5860268928 (2794.39 GiB 3000.46 GB)
  79. Data Offset : 264192 sectors
  80. Super Offset : 8 sectors
  81. Unused Space : before=264112 sectors, after=48 sectors
  82. State : active
  83. Device UUID : f42f92c1:8e8c6347:53fee391:8fd6cfa1
  84.  
  85. Internal Bitmap : 8 sectors from superblock
  86. Update Time : Thu May 16 01:12:50 2019
  87. Bad Block Log : 512 entries available at offset 24 sectors
  88. Checksum : 9d90c467 - correct
  89. Events : 25
  90.  
  91.  
  92. Device Role : Active device 1
  93. Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
  94.  
  95.  
  96.  
  97. root$ mdadm --detail /dev/md0
  98. /dev/md0:
  99. Version : 1.2
  100. Creation Time : Thu May 16 01:10:45 2019
  101. Raid Level : raid1
  102. Array Size : 2930134464 (2794.39 GiB 3000.46 GB)
  103. Used Dev Size : 2930134464 (2794.39 GiB 3000.46 GB)
  104. Raid Devices : 2
  105. Total Devices : 2
  106. Persistence : Superblock is persistent
  107.  
  108. Intent Bitmap : Internal
  109.  
  110. Update Time : Thu May 16 01:13:35 2019
  111. State : clean, resyncing
  112. Active Devices : 2
  113. Working Devices : 2
  114. Failed Devices : 0
  115. Spare Devices : 0
  116.  
  117. Consistency Policy : bitmap
  118.  
  119. Resync Status : 0% complete
  120.  
  121. Name : n0s0:0 (local to host n0s0)
  122. UUID : 812f8b4b:eec3b59b:c5f0f680:c525b1aa
  123. Events : 34
  124.  
  125. Number Major Minor RaidDevice State
  126. 0 8 0 0 active sync /dev/sda
  127. 1 8 32 1 active sync /dev/sdc
  128.  
  129.  
  130.  
  131.  
  132. # Add Raid 1 to the volume group
  133. root$ pvcreate /dev/md0
  134. Physical volume "/dev/md0" successfully created.
  135.  
  136. root$ pvs
  137. PV VG Fmt Attr PSize PFree
  138. /dev/md0 lvm2 --- <2.73t <2.73t
  139. /dev/sdb2 vg lvm2 a-- <13.39g 0
  140.  
  141. root$ vgextend vg /dev/md0
  142. Volume group "vg" successfully extended
  143.  
  144.  
  145. root$ lvextend -r -L 200GiB vg/root
  146. Size of logical volume vg/root changed from <5.39 GiB (1379 extents) to 200.00 GiB (51200 extents).
  147. Logical volume vg/root successfully resized.
  148. resize2fs 1.42.9 (28-Dec-2013)
  149. Filesystem at /dev/mapper/vg-root is mounted on /; on-line resizing required
  150. old_desc_blocks = 1, new_desc_blocks = 25
  151. The filesystem on /dev/mapper/vg-root is now 52428800 blocks long.
  152.  
  153. root$ lvs
  154. LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
  155. root vg -wi-ao---- 200.00g
  156. swap vg -wi-ao---- 8.00g
  157.  
  158. root$ df -h
  159. Filesystem Size Used Avail Use% Mounted on
  160. devtmpfs 7.7G 0 7.7G 0% /dev
  161. tmpfs 7.7G 0 7.7G 0% /dev/shm
  162. tmpfs 7.7G 8.8M 7.7G 1% /run
  163. tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
  164. /dev/mapper/vg-root 197G 1.5G 188G 1% /
  165. /dev/sdb1 922M 143M 732M 17% /boot
  166. tmpfs 1.6G 0 1.6G 0% /run/user/0
  167.  
  168.  
  169. # Moves the extends from the old device to the new RAID 1
  170. root$ pvmove /dev/sdb2 /dev/md0
  171. /dev/sdb2: Moved: 0.00%
  172. /dev/sdb2: Moved: 8.02%
  173. /dev/sdb2: Moved: 43.95%
  174. /dev/sdb2: Moved: 75.05%
  175. /dev/sdb2: Moved: 100.00%
  176.  
  177.  
  178. root$ pvs
  179. PV VG Fmt Attr PSize PFree
  180. /dev/md0 vg lvm2 a-- <2.73t <2.53t
  181. /dev/sdb2 vg lvm2 a-- <13.39g <13.39g
  182.  
  183.  
  184. # Remove the old device
  185.  
  186. root$ vgreduce vg /dev/sdb2
  187. Removed "/dev/sdb2" from volume group "vg"
  188.  
  189.  
  190. root$ pvremove /dev/sdb2
  191. Labels on physical volume "/dev/sdb2" successfully wiped.
  192.  
  193.  
  194. # Save the configuration
  195. root$ mdadm --detail --scan --verbose >> /etc/mdadm.conf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement