Detalhe Importante, Isso aqui não é uma receita de bolo, você deve ter noção do que está fazendo, pois em muitos casos vai ter que improvisar, na primeira vez eu fiz várias vezes o processo, a segunda vez tive que mudar algumas coisas, mas a referência é boa...
I assume you have installed XenServer on /dev/sda and have NOT configure any local storage (it is easier to do that afterwards). /dev/sda should contain three partitions, verify this with:
sgdisk -p /dev/sda (Preste atenção no resultado deste comando, você vai usar ele abaixo)
What the second partition is for i am not sure. The second partition is used for backups during a XenServer upgrade. Now we are going to use /dev/sdb as the mirror disk. First clear the partition table.
sgdisk --zap-all /dev/sdb
Now install a GPT table on it
sgdisk --mbrtogpt --clear /dev/sdb
The following commands are dependent on your installation. Copy the start and end sectors from /dev/sda.
(você vai alterar conforme mostrou o comando que mandei prestar atenção)
sgdisk --new=1:2048:8388641 /dev/sdbsgdisk --typecode=1:fd00 /dev/sdbsgdisk --attributes=1:set:2 /dev/sdbsgdisk --new=2:8390656:16777249 /dev/sdbsgdisk --typecode=2:fd00 /dev/sdbsgdisk --new=3:16779264:976773134/dev/sdbsgdisk --typecode=3:fd00 /dev/sdb
Ignore sgdisk complaining about the sector addresses not being aligned. It will correct it automatically. Do pay attention if sgdisk says the kernel is still using the old partition table. You need to reboot if that is the case.
Now it is time to create the software RAID devices.
(antes de criar, apague se existir: rm -rf /dev/md0 md1 md2, caso exista o array apague ele:
mdadm --stop /dev/md0 # to halt the array
mdadm --remove /dev/md0 # to remove the array)
Faça o mesmo para /dev/md1 e 2, conforme necessidade
mknod /dev/md0 b 9 0mknod /dev/md1 b 9 1mknod /dev/md2 b 9 2mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb2mdadm --create /dev/md2 --level=1 --raid-devices=2 missing /dev/sdb3
Create bitmaps for each RAID device (see Criggie’s comment below). Bitmaps slightly impact throughput but significantly reduce the rebuilt time when the array fails.
mdadm --grow /dev/md0 -b internalmdadm --grow /dev/md1 -b internalmdadm --grow /dev/md2 -b internal
Format the root disk and mount it at /mnt.
mkfs.ext3 /dev/md0mount /dev/md0 /mnt
Copy the root filesystem to the RAID array.
cp -vxpR / /mnt
Change the root filesystem in /mnt/etc/fstab to /dev/md0.
edit /mnt/boot/extlinux.conf and replace every mention of the old root filesystem (root=LABEL=xxx) with root=/dev/md0.
Install the bootloader on the second hard disk.
mount --bind /dev /mnt/devmount -t sysfs none /mnt/sysmount -t proc none /mnt/procchroot /mnt /sbin/extlinux --install /bootdd if=/mnt/usr/share/syslinux/gptmbr.bin of=/dev/sdb
Make a new initrd image which contains a driver for the new root filesystem on the software RAID array.
chroot /mntmkinitrd -v -f --theme=/usr/share/splash --without-multipath /boot/initrd-`uname -r`.img `uname -r`
Onde esta escrito uname -r, você vai colocar o resultado desde comando do seu sitema, a primeira vez eu coloquei isso ae, deu pau hahahha
Agora como fala o comando abaixo, você tem que carregar o segundo disco para executar os comandos:
Unmount the new root and reboot. Remember to use the boot menu of your BIOS to boot from the second hard disk this time! When XenServer is up again, include /dev/sda in the array with the following commands:
sgdisk --typecode=1:fd00 /dev/sdasgdisk --typecode=2:fd00 /dev/sdasgdisk --typecode=3:fd00 /dev/sdamdadm -a /dev/md0 /dev/sda1mdadm -a /dev/md1 /dev/sda2
(lembro que nessa parte voce tem que remover o local storage do xen para funcionar, vou tentar editar depois)
mdadm -a /dev/md2 /dev/sda3
Depois você usa o comando:
xe sr-param-list uuid=e7fe2795-2e29-3f6b-9195-3471627cca78 (uuid do local storage, so da propriedades)
xe pbd-unplug uuid=b5e62814-d0c8-8971-f645-be6e5ec4cab5
xe sr-forget uuid=b5e62814-d0c8-8971-f645-be6e5ec4cab5
==== Reinicie e de o comando abaixo mudando para o uuid respectivo: xe host-list
xe sr-create host-uuid=78b6ff64-5d9f-4c0f-9e94-ee3ce04a6101 content-type=user type=lvm device-config:device=/dev/sdb shared=false name-label="Local storage 2"
The array needs to complete its initial build/synchronisation. That is gonna take a while. Follow its progress with:
watch -n 1 cat /proc/mdstat
At last add /dev/md2 as a local SR to XenServer.
Good luck with it.