next up previous contents
Next: 15 Serial Ports Up: Redhat FAQ Previous: 13 Raid on Linux   Contents

Subsections

14 Obsolete RAID Procedures

These procedure have been obsoleted for newer systems.

14.1 Upgrading RAID 1 system disks for Linux

Redhat 7.0 to Redhat 7.2 upgrade with RAID 1 systems disks.

14.1.1 Preparation

  1. Know your RAID configuration.
It is a good idea to print a copy of /etc/raidtab or /etc/mdadm.conf and /etc/fstab for reference.

14.1.2 Procedure

  1. Boot the machine and log in as root or login and use sudo to become root..
  2. Edit /etc/raidtab to mark all mirror 1 partitions that are to be upgraded as failed-disk.
  3. Reboot to bring up the RAID in degraded mode. Login and become root.
  4. Check that the RAID is running in degraded mode
    # cat /proc/mdstat 
    Personalities : [raid1] 
    read_ahead 1024 sectors  
    md1 : active raid1 sda1[0] 24000 blocks [1/2] [U_]  
    md0 : active raid1 sda2[0] 2104448 blocks [1/2] [U_]  
    md2 : active raid1 sda3[0] 6249216 blocks [1/2] [U_]
  5. Use fdisk to relabel the mirror 1 partitions (in this case on /dev/sdb) from type FD to type 83. Watch the messages carefully because it may be necessary to reboot the machine to update the partition table. If necessary, reboot and double check the partition types.
    # fdisk -l /dev/sdb
  6. Mount the root partition mirror
    # mount /dev/sdb2 /t
  7. Edit /t/etc/fstab to reflect a non RAID setup. This means at least changing the device name for all affected partitions. Other changes such as commenting out NFS drives and maybe changing the swap partitions may also be necessary.
  8. Shutdown and boot from the Redhat CD. When asked, select upgrade to /dev/sdb.
  9. Select the partitions you want to migrate from ext2 to ext3. Here / and /var were migrated. /boot was left as ext2. There is no reason /boot cannot be migrated as well.
  10. Write boot information to /dev/sdb
  11. Be certain to create a boot floppy. Label this 'Boot Floppy 1'. Do not skip this step because your system will probably not boot without it. You will need to create a second boot floppy later so write protect this one for safety.
  12. Reboot from Boot Floppy 1.

14.1.3 Recreating the RAID

This is the last point in the process where you can back out easily.

  1. The original RAID configuration should already exist in degraded mode. You can double check with:
    # cat /proc/mdstat
  2. Create new file systems on the RAID devices.
    # mke2fs -j /dev/md1 
    # mke2fs -j /dev/md0 
    # mke2fs -j /dev/md2
  3. Transfer everything from /dev/sdb to the degraded RAID. This involves mounting the RAID file systems and copying all the files from the boot disk to the RAID devices.
    # mkdir /t 
    # mount /dev/md0 /t 
    # mkdir /t/boot 
    # mount /dev/md1 /t/boot 
    # mkdir /t/var 
    # mount /dev/md1 /t/var
  4. Create /proc and /tmp for the new file system
    # mkdir /t/proc 
    # mkdir /t/tmp
  5. Now we have a replica of the current file system on the RAID 1 drives mounted underneath /t. Copy everything on the boot file systems to the RAID using the -a (-archive) option. eg:
    # cp -a /bin /t/. 
    # cp /boot/* /t/boot/. 
    etc...

    Be sure to skip pseudo-directories like /proc and there is no need to copy /tmp.

  6. Edit /t/etc/fstab to change the mount points: 
    /dev/md0   /      ext3  defaults  1 1  
    /dev/md1   /boot  ext2  defaults  1 2  
    /dev/md2   /var   ext3  defaults  1 2
  7. Make 'Boot Floppy 2' to boot from the RAID array (Replace 2.4.7-10smp with your kernel version):
    # mkbootdisk -mkinitrdargs ``-preload raid1'' 2.4.7-10smp

    Do not use Boot Floppy 1 for this! If you make a mistake later you will need #1 to recover.

