понедельник, 30 марта 2009 г.

Converting Fedora 10 single drive installation to RAID1

Look like there is no straight forward instructions regarding the topic. I used two of them

http://togami.com/~warren/guides/remoteraidcrazies/

http://m.linuxjournal.com/article/10217

I already installed mdadm package during the initial system setup, so I went directly to the step of copying partition table to the second (clean) disk (manual #2, Converting a Server to RAID1, 2nd step)

# sfdisk -d /dev/sda | sfdisk /dev/sdb
# fdisk /dev/sdb
> t
> 1
> fd
> t
> 2
> fd
> t
> 3
> fd
> w

I have 3 partitions (root, swap and synchronized with drbd), so I converted them all to raid fs type.

Then I created a raid 1 with single disks for all of my 3 partitions.

 

# mdadm -C /dev/md0 -n2 -l1 missing /dev/sdb1  # root
# mdadm -C /dev/md1 -n2 -l1 missing /dev/sdb2  # swap
# mdadm -C /dev/md2 -n2 -l1 missing /dev/sdb3  # drbd
# cat /proc/mdstat
# mdadm --detail --scan >> /etc/mdadm/mdadm.conf

 

As you can see I do everything like in the second manual. But now the most interesting part of this manipulations begins – you should boot from your newly created raid1.

I did everything like in the next step of the 2nd manual – copied the boot config and specified “root=/dev/md0” and (hd1,0) instead of (hd0,0).

Then the second manual suggests to rebuild initrd image with debian tool. But I don’t have it in fedora. So I followed instructions about creating initrd manually.

Unfortunately they didn’t help – my system couldn’t mount /dev/md0 device (“couldn’t mount /dev/root device” at the boot screen).

So, I googled and found old Russian article about doing the same sort of things, most of step in this article are outdated, but luckily there was a step that saved me

mkinitrd --with=raid1 --preload=raid1 --fstab=/mnt/md0/etc/fstab [image filename] [kernel version]

before that I mounted md0 raid drive to “/mnt/md0”, I also modified fstab on the raid disk – instead of local partitions I mounted raid ones (/dev/md0, /dev/md1).

Don’t forget also to change fstab on your original system – for some reasons grub could load partitions via their IDs after a reboot, so I couldn’t boot to any system.

Then I synchronized content from the /dev/sda1 to /dev/md0. installed grub onto both disks (see article #2) and used solution in the first article to boot into the second option once a time.

It finally did the trick – I stuck with the creation of initrd image – you have to specify new fstab, otherwise mkinitrd won’t know that your root partition is on the raid drive, thus initrd won’t mount raid at the very beginning, so grub won’t be able to load the kernel.

Once I booted from the raid drive I added the original one to the raid array and synchronized the array.

OK, so I will continue with creating of failover cluster, I need to configure drbd and heartbeat. Will let you know if I face any issues.

Комментариев нет:

Отправить комментарий