RedHat Linux: AS 3.0
Linux Kernel: 2.4
RAID Software : raidtools-1.00.3-7
# df -k <CR>
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda2 3526112 1530736 1816256 46% /
/dev/hda1 101018 9343 86459 10% /boot
/tmp 32768 0 32768 0% /dev/shm
#
List current partion ID on OS disk
# fdisk -l /dev/hda
Disk /dev/hda: 4320 MB, 4320862208 bytes
255 heads, 63 sectors/track, 525 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 459 3582495 83 Linux
/dev/hda3 460 524 522112+ 82 Linux swap
#
Change partion ID of 1st disk (OS disk) and 2nd disk to ÒLinux raid autodetectÓ type
# fdisk -l /dev/hda <CR>
Disk /dev/hda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 fd Linux raid autodetect
/dev/hda2 14 4610 36925402+ fd Linux raid autodetect
/dev/hda3 4611 4864 2040255 fd Linux raid autodetect
# fdisk -l /dev/hdc <CR>
Disk /dev/hdc: 40.0 GB, 40007761920 bytes
16 heads, 63 sectors/track, 77520 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 * 1 214 107824+ fd Linux raid autodetect
/dev/hdc2 215 73845 37110024 fd Linux raid autodetect
/dev/hdc3 73846 77520 1852200 fd Linux raid autodetect
#
Mirror OS disk as
/dev/md0 /dev/hda2 // /dev/hdc2 mounted as /
/dev/md1 /dev/hda1 // /dev/hdc1 mounted as /boot
/dev/md2 /dev/hda3 // /dev/hdc3 swap
Create /etc/raidtab with a failed disk which is the current mounted OS disk
# vi /etc/raidtab
# md0 is the root /
raiddev /dev/md0
raid-level 1
nr-raid-disks 2
chunk-size 64k
persistent-superblock 1
nr-spare-disks 0
device /dev/hdc2
raid-disk 0
device /dev/hda2
# raid-disk 1
failed-disk 1
#
#****************************************
# md1 is the /boot
#
raiddev /dev/md1
raid-level 1
nr-raid-disks 2
chunk-size 64k
persistent-superblock 1
nr-spare-disks 0
device /dev/hdc1
raid-disk 0
device /dev/hda1
failed-disk 1
# raid-disk 1
#
#************************************
# md2 is the swap
#
raiddev /dev/md2
raid-level 1
nr-raid-disks 2
chunk-size 64k
persistent-superblock 1
nr-spare-disks 0
device /dev/hdc3
raid-disk 0
device /dev/hda3
failed-disk 1
#raid-disk 1
#
#**************************************
# mkraid /dev/md0 <CR>
# mkraid /dev/md1 <CR>
# mkraid /dev/md2 <CR>
Note: At this step, the RAID devices md0, md1 and md2 only contain /dev/hdc disk
Create ext3 filesystem
# mke2fs -j /dev/md0 <CR>
# mke2fs -j /dev/md1 <CR>
Copy hda disk to hdc disk except the swap partition hda3
# mkdir /md0 /md1 <CR>
# mount /dev/md0 /md0 <CR>
# dump 0f - /dev/hda2 | (cd /md0 ; restore xf - ) <CR>
# mount /dev/md1 /md1 <CR>
# dump 0f - /dev/hda1 | (cd /md1 ; restore xf - ) <CR>
Note: Shall do the dump command at single user mode.
Create the initial ramdisk images on the RAID boot device /dev/md1
# mount /dev/md1 /boot <CR>
# mv initrd-2.4.21-4.EL.img initrd-2.4.21-4.EL.img.ORIG <CR>
# mv initrd-2.4.21-4.ELsmp.img initrd-2.4.21-4.ELsmp.img.ORIG <CR>
# mkinitrd initrd-2.4.21-4.EL.img initrd-2.4.21-4.EL <CR>
# mkinitrd initrd-2.4.21-4.ELsmp.img initrd-2.4.21-4.ELsmp <CR>
# grub <CR>
grub> device (hd0) /dev/hdc <CR>
grub> root (hd0,0) <CR>
grub> setup (hd0) <CR>
grub> quit <CR>
#
# vi /etc/fsftab
/dev/md0 / ext3 defaults 1 1
/dev/md1 /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/md2 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/sda /mnt/floppy auto noauto,owner,kudzu 0 0
# vi /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hda2
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Enterprise Linux AS (2.4.21-4.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.4.21-4.ELsmp ro root=/dev/md0 === > Change to /dev/md0
initrd /initrd-2.4.21-4.ELsmp.img
title Red Hat Enterprise Linux AS-up (2.4.21-4.EL)
root (hd0,0)
kernel /vmlinuz-2.4.21-4.EL ro root=/dev/md0
initrd /initrd-2.4.21-4.EL.img
#
# shutdown -r now <CR>
Update the /etc/raidtab to change failed-disk to raid-disk for /dev/hda
# vi /etc/raidtab
:
device /dev/hda2
raid-disk 1
:
device /dev/hda1
raid-disk 1
:
device /dev/hda3
raid-disk 1
Attach the /dev/hda disk to the RAID device
# raidhotadd /dev/md0 /dev/hda2 <CR>
# raidhotadd /dev/md1 /dev/hda1 <CR>
# raidhotadd /dev/md2 /dev/hda3 <CR>