Based on https://discussions.citrix.com/topic/378478-xenserver-7-raid1-mdadm-after-install-running-system/
# 1. Install Xenserver 7 with normal single disk configuration, don't create SR storage # 2. copy partition talbe from sda to sdb # !!! important don't write the order wrongly, from sda to sdb is like the following sgdisk /dev/sda -R /dev/sdb # Important! The partition layout may differ with XenServer version, basically there are 2 partitions with same size for OS and backup # and at least 1 for GRUB and 1 for swap parted /dev/sdb # print # quit # You should see a list of partitions, one of them will be flagged as legacy_boot, grub, let's call it BOOT ## flag them as raid disks for sdb partitions sgdisk --typecode=1:fd00 /dev/sdb # OS sgdisk --typecode=2:fd00 /dev/sdb # Backup OS sgdisk --typecode=3:fd00 /dev/sdb # ?? sgdisk --typecode=4:ef02 /dev/sdb # BOOT sgdisk --typecode=5:fd00 /dev/sdb # LOGS sgdisk --typecode=6:fd00 /dev/sdb # SWAP ## note that BOOT partition is not the same like the others. Because in the new disk configuration they changed the boot partition. # 5. create the software raid partitions mdadm --create /dev/md0 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb1 missing mdadm --create /dev/md1 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb2 missing mdadm --create /dev/md2 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb3 missing mdadm --create /dev/md3 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb4 missing mdadm --create /dev/md4 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb5 missing mdadm --create /dev/md5 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb6 missing mkswap /dev/md5 # 6. copy the contents of / and /var/log directories to the new partitions mkfs.ext3 /dev/md0 mkfs.ext3 /dev/md4 # 7. mount newly created/formatted partitions mount /dev/md0 /mnt mkdir -p /mnt/var/log mount /dev/md4 /mnt/var/log # 8. copy contents to the newly mounted directory cp -xR --preserve=all / /mnt # 9. create a mdadm file for boot process (!!!if you forget the file the MD devices will have different names) ### the head of the file should include these lines echo "MAILADDR root" > /mnt/etc/mdadm.conf echo "auto +imsm +1.x -all" >> /mnt/etc/mdadm.conf echo "DEVICE /dev/sd*[a-z][1-9]" >> /mnt/etc/mdadm.conf mdadm --detail --scan >> /mnt/etc/mdadm.conf # 10. copy the contents to the root folder cp /mnt/etc/mdadm.conf /etc # 11. configure mount points sed -i 's/LABEL=root-[a-zA-Z\-]*/\/dev\/md0/' /mnt/etc/fstab sed -i 's/LABEL=swap-[a-zA-Z\-]*/\/dev\/md5/' /mnt/etc/fstab sed -i 's/LABEL=logs-[a-zA-Z\-]*/\/dev\/md4/' /mnt/etc/fstab sed -i '/md5/ a\/dev/md5 swap swap defaults 0 0 ' /mnt/etc/fstab cp /mnt/etc/fstab /etc # 12. change the label name for /dev/sdb1 partition e2label /dev/sda1 |xargs -t e2label /dev/sdb1 # 13. bind mount dev sys proc to the mnt folder mount --bind /dev /mnt/dev mount --bind /sys /mnt/sys mount --bind /proc /mnt/proc chroot /mnt /bin/bash # 14. install grub on /dev/sdb grub-install /dev/sdb # 15. backup initrd cp /boot/initrd-$(uname -r).img /boot/initrd-$(uname -r).img.bck # 16. create new initrd for raid dracut --mdadmconf --fstab --add="mdraid" --filesystems "ext3 tmpfs devpts sysfs proc" --add-drivers="raid1 raid456 mdraid1x mdraid09" --force /boot/initrd-$(uname -r).img $(uname -r) -M ###never change the boot configuration via grub-mkconfig.. it will kill xenserver.. change the GRUB configuation, by hand inside the files # 17. change grub configuration sed -i 's/quiet/rd.auto rd.auto=1 rhgb quiet/' /boot/grub/grub.cfg sed -i 's/LABEL=root-[a-zA-Z\-]*/\/dev\/md0/' /boot/grub/grub.cfg sed -i '/search/ i\ insmod gzio' /boot/grub/grub.cfg sed -i '/search/ i\ insmod part_msdos' /boot/grub/grub.cfg sed -i '/search/ i\ insmod diskfilter mdraid09' /boot/grub/grub.cfg sed -i '/search/ c\ set root=(hd0,gpt1)' /boot/grub/grub.cfg # 18. exit from chroot exit # 19. change the same things in sda1 partition so after reboot you don't need to boot from second disk cp /mnt/boot/initrd-3.10.0+10.img /boot/ sed -i 's/quiet/rd.auto rd.auto=1 rhgb quiet/' /boot/grub/grub.cfg sed -i 's/LABEL=root-[a-zA-Z\-]*/\/dev\/md0/' /boot/grub/grub.cfg sed -i '/search/ i\ insmod gzio' /boot/grub/grub.cfg sed -i '/search/ i\ insmod part_msdos' /boot/grub/grub.cfg sed -i '/search/ i\ insmod diskfilter mdraid09' /boot/grub/grub.cfg sed -i '/search/ c\ set root=(hd0,gpt1)' /boot/grub/grub.cfg # 20. reboot # !!!!!!reboot the server the server will boot from software raid..!!!!! # 21. After the reboot add the /dev/sda to the new MD disks. sgdisk /dev/sdb -R /dev/sda mdadm -a /dev/md0 /dev/sda1 mdadm -a /dev/md1 /dev/sda2 mdadm -a /dev/md2 /dev/sda3 mdadm -a /dev/md3 /dev/sda4 mdadm -a /dev/md4 /dev/sda5 # This will take a while for resync of all disks grub-install /dev/sda # Create SR xe sr-create content-type=user device-config:device=/dev/md2 host-uuid=<host-uuid> name-label=”SRRaid1-Local” shared=false type=lvm
This post is basically just a backup of that forum post in case it become dead link