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:
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:
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
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
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)
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
Now we have clean system on softraid :)
This article is a modified and fixed version of original article located
here
by: maniac_t on 2010-11-11 at 11:19:14ID: 21258
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