[Centos] raid mirroring on existing CentOS 4 installation?

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



> Before you buy anything, be aware of the fact that CentOS4 does not
> have "built-in" support for either 3ware or adaptec SATA RAID cards,
> In fact, it doesn't support many raid cards, at all.

> Your best best will be the LSI or MegaRaid cards.

> Also, if you read the digest version of this list, since the beginning
> of the month, there were quite a number of posts regarding Raid and
> CentOS4, including a few from me.

There is a 3ware module(s):

  /lib/modules/`uname -r`/kernel/drivers/scsi/3w-xxxx.ko
  /lib/modules/`uname -r`/kernel/drivers/scsi/3w-9xxx.ko


Meanwhile...

I wrote up the following procedure to setup LVM/mdadm RAID1 migrating
from a single disk to 2 NEW identical drives to become the mirror - you
can probably just retag the original drive as "Linux auto detect" and
skip the copying/cpio everything to a 2nd staging drive if you're
feeling brave - otherwise, current hdc will become hda and current hda
will become the mirrored hdc. This is cnp'd from HTML document -
plaintext formatting may vary. Have NOT tested this against 4.0 (works
in 3.x) :



It is assumed that system is booted off of /dev/hda where /dev/hdc is an
identical drive upon which a new boot disk will be constructed. In
addition; example layout :

Partition 	Filesystem 	Metadevice
/dev/hda1 	/boot 		/dev/md1
/dev/hda2 	/ 		/dev/md2
/dev/hda3 	swap 		/dev/md3
/dev/hda5 	/export/home 	/dev/md5

    * If you're adding a new disk that has a set of filesystems (and
e2fs labels) on it, you will need to clear the partition table before
installing it into a system, as the LABEL=/filesystem model gets easily
confused; e2label can be used to just erase labels. Remember if you
erase the labels, change /etc/grub/grub.conf and /etc/fstab to use
partition names, or you won't be able to reboot!

   1. Ensure the disks are of the same type/size; Note: identical disks
may have different geometry settings which must be resolved
          * sfdisk -sg /dev/hda; sfdisk -sg /dev/hdc
   2. Copy the partition table (and geometry) from current to new disk
          * sfdisk -d /dev/hda | sfdisk /dev/hdc
	or
          * sfdisk -d /dev/hda | sfdisk -C <cyl> -H <head> -S <sec> /dev/hdc
   3. Set the partition label on the new mirror drive to "Linux raid
autodetect" :
          * sfdisk -c /dev/hdc 1 fd
          * sfdisk -c /dev/hdc 2 fd
          * sfdisk -c /dev/hdc 3 fd
          * sfdisk -c /dev/hdc 5 fd
   4. Construct the RAID1 metadisk devices on each partition :
          * mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/hdc1
missing
          * mdadm --create /dev/md2 --level=1 --raid-devices=2 /dev/hdc2
missing
          * mdadm --create /dev/md3 --level=1 --raid-devices=2 /dev/hdc3
missing
          * mdadm --create /dev/md5 --level=1 --raid-devices=2 /dev/hdc5
missing
   5. Construct filesystems on metadisk devices :
          * mkfs -t ext3 /dev/md1
          * mkfs -t ext3 /dev/md2
          * mkfs -t ext3 /dev/md5
          * mkswap /dev/md3
   6. Copy filesystems from original to new mirror drive :
          * mkdir /mnt/new
          * mount /dev/md2 /mnt/new
          * cd /; find . -xdev | cpio -pmd /mnt/new
          * mount /dev/md1 /mnt/new/boot
          * cd /boot; find . -xdev | cpio -pmd /mnt/new/boot
          * mount /dev/md5 /mnt/new/export/home
          * cd /export/home; find . -xdev | cpio -pmd /mnt/new/export/home
   7. Update /etc/fstab file on new drive (/mnt/new/etc/fstab); replace
all LABEL=/ tags with /dev/md#
   8. Construct new initrd image which preloads the raid1 kernel module
          * RH73/9 env startraid=1 mkinitrd -f --preload=raid1
/mnt/new/boot/initrd-`uname -r`.img `uname -r`
                o RHEL/CentOS: can leave off the env startraid=1 part
                o repeat for any other bootable kernels on the system
   9. Update grub.conf file on new disk; remove all (hdX,0) references
and set the kernel root= option to the appropriate /dev/md device that's
the root filesystem :

      default=0
      timeout=10
      splashimage=/grub/splash.xpm.gz
      title Red Hat Linux (2.4.20-28.7smp)
         kernel /vmlinuz-2.4.20-28.7smp ro root=/dev/md1
         initrd /initrd-2.4.20-28.7smp.img


   10. Unmount the new disk: umount /mnt/md3; umount /mnt/md0; umount
/mnt/md1
   11. Run GRUB to setup bootloader :
          root (hd1,0); setup (hd1)
   12. Shutdown system, make new disk primary and check if it boots
(verify all root disk filesystems are mounted on /dev/mdX devices)

If all goes well, setup 2nd mirror disk (can recycle old boot disk) :

   1. Reset partition table (types and layout) :
          * sfdisk -d /dev/hda | sfdisk /dev/hdc
   2. Add the new mirror devices; monitor through /proc/mdstat :
          * mdadm --add /dev/md0 /dev/hdc1
          * mdadm --add /dev/md1 /dev/hdc2
          * mdadm --add /dev/md2 /dev/hdc3
          * mdadm --add /dev/md3 /dev/hdc5
   3. Setup GRUB loader on 2nd drive (can do this once /boot on /dev/md0
is finished) :
          root (hd1,0); setup (hd1)

    * Once all the mirrors are finished syncing up, you should be able
to swap drives and have the system reboot. Should a disk fail, you will
likely still have to physically remove it from the system (esp if IDE),
but the other drive should be intact. Use the last procedure above to
setup and reattach new mirror disk.


-ericb

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux