Advertisement
Emyl

Istruzioni per il passaggio a RAID 1 su un server XenServer

Dec 7th, 2012
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 13.63 KB | None | 0 0
  1. # Istruzioni per il passaggio a RAID 1 su un server XenServer 6.1 con GPT
  2. # -----------------------------------------------------------------------
  3.  
  4. # STEP 1. Verifica della partition table del disco
  5. # dove e' installato XenServer (generalmente /dev/sda)
  6. gdisk -l /dev/sda
  7.  
  8. # (...)
  9. # Number  Start (sector)    End (sector)  Size       Code  Name
  10. #    1            2048         8388641   4.0 GiB     0700
  11. #    2         8390656        16777249   4.0 GiB     0700
  12. #    3        16779264       488397134   224.9 GiB   8E00
  13.  
  14. # STEP 2. Verifica della partition table dell'altro disco
  15. # (/dev/sdb)
  16. gdisk -l /dev/sdb
  17.  
  18. # ***************************************************************
  19. # Found invalid GPT and valid MBR; converting MBR to GPT format.
  20. # ***************************************************************
  21.  
  22. # Disk /dev/sdb: 488397168 sectors, 232.9 GiB
  23. # Logical sector size: 512 bytes
  24. # Disk identifier (GUID): 87B782BD-288B-4C78-8458-DD24DDBC41A0
  25. # Partition table holds up to 128 entries
  26. # First usable sector is 34, last usable sector is 488397134
  27. # Partitions will be aligned on 2048-sector boundaries
  28. # Total free space is 10541 sectors (5.1 MiB)
  29.  
  30. # Number  Start (sector)    End (sector)  Size       Code  Name
  31. #    1            2048          206847   100.0 MiB   0700  Linux/Windows data
  32. #    2          206848       470616063   224.3 GiB   0700  Linux/Windows data
  33. #    3       470616064       488388607   8.5 GiB     0700  Linux/Windows data
  34.  
  35. # STEP 3. Creazione partizioni RAID su /dev/sdb
  36. gdisk /dev/sdb
  37.  
  38. # GPT fdisk (gdisk) version 0.6.10
  39.  
  40. # Partition table scan:
  41. #   MBR: MBR only
  42. #   BSD: not present
  43. #   APM: not present
  44. #   GPT: not present
  45.  
  46.  
  47. # ***************************************************************
  48. # Found invalid GPT and valid MBR; converting MBR to GPT format.
  49. # THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if
  50. # you don't want to convert your MBR partitions to GPT format!
  51. # ***************************************************************
  52.  
  53.  
  54. # Command (? for help): ?
  55. # b       back up GPT data to a file
  56. # c       change a partition's name
  57. # d       delete a partition
  58. # i       show detailed information on a partition
  59. # l       list known partition types
  60. # n       add a new partition
  61. # o       create a new empty GUID partition table (GPT)
  62. # p       print the partition table
  63. # q       quit without saving changes
  64. # r       recovery and transformation options (experts only)
  65. # s       sort partitions
  66. # t       change a partition's type code
  67. # v       verify disk
  68. # w       write table to disk and exit
  69. # x       extra functionality (experts only)
  70. # ?       print this menu
  71.  
  72. # STEP 3/1. Eliminazione delle partizioni esistenti
  73.  
  74. Command (? for help): d
  75. Partition number (1-3): 1
  76.  
  77. Command (? for help): d
  78. Partition number (2-3): 2
  79.  
  80. Command (? for help): d
  81. Using 3
  82.  
  83. Command (? for help): p
  84. # Disk /dev/sdb: 488397168 sectors, 232.9 GiB
  85. # Logical sector size: 512 bytes
  86. # Disk identifier (GUID): 0F0F7742-7696-41A6-8733-219F8F5790AB
  87. # Partition table holds up to 128 entries
  88. # First usable sector is 34, last usable sector is 488397134
  89. # Partitions will be aligned on 2048-sector boundaries
  90. # Total free space is 488397101 sectors (232.9 GiB)
  91.  
  92. # Number  Start (sector)    End (sector)  Size       Code  Name
  93.  
  94. # STEP 3/2. Creazione delle partizioni come /dev/sda, di tipo FD00 (Linux RAID)
  95.  
  96. Command (? for help): n
  97. Partition number (1-128, default 1): 1
  98. First sector (34-488397134, default = 34) or {+-}size{KMGT}: 2048
  99. Last sector (2048-488397134, default = 488397134) or {+-}size{KMGT}: 8388641
  100. Current type is 'Linux/Windows data'
  101. Hex code (L to show codes, 0 to enter raw code, Enter = 0700): FD00
  102. Changed type of partition to 'Linux RAID'
  103.  
  104. Command (? for help): n
  105. Partition number (2-128, default 2): 2
  106. First sector (34-488397134, default = 8388642) or {+-}size{KMGT}: 8390656
  107. Last sector (8390656-488397134, default = 488397134) or {+-}size{KMGT}: 16777249
  108. Current type is 'Linux/Windows data'
  109. Hex code (L to show codes, 0 to enter raw code, Enter = 0700): FD00
  110. Changed type of partition to 'Linux RAID'
  111.  
  112. Command (? for help): n
  113. Partition number (3-128, default 3): 3
  114. First sector (34-488397134, default = 16777250) or {+-}size{KMGT}: 16779264
  115. Last sector (16779264-488397134, default = 488397134) or {+-}size{KMGT}: 488397134
  116. Current type is 'Linux/Windows data'
  117. Hex code (L to show codes, 0 to enter raw code, Enter = 0700): FD00
  118. Changed type of partition to 'Linux RAID'
  119.  
  120. Command (? for help): p
  121. # Disk /dev/sdb: 488397168 sectors, 232.9 GiB
  122. # Logical sector size: 512 bytes
  123. # Disk identifier (GUID): 0F0F7742-7696-41A6-8733-219F8F5790AB
  124. # Partition table holds up to 128 entries
  125. # First usable sector is 34, last usable sector is 488397134
  126. # Partitions will be aligned on 2048-sector boundaries
  127. # Total free space is 6042 sectors (3.0 MiB)
  128.  
  129. # Number  Start (sector)    End (sector)  Size       Code  Name
  130. #    1            2048         8388641   4.0 GiB     FD00  Linux RAID
  131. #    2         8390656        16777249   4.0 GiB     FD00  Linux RAID
  132. #    3        16779264       488397134   224.9 GiB   FD00  Linux RAID
  133.  
  134. # STEP 3/3. Scrittura della tabella delle partizioni su disco (ATTENZIONE!)
  135.  
  136. Command (? for help): w
  137.  
  138. Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
  139. PARTITIONS!!
  140.  
  141. Do you want to proceed, possibly destroying your data? (Y/N): Y
  142. OK; writing new GUID partition table (GPT).
  143. # The operation has completed successfully.
  144.  
  145. # STEP 4. Riavvio del server
  146. reboot
  147.  
  148. # STEP 5. Creazione driver MD (multiple devices, in pratica sono i driver di Linux per il RAID software)
  149. mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 missing
  150. # mdadm: array /dev/md0 started.
  151. mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb2 missing
  152. # mdadm: array /dev/md1 started.
  153. mdadm --create /dev/md2 --level=1 --raid-devices=2 /dev/sdb3 missing
  154. # mdadm: array /dev/md2 started.
  155.  
  156. # STEP 6. Spostamento della partizione dedicata alle macchine virtuali sul volume RAID
  157. # NOTA: il nome del Volume Group e' casuale, viene indicato come VG_<TAB> dal momento che il tasto TAB
  158. # puo' essere utilizzato per espandere il nome automaticamente.
  159.  
  160. pvcreate /dev/md2
  161. # Physical volume "/dev/md2" successfully created
  162. vgextend VG_<TAB> /dev/md2
  163. # Volume group "VG_XenStorage-a387dae6-291d-34d3-dd74-7e35ad937048" successfully extended
  164. pvmove /dev/sda3 /dev/md2
  165. # /dev/sda3: Moved: 0.0%
  166. # /dev/sda3: Moved: 2.3%
  167. # /dev/sda3: Moved: 4.5%
  168. # ...
  169. # /dev/sda3: Moved: 96.8%
  170. # /dev/sda3: Moved: 98.6%
  171. # /dev/sda3: Moved: 100.0%
  172.  
  173. # STEP 7. Rimozione della vecchia partizione dal Volume Group
  174. vgreduce VG_<TAB> /dev/sda3
  175. # Removed "/dev/sda3" from volume group "VG_XenStorage-a387dae6-291d-34d3-dd74-7e35ad937048"
  176. pvremove /dev/sda3
  177. # Labels on physical volume "/dev/sda3" successfully wiped
  178.  
  179. # STEP 8. Formattazione di /dev/md0 e copia del sistema operativo su di esso
  180. mkfs.ext3 /dev/md0
  181. # mke2fs 1.39 (29-May-2006)
  182. # Filesystem label=
  183. # OS type: Linux
  184. # Block size=4096 (log=2)
  185. # Fragment size=4096 (log=2)
  186. # 524288 inodes, 1048304 blocks
  187. # 52415 blocks (5.00%) reserved for the super user
  188. # First data block=0
  189. # Maximum filesystem blocks=1073741824
  190. # 32 block groups
  191. # 32768 blocks per group, 32768 fragments per group
  192. # 16384 inodes per group
  193. # Superblock backups stored on blocks:
  194. #         32768, 98304, 163840, 229376, 294912, 819200, 884736
  195.  
  196. # Writing inode tables: done
  197. # Creating journal (16384 blocks): done
  198. # Writing superblocks and filesystem accounting information: done
  199.  
  200. # This filesystem will be automatically checked every 34 mounts or
  201. # 180 days, whichever comes first.  Use tune2fs -c or -i to override.
  202. mount /dev/md0 /mnt
  203. cd /
  204. cp -axv . /mnt
  205. # ...
  206. # `./cli-rt/gtserver/gtmessages.ml' -> `/mnt/./cli-rt/gtserver/gtmessages.ml'
  207. # `./cli-rt/gtserver/gtserver_linux.ml' -> `/mnt/./cli-rt/gtserver/gtserver_linux.ml'
  208. # `./media' -> `/mnt/./media'
  209.  
  210. # STEP 9. Modifica del file /mnt/etc/fstab
  211. # Nella prima colonna dell prima riga e' necessario inserire il valore /dev/md0
  212. nano /mnt/etc/fstab
  213. # PRIMA DELLE MODIFICHE:
  214. # LABEL=root-slwymfnm    /         ext3     defaults   1  1
  215. # DOPO LE MODIFICHE:
  216. # /dev/md0    /         ext3     defaults   1  1
  217. #
  218. # Il salvataggio si effettua con CTRL + Lettera O + Invio. Per uscire da nano invece si usa CTRL + X.
  219.  
  220. # STEP 10. Creazione di una nuova immagine di boot e relativo scompattamento
  221. mkdir /mnt/root/initrd-raid
  222. mkinitrd -v --fstab=/mnt/etc/fstab /mnt/root/initrd-raid/initrd-`uname -r`-raid.img `uname -r`
  223. # Creating initramfs
  224. # Modulefile is /etc/modprobe.conf
  225. # Looking for deps of module ehci-hcd: usbcore
  226. # ...
  227. # Adding module dm-mirror
  228. # Adding module dm-zero
  229. # Adding module dm-snapshot
  230. cd /mnt/root/initrd-raid
  231. zcat initrd-`uname -r`-raid.img | cpio -i
  232. # 14097 blocks
  233.  
  234. # STEP 11. Modifica del file init
  235. # E' necessario cercare la riga che contiene il testo:
  236. # raidautorun /dev/md2
  237. # ed inserire nelle due righe superiori il testo
  238. # raidautorun /dev/md0
  239. # raidautorun /dev/md1
  240. nano init
  241. # Per salvare e uscire vedere step 9
  242.  
  243. # STEP 12. Copia del nuovo ramdisk e modifica del menu di boot
  244. find . -print | cpio -o -Hnewc | gzip -c > /mnt/boot/initrd-`uname -r`-raid.img
  245. # 20401 blocks
  246. rm /mnt/boot/initrd-2.6-xen.img
  247. rm: remove symbolic link `/mnt/boot/initrd-2.6-xen.img`? y
  248. ln -s initrd-`uname -r`-raid.img /mnt/boot/initrd-2.6-xen.img
  249. nano /mnt/boot/extlinux.conf
  250. # Modificare tutte le voci "root=LABEL=root-xyz" con "root=/dev/md0".
  251. # Per salvare e uscire vedere step 9
  252.  
  253. # STEP 13. Impostazione MBR su /dev/sdb
  254. cat /mnt/usr/share/syslinux/gptmbr.bin > /dev/sdb
  255. cd /mnt
  256. extlinux --raid -i boot/
  257. # boot/ is device /dev/md0
  258.  
  259. # STEP 14. Unmount di /dev/md0
  260. cd
  261. umount /dev/md0
  262. sync
  263.  
  264. # STEP 15. Impostazione del flag di boot sui dischi
  265. sgdisk /dev/sda --attributes=1:set:2
  266. # Warning: The kernel is still using the old partition table.
  267. # The new table will be used at the next reboot.
  268. # The operation has completed successfully.
  269. sgdisk /dev/sdb --attributes=1:set:2
  270. # Warning: The kernel is still using the old partition table.
  271. # The new table will be used at the next reboot.
  272. # The operation has completed successfully.
  273.  
  274. # STEP 16. Spegnimento
  275. # IMPORTANTE: Prima del riavvio e' necessario impostare sul BIOS il boot dal SECONDO Hard Disk!
  276. poweroff
  277.  
  278. # STEP 17. Cambio del tipo di partizioni per /dev/sda
  279. gdisk /dev/sda
  280. # GPT fdisk (gdisk) version 0.6.10
  281.  
  282. # Partition table scan:
  283. #   MBR: protective
  284. #   BSD: not present
  285. #   APM: not present
  286. #   GPT: present
  287.  
  288. # Found valid GPT with protective MBR; using GPT.
  289.  
  290. # Command (? for help): t
  291. # Partition number (1-3): 1
  292. # Current type is 'Linux/Windows data'
  293. # Hex code (L to show codes, 0 to enter raw code, Enter = 0700): FD00
  294. # Changed type of partition to 'Linux RAID'
  295.  
  296. # Command (? for help): t
  297. # Partition number (1-3): 2
  298. # Current type is 'Linux/Windows data'
  299. # Hex code (L to show codes, 0 to enter raw code, Enter = 0700): FD00
  300. # Changed type of partition to 'Linux RAID'
  301.  
  302. # Command (? for help): t
  303. # Partition number (1-3): 3
  304. # Current type is 'Linux LVM'
  305. # Hex code (L to show codes, 0 to enter raw code, Enter = 0700): FD00
  306. # Changed type of partition to 'Linux RAID'
  307.  
  308. # Command (? for help): p
  309. # Disk /dev/sda: 488397168 sectors, 232.9 GiB
  310. # Logical sector size: 512 bytes
  311. # Disk identifier (GUID): 94FD44E7-05E0-41C4-90DD-409B329C78CB
  312. # Partition table holds up to 128 entries
  313. # First usable sector is 34, last usable sector is 488397134
  314. # Partitions will be aligned on 2048-sector boundaries
  315. # Total free space is 6042 sectors (3.0 MiB)
  316.  
  317. # Number  Start (sector)    End (sector)  Size       Code  Name
  318. #    1            2048         8388641   4.0 GiB     FD00
  319. #    2         8390656        16777249   4.0 GiB     FD00
  320. #    3        16779264       488397134   224.9 GiB   FD00
  321.  
  322. # Command (? for help): w
  323.  
  324. # Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
  325. # PARTITIONS!!
  326.  
  327. # Do you want to proceed, possibly destroying your data? (Y/N): Y
  328. # OK; writing new GUID partition table (GPT).
  329. # The operation has completed successfully.
  330.  
  331. # STEP 18. Aggiunta delle partizioni di /dev/sda all'array RAID
  332. mdadm -a /dev/md0 /dev/sda1
  333. # mdadm: added /dev/sda1
  334. mdadm -a /dev/md1 /dev/sda2
  335. # mdadm: added /dev/sda2
  336. mdadm -a /dev/md2 /dev/sda3
  337. # mdadm: added /dev/sda3
  338.  
  339. # STEP 19. Verifica del processo di ricostruzione dell'array RAID
  340. # La configurazione e' pressoche' completata. Per verificare lo stato dell'array eseguire il comando:
  341. cat /proc/mdstat
  342.  
  343. # Se l'array e' in ricostruzione l'output sara' simile a:
  344. # -------------------------------------------------------
  345. # Personalities : [raid1]
  346. # md1 : active raid1 sda2[2] sdb2[0]
  347. #       4193216 blocks [2/1] [U_]
  348. #         resync=DELAYED
  349.  
  350. # md2 : active raid1 sda3[2] sdb3[0]
  351. #       235808832 blocks [2/1] [U_]
  352. #       [>....................]  recovery =  1.3% (3166784/235808832) finish=34.2min speed=113099K/sec
  353.  
  354. # md0 : active raid1 sda1[1] sdb1[0]
  355. #       4193216 blocks [2/2] [UU]
  356.  
  357. # unused devices: <none>
  358.  
  359. # Al termine della ricostruzione invece si avra' il seguente output:
  360. # ------------------------------------------------------------------
  361. # Personalities : [raid1]
  362. # md1 : active raid1 sda2[1] sdb2[0]
  363. #       4193216 blocks [2/2] [UU]
  364.  
  365. # md2 : active raid1 sda3[1] sdb3[0]
  366. #       235808832 blocks [2/2] [UU]
  367.  
  368. # md0 : active raid1 sda1[1] sdb1[0]
  369. #       4193216 blocks [2/2] [UU]
  370.  
  371. # unused devices: <none>
  372.  
  373. # STEP 20. Copia della configurazione RAID
  374. mdadm --detail --scan >> /etc/mdadm.conf
  375.  
  376. # STEP 21. Restore del Volume Group
  377. cd /etc/lvm/backup
  378. vgcfgrestore --file VG_<TAB> VG_<TAB>
  379. # Restored volume group VG_XenStorage-a387dae6-291d-34d3-dd74-7e35ad937048
  380.  
  381. # Configurazione RAID 1 completata. Congratulazioni!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement