Next: 15 Serial Ports
Up: Redhat FAQ
Previous: 13 Raid on Linux
Contents
Subsections
These procedure have been obsoleted for newer systems.
Redhat 7.0 to Redhat 7.2 upgrade with RAID 1 systems disks.
- 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.
- Boot the machine and log in as root or login and use sudo to become
root..
- Edit /etc/raidtab to mark all mirror 1 partitions that are to be upgraded
as failed-disk.
- Reboot to bring up the RAID in degraded mode. Login and become root.
- 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_]
- 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
- Mount the root partition mirror
# mount /dev/sdb2 /t
- 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.
- Shutdown and boot from the Redhat CD. When asked, select upgrade to
/dev/sdb.
- 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.
- Write boot information to /dev/sdb
- 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.
- Reboot from Boot Floppy 1.
This is the last point in the process where you can back out easily.
- The original RAID configuration should already exist in degraded mode.
You can double check with:
# cat /proc/mdstat
- Create new file systems on the RAID devices.
# mke2fs -j /dev/md1
# mke2fs -j /dev/md0
# mke2fs -j /dev/md2
- 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
- Create /proc and /tmp for the new file system
# mkdir /t/proc
# mkdir /t/tmp
- 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.
- 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
- 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.
- Reboot from Boot Floppy 2. At the lilio 'boot:' prompt type:
Boot: linux root=/dev/md0
- 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
- 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
- Change the 'failed-disk' entries in /etc/raidtab to 'raid-disk'.
- Add the partitions back into the RAID.
# raidhotadd /dev/md0 /dev/sdb2
# raidhotadd /dev/md1 /dev/sdb1
# raidhotadd /dev/md2 /dev/sdb3
- 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.
- 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
- Edit the two lilo.conf files to reflect the new kernel and initrd.
This usually means changing the ``image='' and ``initrd=''
lines.
- Run lilo using the newly edited configuration files
# lilo -C /etc/lilo.conf.sda
# lilo -C /etc/lilo.conf.sdb
- Reboot. If all went well, you will come up with an upgraded RAID1
system
- By:
- Stephen Carville
- Rev:
- 04/18/02
The easist way to do Raid 5 is during install. However, that is not
alway possible.
- Decide what disk will be in the Raid. Here I will use four drives:
sdb, sdc, sdd, sde.
- 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.
- 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
- Create the raid
# mkraid -force /dev/md0
- 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>
- 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.
- Make a file system on the raid set.
# mke2fs -f /dev/md0
- Mounting can be done in one of two ways.
- 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
- Second is to label the partition
# e2label /dev/md0 /mp001
- Then use that label to reference the partition in /etc/fstab
LABEL=/mp001 /mp001 ext3 defaults 1 2
- Finally, mount the new Raid drive
# mount /mp001
14.3 Setting up Raid 1 for Linux
- By:
- Stephen Carville
- Rev:
- 01/31/2002
- When setting up RAID1 for Linux install the operating system on the
second drive.
- Have at least two floppy drives on hand
- Here I assume two SCSI drives called /dev/sda and /dev/sdb installed
in a machine destined to be a web and ftp server.
- Use fdisk to partition the second drive appropriately. For example:
Table 1:
Example Partition Table
| Partition |
Size |
Mounted on
/dev/sdb1 |
|
- Make the /boot partition (/dev/sdb1) bootable.
- Install the OS
- Write boot information to the first partition on sdb
- 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.
- Reboot from the Boot Floppy 1 and log in as root.
- 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).
- When writing the partition table, watch the messages carefully. It
may be necessary to reboot the machine to properly change the partition
table.
- If necessary, reboot from Boot Floppy 1 and login as root.
- 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.
- 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
- 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>
- Next create file systems on the RAID devices
# mkfs /dev/md0
# mkfs /dev/md1
# mkfs /dev/md2
- 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
- Create /t/proc and /t/tmp
# mkdir /t/proc
# mkdir /t/tmp
- 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.
- 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
- 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
- Reboot from Boot Floppy 2. At the lilo 'boot:' prompt type:
Boot: linux root=/dev/md0
- 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
- 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
- If necessary, reboot from Boot Floppy 2 as described above. Is a reboot
is necessary, double check the partition table
# fdisk -l /dev/sdb
- 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.
- Add the new partitions to the RAID:
# raidhotadd /dev/md0 /dev/sdb2
# raidhotadd /dev/md1 /dev/sdb1
# raidhotadd /dev/md2 /dev/sdb3
- 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.
- 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
- 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.
- Run lilo on each of the newly created files
# lilo -C /etc/lilo.conf.sda
# lilo -C /etc/lilo.conf.sda
- 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
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
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: 15 Serial Ports
Up: Redhat FAQ
Previous: 13 Raid on Linux
Contents
2005-03-20