- Create new partition for Local Storage
# gdisk /dev/sda
- Check /dev/sda partition table
# gdisk -l /dev/sda
(...)
Number Start (sector) End (sector) Size Code Name
1 2048 8388641 4.0 GiB 0700
2 8390656 16777249 4.0 GiB 0700
3 16779264 1953525134 923.5 GiB 8E00
- Check /dev/sdb partition table
# gdisk -l /dev/sdb
- Create RAID partitions on /dev/sdb.
Replicate the partition table sectors. Choose fd00 as code for partition type.
The result should look something like this:
Number Start (sector) End (sector) Size Code Name
1 2048 8388641 4.0 GiB FD00 Linux RAID
2 8390656 16777249 4.0 GiB FD00 Linux RAID
3 16779264 1953525134 923.5 GiB FD00 Linux RAID
- Create MD devices
# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 missing
# mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb2 missing
# mdadm --create /dev/md2 --level=1 --raid-devices=2 /dev/sdb3 missing
- Mount /dev/md0 and copy the filesystem to it
# mkfs.ext3 /dev/md0
# mount /dev/md0 /mnt
# cp -vxpR / /mnt
- Modify /mnt/etc/fstab and change the root= parameter to /dev/md0. (Do NOT include the LABEL=)
# sed -i 's/LABEL=[a-zA-Z\-]*/\/dev\/md0/' /mnt/etc/fstab
- Create a new boot image and uncompress it:
# mkdir /mnt/root/initrd-raid
# mkinitrd -v --fstab=/mnt/etc/fstab /mnt/root/initrd-raid/initrd-`uname -r`-raid.img `uname -r`
# cd /mnt/root/initrd-raid
# zcat initrd-`uname -r`-raid.img | cpio -i
# sed -i 's/raidautorun \/dev\/md0/raidautorun \/dev\/md0\nraidautorun \/dev\/md1\nraidautorun \/dev\/md2/' init
# rm initrd-`uname -r`-raid.img
- Copy the new ramdisk to the /mnt/boot folder and modify boot menu
# find . -print | cpio -o -Hnewc | gzip -c > /mnt/boot/initrd-`uname -r`-raid.img
# rm /mnt/boot/initrd-2.6-xen.img
rm: remove symbolic link `/mnt/boot/initrd-2.6-xen.img’? y
# ln -s initrd-`uname -r`-raid.img /mnt/boot/initrd-2.6-xen.img
# sed -i 's/LABEL=[a-zA-Z\-]*/\/dev\/md0/' extlinux.conf
- Set up MBR for GPT on /dev/sdb
# cat /mnt/usr/share/syslinux/gptmbr.bin > /dev/sdb
# cd /mnt
# extlinux --raid -i boot/
- Make sure the bootable flag is set on the partitions
# sgdisk /dev/sda --attributes=1:set:2
# sgdisk /dev/sdb --attributes=1:set:2
- Unmount /dev/md0
# cd
# umount /dev/md0
# sync
- Reboot ( IMPORTANT: Set your server to boot from the SECONDARY HDD before booting!)
# reboot
- After the reboot is (hopefully) complete, it's time to switch /dev/sda's partitions to RAID
# gdisk /dev/sda
Press 't' select partition number and type in fd00.
Repeat for all your partitions. Then 'w' to write changes.
Your partition table should look something like this:
(...)
Number Start (sector) End (sector) Size Code Name
1 2048 8388641 4.0 GiB FD00
2 8390656 16777249 4.0 GiB FD00
3 16779264 1953525134 923.5 GiB FD00
- You are now ready to add these partitions into the RAID arrays
# mdadm -a /dev/md0 /dev/sda1
mdadm: added /dev/sda1
# mdadm -a /dev/md1 /dev/sda2
mdadm: added /dev/sda2
# mdadm -a /dev/md2 /dev/sda3
mdadm: added /dev/sda3
- To check how the RAID sync is going look at:
# watch -n 1 cat /proc/mdstat
- When it's done on all three arrays, copy the RAID setup to /etc/mdadm.conf
# mdadm --detail --scan >> /etc/mdadm.conf
- At last add /dev/md2 as a local SR to XenServer
# xe host-list
uuid ( RO) : 0f85df3a-52be-44b5-83cb-828cf1d1c6b2
name-label ( RW): xenserver-joatnkwg
name-description ( RW): Default install of XenServer
# xe sr-create content-type=user device-config:device=/dev/md2 host-uuid=0f85df3a-52be-44b5-83cb-828cf1d1c6b2 name-label="Local Storage" shared=false type=ext
- You should now have a fully functional RAID 1 XenServer 6.2 Setup!
what the different if I use
"cat /mnt/usr/share/syslinux/gptmbr.bin > /dev/sdb" and
"cat /mnt/usr/share/syslinux/mbr.bin > /dev/sdb" to create bootloader?