*note* this is yet a shameless copy of http://www.firstserved.net/blog/2007/06/07/booting-xenserver-or-xenenterprise-from-software-raid/, which still needs to be modified!
Since XenServer and XenEnterprise do not support installing the operating system on an MD software RAID device during the installation, you’ll have to undertake a few steps afterwards if you want to mirror your boot disks.
This article is largely based on Harry de Jong’s solution, as posted on the XenSource forums, with a few differences:
* There’s no need to copy mdadm.static from another server to the Xen host;
* The initrd ramdisk’s configuration is a bit simpler;
* There’s no need to swap the physical disks, which means the procedure can be accomplished remotely.
Create identical partitions to your boot disk /dev/sda on your second disk /dev/sdb
If /dev/sda looks like this:
# fdisk -l /dev/sda
Disk /dev/sda: 249.3 GB, 249376538624 bytes
255 heads, 63 sectors/track, 30318 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 499 4008186 83 Linux
/dev/sda2 500 998 4008217+ 83 Linux
/dev/sda3 999 30318 235512900 83 Linux
/dev/sdb should look like this:
# fdisk -l /dev/sdb
Disk /dev/sdb: 249.3 GB, 249376538624 bytes
255 heads, 63 sectors/track, 30318 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 499 4008186 fd Linux raid autodetect
/dev/sdb2 500 998 4008217+ fd Linux raid autodetect
/dev/sdb3 999 30318 235512900 fd Linux raid autodetect
Do not forget to set the partition type to ‘fd’ (Linux RAID autodetect) instead of the default 83 (Linux).
Create the necessary device nodes
# mknod /dev/md0 b 9 0
# mknod /dev/md1 b 9 1
# mknod /dev/md2 b 9 2
Create your MD RAID 1 arrays (with missing disks)
# mdadm –create /dev/md0 –level=1 –raid-devices=2 /dev/sdb1 missing
# mdadm –create /dev/md1 –level=1 –raid-devices=2 /dev/sdb2 missing
# mdadm –create /dev/md2 –level=1 –raid-devices=2 /dev/sdb3 missing
/dev/sda2 is just an empty, unmounted partition used by XenServer for upgrades.
Copy the Xen Storage Manager data over to RAID
# pvcreate /dev/md2
# vgextend VG_XenStorage-3553b468-fca7-46c0-baeb-7cd471a6a9ab /dev/md1
# pvmove /dev/sda3 /dev/md2
Replace the uuid in the vgextend line above with the uuid of your own Xen SR. Use ’sm info’ to display your SR’s uuid.
Remove /dev/sda3 from the SR volume group and add it to the RAID array
# vgreduce VG_XenStorage-3553b468-fca7-46c0-baeb-7cd471a6a9ab /dev/sda3
# pvremove /dev/sda3
# mdadm -a /dev/md2 /dev/sda3
Mount /dev/md0 and copy the filesystem to it
# mkfs.ext3 /dev/md0
# mount /dev/md0 /mnt
# cd /
# cp -axv . /mnt
Make a new initrd ramdisk containing the MD RAID drivers
Modify /mnt/etc/fstab so the system will mount / from /dev/md0 instead of LABEL=/-main. Replace "LABEL=/-main" by "/dev/md0".
Create a new boot image and uncompress it:
# mkdir /mnt/root/initrd-raid
# mkinitrd –fstab=/mnt/etc/fstab /mnt/root/initrd-raid/initrd-2.6.16.38-xs3.2.0.531.3960xen-raid.img 2.6.16.38-xs3.2.0.531.3960xen
# cd /mnt/root/initrd-raid
# zcat initrd-2.6.16.38-xs3.2.0.531.3960xen-raid.img | cpio -i
Since mkinitrd looks at /etc/fstab to determine what device the root volume is on, it has now added the necessary raid drivers to the new boot image.
Uncompress the current ramdisk and add the raid drivers to it
# mkdir /root/initrd
# cd /root/initrd
# zcat /boot/initrd-2.6.16.38-xs3.2.0.531.3960xen.img | cpio -i
Now add the raid module from the new ramdisk and modify the init file:
# cp /root/initrd-raid/lib/raid1.ko lib
# vi init
Add the following lines before the second line containing "/sbin/udevstart":
echo "Loading raid1.ko module"
insmod /lib/raid1.ko
Add the following lines before the line containing "echo Creating root device":
raidautorun /dev/md0
raidautorun /dev/md1
raidautorun /dev/md2
Note: if you’ve created other MD raid devices, add a ‘raidautorun’ statement for them as well.
Copy the new ramdisk to the /mnt/boot folder and add modify GRUB’s boot menu
# find . -print | cpio -o -Hnewc | gzip -c > /mnt/boot/initrd-2.6.16.38-xs3.2.0.531.3960xen-raid.img
# rm /mnt/boot/initrd-2.6-xen.img
rm: remove symbolic link `/mnt/boot/initrd-2.6-xen.img’? y
# ln -s initrd-2.6.16.38-xs3.2.0.531.3960xen-raid.img /mnt/boot/initrd-2.6-xen.img
# vi /mnt/boot/grub/menu.lst
Replace "root=LABEL=/-main" by "root=/dev/md0" in all menu entries.
Unmount /dev/md0
# cd /root
# umount /dev/md0
# sync
Set up the Master Boot Record on /dev/sdb
# grub
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd0)
Checking if "/boot/grub/stage1" exists… yes
Checking if "/boot/grub/stage2" exists… yes
Checking if "/boot/grub/e2fs_stage1_5" exists… yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"… 16 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2
/boot/grub/grub.conf"… succeeded
Done.
grub> quit
Modify GRUB’s boot menu to boot from the second disk
# vi /boot/grub/menu.lst
Replace the line in the first XenServer entry that says "root (hd0,0)" with "root (hd1,0)". Also replace "root=LABEL=/-main" by "root=/dev/md0" in all menu entries. This will allow you to boot from /dev/md0 instead of /dev/sda. In case something goes wrong, you could always reboot using one of the other entries, which still point to /dev/sda.
Reboot
# shutdown -r now
If all goes well, you should see your system mounting /dev/md0 as the filesystem root. If not, reboot using one of the other GRUB menu entries and check out the previous steps.
Change /dev/sda’s partition types from Linux to Linux RAID autodetect
# fdisk /dev/sda
The result should be something like this:
Disk /dev/sda: 249.3 GB, 249376538624 bytes
255 heads, 63 sectors/track, 30318 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 499 4008186 fd Linux raid autodetect
/dev/sda2 500 998 4008217+ fd Linux raid autodetect
/dev/sda3 999 30318 235512900 fd Linux raid autodetect
Add the missing partitons to the RAID arrays
# mdadm -a /dev/md0 /dev/sda1
mdadm: hot added /dev/sda1
# mdadm -a /dev/md1 /dev/sda2
mdadm: hot added /dev/sda2
# mdadm -a /dev/md2 /dev/sda3
mdadm: hot added /dev/sda3
Then wait for the sync to complete:
# watch cat /proc/mdstat
Copy the running RAID setup to /etc/mdadm.conf
# mdadm –detail –scan >> /etc/mdadm.conf
Be sure to add a line ‘DEVICE partitions’ at the top of /etc/mdadm.conf if you want to define MD devices that span a whole disk instead of just a partition. Without this line, MD won’t be able to detect your drives as MD components at boot.
That’s it!
dinsdag 8 april 2008
Abonneren op:
Posts (Atom)