[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: converting running system to RAID-1

   I haven't tried this protocol yet (we are waiting for a
second IDE card) but I believe this should work for setting converting
an existing FC5 IDE drive to RAID-1 on two IDE drives. Does anyone
see any potential glitches. The only part I am uncertain on is the
steps where I have to edit grub.conf. Specifically I am unclear on
the fallover mechanism in terms of which drive it will read from
/boot off of? Also I assume I need to edit grub.conf on the second
drive before I do the setup of it in grub. Oh, the current partitions

df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda3             40631988  12381336  26153368  33% /
/dev/hda1               101086     18244     77623  20% /boot
/dev/hda2             10154020   2568816   7061084  27% /opt
/dev/shm                515976         0    515976   0% /dev/shm
/dev/hda6             96443344  55721576  35743628  61% /home

/sbin/sfdisk -d /dev/hda
# partition table of /dev/hda
unit: sectors

/dev/hda1 : start=       63, size=   208782, Id=83, bootable
/dev/hda2 : start=   208845, size= 20964825, Id=83
/dev/hda3 : start= 21173670, size= 83891430, Id=83
/dev/hda4 : start=105065100, size=207511605, Id= 5
/dev/hda5 : start=105065163, size=  8385867, Id=82
/dev/hda6 : start=113451093, size=199125612, Id=83

As root AFTER second IDE drive install on second IDE channel (not slave!)

1) Recreate current kernel with raid1 module preloaded (this will happen automatically once root
partition is raid). NOTE: This step is essential and you can not upgrade your again kernel before
completing the remaining steps.

cd /boot
cp initrd-2.6.16-1.2069_FC5smp.img initrd-2.6.16-1.2069_FC5smp.img.sav
/sbin/mkinitrd -f --preload raid1 /boot/initrd-2.6.16-1.2069_FC5smp.img 2.6.16-1.2069_FC5smp

2) duplicate the partitions of the first drive onto the second drive

/sbin/sfdisk -d /dev/hda | /sbin/sfdisk /dev/hdc

3) verify the partitions are the same with

/sbin/sfdisk -l /dev/hda
/sbin/sfdisk -l /dev/hdc

4) change partition Id's on second drive to fd for software RAID

/sbin/parted /dev/hdc set 1 raid on
/sbin/parted /dev/hdc set 2 raid on
/sbin/parted /dev/hdc set 3 raid on
/sbin/parted /dev/hdc set 5 raid on
/sbin/parted /dev/hdc set 6 raid on

Note that we don't touch hdc4 since it is the extended partition.
Also hdc5 is swap.

5) use '/sbin/sfdisk -l /dev/hdc' to verify that we have changed the
Id for the paritions to fd.

6) Now reboot to make sure that partition table reloads. This boot will
be from /dev/hda.

7) Create the md devices with...

/sbin/mdadm --create /dev/md0 --level 1 --raid-devices=2 missing /dev/hdc1
/sbin/mdadm --create /dev/md1 --level 1 --raid-devices=2 missing /dev/hdc2
/sbin/mdadm --create /dev/md2 --level 1 --raid-devices=2 missing /dev/hdc3
/sbin/mdadm --create /dev/md3 --level 1 --raid-devices=2 missing /dev/hdc5
/sbin/mdadm --create /dev/md4 --level 1 --raid-devices=2 missing /dev/hdc6

8) Check the status of the arrays with 'cat /proc/mdstat'/ They should show
raid1 active with _U and hdc*.

9) Make the md filesystems...

/sbin/mkfs.ext3 /dev/md0
/sbin/mkfs.ext3 /dev/md1
/sbin/mkfs.ext3 /dev/md2
/sbin/mkfs.ext3 /dev/md4

10) Make the md swap

/sbin/mkswap /dev/md3

11) Now copy the data from each old partition to its matching md partition

mount /dev/md2 /mnt/

mkdir /mnt/boot
mount /dev/md0 /mnt/boot

mkdir /mnt/opt
mount /dev/md1 /mnt/opt

mkdir /mnt/home
mount /dev/md4 /mnt/home

cd /mnt
tar -C / -clspf - . | tar -xlspvf -

cd /mnt/boot
tar -C /boot -clspf - . | tar -xlspvf -

cd /mnt/opt
tar -C /opt -clspf - . | tar -xlspvf -

cd /mnt/home
tar -C /home -clspf - . | tar -xlspvf -

12) Now backup and edit /boot/grub/menu.lst to have the changes below. 
Copy this over to /mnt/boot/grub just to be safe.


#fallback to md2 on hdc
fallback 1

title Fedora Core (2.6.16-1.2069_FC5smp) from hda1 as md2
        root (hd0,0)
        kernel /vmlinuz-2.6.16-1.2069_FC5smp ro root=/dev/md2 rhgb quiet
        initrd /initrd-2.6.16-1.2069_FC5smp.img

title Fedora Core (2.6.16-1.2069_FC5smp) from hdc1 as md2
        root (hd1,0)
        kernel /vmlinuz-2.6.16-1.2069_FC5smp ro root=/dev/md2 rhgb quiet
        initrd /initrd-2.6.16-1.2069_FC5smp.img

13) Now edit /mnt/etc/fstab to have...

/dev/md2                /                       ext3    defaults        1 1
/dev/md0            /boot                   ext3    defaults        1 2
/dev/md1              /opt                    ext3    defaults        1 2
/dev/devpts             /dev/pts                devpts  gid=5,mode=620  0 0
/dev/shm                /dev/shm                tmpfs   defaults        0 0
/dev/md4            /home                   ext3    defaults        1 2
/dev/proc               /proc                   proc    defaults        0 0
/dev/sys                /sys                    sysfs   defaults        0 0
/dev/md3        swap                    swap    defaults        0 0

14) Now reboot

15) Once booted from the md partitions on hdc we must setup grub again. Edit
the /boot/grub/conf first to have the root partition set to /dev/md2 for

root (hd1,0)
setup (hd1)

16) Reboot once more. This time you will come up with the boot loader off of thesecond (hdc) drive and not have to fallover to it

17) Now add missing slices using the partitions on the first drive...

/sbin/mdadm /dev/md0 -a /dev/hda1
/sbin/mdadm /dev/md1 -a /dev/hda2
/sbin/mdadm /dev/md2 -a /dev/hda3
/sbin/mdadm /dev/md3 -a /dev/hda5
/sbin/mdadm /dev/md4 -a /dev/hda6

18) Use mdstat to verify that the RAID is being built

cat /proc/mdstat

Tnanks in advance for any comments or advice. Also we really should have this
documented somewhere for Fedora.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]