I have written previously about how to convert Citrix Xenserver 6.2 to a software RAID 1. When I upgraded to Xenserver 6.5 I found I had to re-install the xenserver instance because the upgrade didn’t recognize the software RAID. When trying to follow my own guide I found that I couldn’t create the array – it gave the following error message:
mdadm: unexpected failure opening /dev/md0
It turns out 6.5 handles RAID differently. You have to manually load the RAID kernel modules before you can create arrays. I was able to get this running successfully thanks to guidance from this site, specifically comments on it by Olli.
The majority of this can simply be copy/pasted into the command window, once drive paths have been updated for your specific setup.
# Prepare /dev/sdd sgdisk --zap-all /dev/sdd sgdisk --mbrtogpt --clear /dev/sdd sgdisk -R/dev/sdd /dev/sdc # Replicate partion table from /dev/sdc to /dev/sdd with unique identifier sleep 5 # Sleep 5 seconds here if you script this… sgdisk --typecode=1:fd00 /dev/sdd sgdisk --typecode=2:fd00 /dev/sdd sgdisk --typecode=3:fd00 /dev/sdd sleep 5 # Sleep 5 seconds here if you script this… modprobe md_mod # load raid, because it isn't load by default (XS6.5 only) yes|mdadm --create /dev/md0 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdd1 missing # Create md0 (root) yes|mdadm --create /dev/md1 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdd2 missing # Create md0 (swap) yes|mdadm --create /dev/md2 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdd3 missing # Create md0 (storage) sleep 5 # Sleep 5 seconds here if you script this… mkfs.ext3 /dev/md0 # Create root FS mount /dev/md0 /mnt # Mount root FS cp -xR --preserve=all / /mnt # Replicate root files mdadm --detail --scan > /mnt/etc/mdadm.conf #generate RAID configuration sed -i 's/LABEL=[a-zA-Z\-]*/\/dev\/md0/' /mnt/etc/fstab # Update fstab for new RAID device 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/sdd chroot /mnt mkinitrd -v -f --theme=/usr/share/splash --without-multipath /boot/initrd-`uname -r`.img `uname -r` exit sed -i 's/LABEL=[a-zA-Z\-]*/\/dev\/md0/' /mnt/boot/extlinux.conf # Update extlinux for new RAID device cd /mnt && extlinux --raid -i boot/ sgdisk /dev/sdd --attributes=1:set:2 #Unmount filesystems and reboot cd umount /mnt/dev umount /mnt/sys umount /mnt/proc umount /mnt sync reboot
Tell BIOS to use disk B
After reboot to disk B…
sgdisk -R/dev/sdc /dev/sdd # Replicate partition table from /dev/sdd to /dev/sdc with unique identifier sgdisk /dev/sdc --attributes=1:set:2 sleep 5 # Sleep 5 seconds here if you script this… mdadm -a /dev/md0 /dev/sdc1 mdadm -a /dev/md1 /dev/sdc2 mdadm -a /dev/md2 /dev/sdc3 # If this command gives error, you need to forget/destroy an active SR first #This next command is the only command you have to manually update before pasting in. Find the UUID of your xenserver host and paste it between the <> below xe sr-create content-type=user device-config:device=/dev/md2 host-uuid=<UUID of xenserver host> name-label="RAID 1" shared=false type=lvm # Watch rebuild progress and wait until no arrays are rebuilding before proceeding with any reboot watch “mdadm --detail /dev/md* | grep rebuild”
Done!