14.1.4 Boot from RAID

  1. Reboot from Boot Floppy 2. At the lilio 'boot:' prompt type:
    Boot: linux root=/dev/md0
  2. This will bring up the machine with the new RAID. Use 'df' to check
    # df 
    Filesystem   1k-blocks      Used Available Use% Mounted on 
    /dev/md0       2071352   1448900    517232  74% / 
    /dev/md1         23239      4946     17093  23% /boot 
    /dev/md2       6151040    833140   5005440  15% /var
  3. Use fdisk to change the partition type on /dev/sdb back to type FD (Linux raid autodetect). Watch carefully when you write the partition table because it may be necessary to reboot. Reboot if necessary and check the partition table
    # fdisk -l /dev/sdb
  4. Change the 'failed-disk' entries in /etc/raidtab to 'raid-disk'.
  5. Add the partitions back into the RAID.
    # raidhotadd /dev/md0 /dev/sdb2 
    # raidhotadd /dev/md1 /dev/sdb1 
    # raidhotadd /dev/md2 /dev/sdb3
  6. Check in /proc/mdstat
    # cat /proc/mdstat 
    Personalities : [raid1] 
    read_ahead 1024 sectors 
    md1 : active raid1 sdb1[1] sda1[0] 
    24000 blocks [2/2] [UU]  
     
    md0 : active raid1 sdb2[1] sda2[0] 
    2104448 blocks [2/2] [UU] 
     
    md2 : active raid1 sdb3[1] sda3[0] 
    6249216 blocks [2/2] [UU]

    Unless the RAID partitions are small you will see a message like ``recovery=10%, finish=5.7 minutes'' which indicates the RAID is still updating the newly added drives. Let the recovery finish before proceeding.

  7. Create a system wide initrd image containing the modules you need to boot the system into RAID. Replace 2.47-10smp fro your kernel:
    # mkinitrd /boot/initrd-2.4.7-10smp -preload raid1 2.4.7-10smp
  8. Edit the two lilo.conf files to reflect the new kernel and initrd. This usually means changing the ``image='' and ``initrd='' lines.
  9. Run lilo using the newly edited configuration files
    # lilo -C /etc/lilo.conf.sda 
    # lilo -C /etc/lilo.conf.sdb
  10. Reboot. If all went well, you will come up with an upgraded RAID1 system

14.2 Setting up Raid 5 for Linux

By:
Stephen Carville
Rev:
04/18/02
The easist way to do Raid 5 is during install. However, that is not alway possible.

  1. Decide what disk will be in the Raid. Here I will use four drives: sdb, sdc, sdd, sde.
  2. Partition the drives as needed setting any Raid partitions to type fd (Linux raid autodetect).
    Usually each drive will be one big partition but it is sometimes necessary to use only part of a drive in a Raid 5 array. Do not have two parts of the array on the same drive. That is begging for disaster.
  3. Add to /etc/raidtab:
    raiddev               /dev/md0 
    raid-level            5 
    nr-raid-disks         4 
    chunk-size            64k 
    persistent-superblock 1 
    nr-spare-disks        0 
       device            /dev/sdb1 
       raid-disk         0 
       device            /dev/sdc1 
       raid-disk         1 
       device            /dev/sdd1 
       raid-disk         2 
       device            /dev/sde1 
       raid-disk         3
  4. Create the raid
    # mkraid -force /dev/md0
  5. Check your work in /proc/mdstat:
    # cat /proc/mdstat 
    Personalities : [raid5]  
    read_ahead 1024 sectors  
    md0 : active raid5 sde1[3] sdd1[2] sdc1[1] sdb1[0]  
    215045760 blocks level 5, 64k chunk, algorithm 0 [4/4] [UUUU]  
    unused devices: <none>
  6. Unless this is a very small raid, you will see a line like:
    [==>..................] resync = 11.6% (2425812/143363840) finish=120.0min speed=14227K/sec
    This just means the system is building the raid. Wait until this is done before proceeding.
  7. Make a file system on the raid set.
    # mke2fs -f /dev/md0

14.2.1 Mounting the new file system

  1. Mounting can be done in one of two ways.

    1. First is to just add a line into /etc/fstab for the new partition and the mount point
      /dev/md0        /mp001    ext3    defaults    1 2
    2. Second is to label the partition
      # e2label /dev/md0 /mp001
    3. Then use that label to reference the partition in /etc/fstab
      LABEL=/mp001    /mp001    ext3    defaults    1 2
  2. Finally, mount the new Raid drive
    # mount /mp001


