Install XenServer on software RAID GPT(6+)


Install XenServer on software RAID GPT(6+)

1) Print partition table

sgdisk -p /dev/sda

Save this for step 4

The second partition is used for backups during a XenServer upgrade. Now we are going to use /dev/sdb as the mirror disk.

2) Clear the partition table.

sgdisk --zap-all /dev/sdb

 

3) Now install a GPT table on it

sgdisk --mbrtogpt --clear /dev/sdb

4) The following commands are dependent on your installation. Copy the start and end sectors from /dev/sda.

sgdisk --new=1:2048:8388641 /dev/sdb
sgdisk --typecode=1:fd00 /dev/sdb
sgdisk --attributes=1:set:2 /dev/sdb
sgdisk --new=2:8390656:16777249 /dev/sdb
sgdisk --typecode=2:fd00 /dev/sdb
sgdisk --new=3:16779264:5860533134 /dev/sdb
sgdisk --typecode=3:fd00 /dev/sdb

5) Now it is time to create the software RAID devices.

mknod /dev/md0 b 9 0
mknod /dev/md1 b 9 1
mknod /dev/md2 b 9 2
mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb2
mdadm --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 internal
mdadm --grow /dev/md1 -b internal
mdadm --grow /dev/md2 -b internal

If your Local storage is more than 2Tb it will use metadata 1.0 and you need to create mdadm.conf

mdadm --examine --scan >> /etc/mdadm.conf

6) Format the root disk and mount it at /mnt. Copy the root filesystem to the RAID array.

mkfs.ext3 /dev/md0
mount /dev/md0 /mnt

Copy the root filesystem to the RAID array.

cp -vxpR / /mnt

7) Modify fstab

sed -r -i 's,LABEL=root-\w+ ,/dev/md0 ,g' /mnt/etc/fstab

8) remove /dev/sda3 from Local storage VG

pvcreate /dev/md2
volume_group=`vgscan | grep VG | awk -F \" '{print $2}'`
vgextend $volume_group /dev/md2
pvmove /dev/sda3 /dev/md2
vgreduce $volume_group /dev/sda3

9)

mount --bind /dev /mnt/dev
mount -t sysfs none /mnt/sys
mount -t proc none /mnt/proc
chroot /mnt /sbin/extlinux --install /boot
dd if=/mnt/usr/share/syslinux/gptmbr.bin of=/dev/sdb

10) Make a new initrd image which contains a driver for the new root filesystem on the software RAID array.

chroot /mnt
mkinitrd -v -f --theme=/usr/share/splash --without-multipath /boot/initrd-`uname -r`.img `uname -r`
exit

11) setup loader

sed -r -i 's,root=LABEL=root-\w+ ,root=/dev/md0 ,g' /mnt/boot/extlinux.conf
sed -r -i 's,root=LABEL=root-\w+ ,root=/dev/md0 ,g' /boot/extlinux.conf
cp /mnt/boot/extlinux.conf /boot/
cp /mnt/boot/initrd-`uname -r`.img /boot

12) reboot

13) add sda to md raid

sgdisk --typecode=1:fd00 /dev/sda
sgdisk --typecode=2:fd00 /dev/sda
sgdisk --typecode=3:fd00 /dev/sda
mdadm -a /dev/md0 /dev/sda1
mdadm -a /dev/md1 /dev/sda2
mdadm -a /dev/md2 /dev/sda3

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