<

Install Citrix XenServer 5.6 on softraid

Published on
18,859 Points
12,759 Views
1 Endorsement
Last Modified:
Approved
Citrix XenServer 5.6 has a bug which causes inability to boot after you create any FD-type partition (0xFD=Raid Autodetect). To workaround this issue I suggest doing the following:

In the file /etc/rc.d/rc.sysinit  comment out the line:
[ -x /sbin/nash ] && echo "raidautorun /dev/md0" | nash –quiet

Open in new window


To move fresh-installed XenServer onto the new softraid do the following:
(I am assuming that  /dev/sdb is a new HDD)

Copy the original partition table from /dev/sda to /dev/sdb:
dd if=/dev/sda of=/dev/sdb bs=512 count=1

Open in new window

and check if it is equal (via fdisk -l /dev/sd[a,b])

The next step is to change the partition type from 0x83 (Linux) to 0xFD (Raid autodetect)
echo -e "\nt\n1\nfd\nt\n3\nfd\nw\nx" | fdisk /dev/sdb
echo -e "\nt\n3\nfd\nt\n3\nfd\nw\nx" | fdisk /dev/sdb

Open in new window

Create the degraded softraid devices:
mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1
mdadm --create /dev/md3 --level=1 --raid-devices=2 missing /dev/sdb3

Open in new window

Now we should mirror rootfs to newly created raid (/dev/md0)
mkfs.ext3 /dev/md0
cd / && mount /dev/md0 /mnt && rsync -a --progress --exclude=/sys --exclude=/proc --exclude=/dev/shm --exclude=/dev/pts --exclude=/var/run/sr-mount  / /mnt
mkdir /mnt/sys
mkdir /mnt/proc

Open in new window

And prepare system to boot from RAID.
Change the root-device name to /dev/md0 in file /mnt/etc/fstab
sed -r -i 's,LABEL=root-\w+ ,/dev/md0 ,g' /mnt/etc/fstab

Open in new window

Next, we should fix initrd to correctly boot from /dev/md0
Add load driver raid1.ko
mkdir /root/initrd && cd /root/initrd
zcat /boot/initrd-`uname -r`.img | cpio -i && cp /lib/modules/`uname -r`/kernel/drivers/md/raid1.ko lib

Open in new window


Add these strings to the init file:
q="echo Waiting for driver initialization."
sed -r -i "s,^${q}$,\n\necho Loading raid1.ko module\ninsmod /lib/raid1.ko\n${q}\n,g" init
q="resume /var/swap/swap.001"
sed -r -i "s,^${q}$,${q}\necho Running raidautorun\nraidautorun /dev/md0\nraidautorun /dev/md1\nraidautorun /dev/md3,g" init
r=`grep mkroot /root/initrd/init`
sed -r -i "s|^${r}$|${r/sda1/md0}|g" init

Open in new window

You could complete this step by hand using any preffered text editor, VI or nano:
We should add string insmod /lib/raid1.ko to the end load drivers. Other one is to add a few raidautorun
(raidautorun /dev/md0, raidautorun /dev/md3)

Now we should put new fixed initrd onto the RAID device
find . -print | cpio -o -c | gzip -c > /mnt/boot/initrd-`uname -r`.img

Open in new window


Setup bootloader
sed -r -i 's,root=LABEL=root-\w+ ,root=/dev/md0 ,g' /mnt/boot/extlinux.conf
cat /usr/lib/syslinux/mbr.bin > /dev/sdb
cd /mnt && extlinux -i boot/

Open in new window

Next we have to reboot and boot from secondary hard drive (/dev/sdb)
cd ; umount /mnt || umount /dev/md0
sync
reboot

Open in new window

If you made everything correctly after boot you should see that rootfs located on /dev/md0
(check it with mount)

Before the last step we may want to sync newly /dev/md0 with /dev/sda1
cd / && mount /dev/sda1 /mnt && rsync -a --progress --exclude=/sys --exclude=/proc --exclude=/dev/shm --exclude=/dev/pts --exclude=/var/run/sr-mount  / /mnt

Open in new window


And the last step: Change partitions types on /dev/sda and add it's to currently degraded raids
umount /mnt
echo -e "\nt\n1\nfd\nt\n3\nfd\nw\nx" | fdisk /dev/sda
mdadm -a /dev/md0 /dev/sda1
mdadm -a /dev/md3 /dev/sda3

Open in new window

This will cause raid-resync, you could watch it via
watch cat /proc/mdstat

Open in new window

Now we have clean system on softraid :)

This article is a modified and fixed version of original article located here
1
Author:dr-evil
Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Get 7 days free