14.3 Setting up Raid 1 for Linux

By:
Stephen Carville
Rev:
01/31/2002

14.3.1 Initial Install

  1. When setting up RAID1 for Linux install the operating system on the second drive.
  2. Have at least two floppy drives on hand
  3. Here I assume two SCSI drives called /dev/sda and /dev/sdb installed in a machine destined to be a web and ftp server.
  4. Use fdisk to partition the second drive appropriately. For example:


    Table 1: Example Partition Table
    Partition Size Mounted on
    /dev/sdb1


  5. Make the /boot partition (/dev/sdb1) bootable.
  6. Install the OS
  7. Write boot information to the first partition on sdb
  8. Be certain to create a boot floppy. Label it 'Boot Floppy 1'. Do not forget this part: Your system probably will not boot yet without this boot floppy. Write protect this floppy disk for safety.

14.3.2 Creating the RAID

  1. Reboot from the Boot Floppy 1 and log in as root.
  2. Use fdisk to partition /dev/sda exactly the same as /dev/sdb. Use fdisk -l /dev/sdb if you need to see the partitions on sdb. The only difference here is that the type for all partitions except swap will be of type Linux raid autodetect (hex fd) instead of Linux (hex 83).
  3. When writing the partition table, watch the messages carefully. It may be necessary to reboot the machine to properly change the partition table.
  4. If necessary, reboot from Boot Floppy 1 and login as root.
  5. Create a raidtab file describing the raid configuration. Here we trick the system into believing /dev/sdb is offline by labeling all of its partitions as ``failed-disk''. See Section 14.3.5 for a sample raidtab file.
  6. Make the RAID devices with mkraid. You will have to use the force option to do this 
    # mkraid -force /dev/md0 
    # mkraid -force /dev/md1 
    # mkraid -force /dev/md2
  7. Check your work with /proc/mdstat. Because one disk is marked as failed you should see something like: 
    # cat /proc/mdstat 
    Personalities : [raid1]  
    read_ahead 1024 
    md1 : active raid1 sda1[0] 24000 blocks [1/2] [U_] 
    md0 : active raid1 sda2[0] 2104448 blocks [1/2] [U_] 
    md2 : active raid1 sda3[0] 6249216 blocks [1/2] [U_] 
    unused devices: <none>
  8. Next create file systems on the RAID devices 
    # mkfs /dev/md0 
    # mkfs /dev/md1 
    # mkfs /dev/md2
  9. Transfer the operating system to the raid drives. This involves mounting the new filesystems and copying all the files from the boot disk to the raid devices. On this system. /dev/md0 will become /, /dev/md1 will become /boot, and /dev/md2 will become /var. 
    # mkdir /t 
    # mount /dev/md0 /t 
    # mkdir /t/boot 
    # mount /dev/md1 /t/boot 
    # mkdir /t/var 
    # mount /dev/md2 /t/var
  10. Create /t/proc and /t/tmp
    # mkdir /t/proc 
    # mkdir /t/tmp
  11. Now we have a RAID 1 replica of the boot file system mounted underneath /t. Copy the directories on the boot file system one at a time to the RAID using the -a (-archive) option, eg: 
    # cp -a /bin /t/.

    Be sure to skip copying any pseudo-directories like /proc.

  12. Edit /t/etc/fstab to change the mount devices for /, /boot/ and /var: 
    /dev/md0   /      ext2  defaults  1 1 
    /dev/md1   /boot  ext2  defaults  1 2 
    /dev/md2   /var   ext2  defaults  1 2
  13. Now make Boot Floppy 2 to boot from the RAID array (Replace ``2.2.16-22'' with your kernel version number): 
    # mkbootdisk -mkinitrdargs ``-preload raid1'' 2.2.16-22 
    Do not use boot floopy #1 for this! If you make an error in the next step, you will need #1 to recover

