<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Install Citrix XenServer 5.6 on softraid

Published on
18,701 Points
12,601 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
Comment
Author:dr-evil
5 Comments

Expert Comment

by:maniac_t
Very nice reading, thanks for sharing dr-evil :)

Although there is a typo in adding of the /dev/sda3 into raid, it should be actually /dev/md3  and not /dev/md1 .
So correct line number 4 should look like this:

mdadm -a /dev/md3 /dev/sda3
0
LVL 3

Author Comment

by:dr-evil
Thanks :) Fixed.
0

Expert Comment

by:fluxbox
Great article, works great for poor man's server with no real raid :) . Nice job.
0
LVL 1

Expert Comment

by:tejinashi
You might give a little more credit to the guys who actually figured all this stuff out and made it into a copy-paste style howto.

0
LVL 3

Author Comment

by:dr-evil
You might give a little more credit to the guys who actually figured all this stuff out and made it into a copy-paste style howto.
Yeah, but I've provided a link to original article, which I've checked and fixed. I have no other credit.
0

Featured Post

Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

Join & Write a Comment

In this video tutorial I show you the main steps to install and configure  a VMware ESXi6.0 server. The video has my comments as text on the screen and you can pause anytime when needed. Hope this will be helpful. Verify that your hardware and BIO…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month