Install Citrix XenServer 5.6 on softraid

AID: 3686
  • Status: Published

5550 points

  • Bydr-evil
  • TypeTips/Tricks
  • Posted on2010-09-14 at 06:03:13
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
                                    
1:

Select allOpen 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
                                    
1:

Select allOpen 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
                                    
1:
2:

Select allOpen 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
                                    
1:
2:

Select allOpen 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
                                    
1:
2:
3:
4:

Select allOpen 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
                                    
1:

Select allOpen 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
                                    
1:
2:

Select allOpen 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
                                    
1:
2:
3:
4:
5:
6:

Select allOpen 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
                                    
1:

Select allOpen 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/
                                    
1:
2:
3:

Select allOpen in new window


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

Select allOpen 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
                                    
1:

Select allOpen 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
                                    
1:
2:
3:
4:

Select allOpen in new window


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

Select allOpen in new window


Now we have clean system on softraid :)

This article is a modified and fixed version of original article located here
Asked On
2010-09-14 at 06:03:13ID3686
Tags

XenServer

,

raid

Topic

XenServer

Views
7764

Comments

Expert Comment

by: maniac_t on 2010-11-11 at 11:19:14ID: 21258

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

Author Comment

by: dr-evil on 2010-11-11 at 14:29:33ID: 21263

Thanks :) Fixed.

Expert Comment

by: fluxbox on 2011-01-31 at 19:44:55ID: 23347

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

Expert Comment

by: tejinashi on 2011-02-06 at 22:52:53ID: 23601

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.

Author Comment

by: dr-evil on 2011-06-20 at 05:08:20ID: 28915

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.

Add your Comment

Please Sign up or Log in to comment on this article.

Join Experts Exchange Today

Gain Access to all our Tech Resources

Get personalized answers

Ask unlimited questions

Access Proven Solutions

Search 3.2 million solutions

Read In-Depth How-To Guides

1000+ articles, demos, & tips

Watch Step by Step Tutorials

Learn direct from top tech pros

And Much More!

Your complete tech resource

See Plans and Pricing

30-day free trial. Register in 60 seconds.

Loading Advertisement...

Top XenServer Experts

  1. Mutawadi

    9,200

    0 points yesterday

    Profile
    Rank: Guru
  2. basraj

    2,800

    0 points yesterday

    Profile
    Rank: Sage
  3. tcorley

    2,000

    0 points yesterday

    Profile
  4. MrGraves

    2,000

    0 points yesterday

    Profile
    Rank: Guru
  5. CarlWebster

    1,600

    0 points yesterday

    Profile
    Rank: Genius
  6. dkotte

    1,500

    0 points yesterday

    Profile
    Rank: Guru
  7. sumit_

    1,000

    0 points yesterday

    Profile
  8. eduardoaguirrev

    1,000

    0 points yesterday

    Profile
  9. oBdA

    300

    0 points yesterday

    Profile
    Rank: Savant

Hall Of Fame