14.3.3 First Boot from RAID

  1. Reboot from Boot Floppy 2. At the lilo 'boot:' prompt type: 
    Boot: linux root=/dev/md0
  2. This should bring up the machine with the RAID as a replacement for the original /dev/sdb drives. Log in as root and use 'df' to check: 
    # df 
    Filesystem  1k-blocks    Used    Available  Use% Mounted on 
    /dev/md0      2071352  357032      1609100    19%   / 
    /dev/md1        23239    6473        15566    30%   /boot 
    /dev/md2      6151040    9780      5828800     1%   /var

14.3.4 Making it All Bootable

  1. Use fdisk to change the partition type on /dev/sdb from Linux (83) to Linux raid autodetect (fd). Watch carefully when you write the new partition table because it may be necessary to reboot
  2. If necessary, reboot from Boot Floppy 2 as described above. Is a reboot is necessary, double check the partition table
    # fdisk -l /dev/sdb
  3. Change the 'failed-disk' entries in /etc/raidtab to 'raid-disk'. This lets the system know the drive can be used as part of the RAID.
  4. Add the new partitions to the RAID: 
    # raidhotadd /dev/md0 /dev/sdb2 
    # raidhotadd /dev/md1 /dev/sdb1 
    # raidhotadd /dev/md2 /dev/sdb3
  5. Check your work in /proc/mdstat 
    # cat /proc/mdstat  
    Personalities : [raid1]  
    read_ahead 1024 sectors  
    md1 : active raid1 sda1[0] sdb1[1] 24000 blocks [2/2] [UU] 
    md0 : active raid1 sda2[0] sdb2[1] 2104448 blocks [2/2] [UU] 
    md2 : active raid1 sda3[0] sdb3[1] 6249216 blocks [2/2] [UU] 
    unused devices: <none>

    Unless the RAID partitions are small, you may see a message like ``recovery=10%, finish=5.7 minutes'' which indicates the newly added drives are being updated. Let the recovery finish before proceeding. On large drives this can take a while so be patient.

  6. Create a system wide initrd image containing the modules needed to boot the system into RAID 1. Replace 2.2.16-22 with your kernel version number. 
    # mkinitrd /boot/initrd-2.2.16-22.img -preload raid1 2.2.16-22
  7. Create two lilo files, one for each drive. See example 14.3.6. The only difference between these two files will usually be the 'boot=' entry.
  8. Run lilo on each of the newly created files 
    # lilo -C /etc/lilo.conf.sda 
    # lilo -C /etc/lilo.conf.sda
  9. Remove the floppy, any CDROM, and reboot. If all went well, you should come up in a RAID enabled machine.


14.3.5 Example /etc/raidtab


raiddev /dev/md0
    raid-level            1   
    nr-raid-disks         2
    chunk-size            32
    nr-spare-disks        0
    persistent-superblock 1    
    device                /dev/sda2
    raid-disk             0
    device                /dev/sdb2
    failed-disk           1

raiddev /dev/md1
    raid-level            1
    nr-raid-disks         2
    chunk-size            32
    nr-spare-disks        0
    persistent-superblock 1
    device                /dev/sda1
    raid-disk             0
    device                /dev/sdb1
    failed-disk           1

raiddev /dev/md2
    raid-level            1
    nr-raid-disks         2
    chunk-size            32
    nr-spare-disks        0
    persistent-superblock 1
    device                /dev/sda3
    raid-disk             0
    device                /dev/sdb3
    failed-disk           1


14.3.6 LILO Confgurations

14.3.6.1 /etc/lilo.conf.sda


boot=/dev/sda1
disk=/dev/md0
partition=/dev/md1
map=/boot/map
install=/boot/boot.b
timeout=50
prompt 
default=linuxRAID

image=/boot/vmlinuz-2.2.16-22
   label=linuxRAID
   initrd=/boot/initrd-2.2.16-22.img
   read-only
   root=/dev/md0

14.3.6.2 /etc/lilo.conf.sdb


boot=/dev/sdb
disk=/dev/md0
partition=/dev/md1
map=/boot/map
install=/boot/boot.b
timeout=50
prompt
default=linuxRAID

image=/boot/vmlinuz-2.2.16-22
    label=linuxRAID
    initrd=/boot/initrd-2.2.16-22.img
    read-only
    root=/dev/md0


next up previous contents
Next: 15 Serial Ports Up: Redhat FAQ Previous: 13 Raid on Linux   Contents
2005-03-20