Next: 14 Obsolete RAID Procedures
Up: Redhat FAQ
Previous: 12 PPP
Contents
Subsections
Generally, system RAID sets will be built at install time but larger
RAID's - such as a RAID 10 for a database - may be built later.
In this examle I will build a RAID 10 using sda1, sdb1, sdc1, sde1,
sdf1, and sdg1.
- Check all the drives are partitioned. Repartition if necessary
$ sudo fdisk -l
Disk /dev/sda: 146.8 GB, 146815733760 bytes
255 heads, 63 sectors/track, 17849 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id
System
/dev/sda1 * 1 17849 143372061 fd
Linux raid autodetect
<etc>
- Create the RAID1 devices
$ sudo mdadm -create /dev/md11 -level=1 -chunk=1024
-raid-devices=2 /dev/sda1 /dev/sde1
$ sudo mdadm -create /dev/md12 -level=1 -chunk=1024
-raid-devices=2 /dev/sdb1 /dev/sdf1
$ sudo mdadm -create /dev/md13 -level=1 -chunk=1024
-raid-devices=2 /dev/sdc1 /dev/sdg1
- Create the RAID0 across the above RAID1's to createa RAID10
$ sudo mdadm -create /dev/md10 -level=0 -chunk=1024
-raid-devices=3 /dev/md11 /dev/md12 /dev/md13
- Format the new device
$ sudo mke2fs -j -L /mp001 /dev/md10
- Generate a new mdadm.conf
$ cd
$ echo 'DEVICE /dev/sd*[0-9]' >tt
$ sudo mdadm -examine -scan -config=tt >mdadm.conf
$ sudo cp mdadm.conf /etc/mdadm.conf
- By:
- Stephen Carville
- Rev:
- 09/01/2004
For illustration, assume drive /dev/sdh and /dev/sdi
make up a raid, /dev/sdi has failed and will be replaced by drive
/dev/sdj.
- Determine which drive has failed. this information can be inferred
from /proc/mdstat and mdadm
$ cat /proc/mdstat
$ sudo mdadm -D /dev/md0
- If any partitions on the failed drive were not removed by the system,
remove them
$ sudo mdadm -r /dev/md1 /dev/sdi2
- Partition the replacement drive like the failed drive. If any differences
are necessary, make the new partitions bigger
- If the replacement and failed drives have the same geometry, use sfdisk
to duplicate it
$ sudo sfdisk -d /dev/sdh >part
$ sudo sfdisk /dev/sdj <part
- If the hardware allows hot swapping, swap the new drive and the failed
drive. (This step can be skipped if desired but be sure to adjust
drive names below).
- Add the new drive partitins to the RAID. Be certain that you are adding
the correct partitions!
$ sudo mdadm -a /dev/md0 /dev/sdi1
$ sudo mdadm -a /dev/md1 /dev/sdi2
<etc>
- Wait for the drive to be completly restored. The sync process happens
in the background at about 500 to 600 Kilobytes per second.
- If possible, reboot to check that the new RAID is working correctly.
- Determine which drive has failed. this information can be inferred
from /proc/mdstat and mdadm
$ cat /proc/mdstat
$ sudo mdadm -D /dev/md0
- If any partiton on the failed drive were not removed by the system,
remove them
$ sudo mdadm -r /dev/md1 /dev/sdi2
- Dump the partition for the good drive
$ sudo sfdisk -l /dev/sdh
- If the replacement drive is the same geometry
$ sudo sfdisk -d /dev/sdh >part
- Replace the failed drive
- Partition the replacement drive like the failed drive using sfdisk
if possible. If any differences are necessary, make the new partitions
bigger.
- Add the new drive partitions to the RAID. Be certain that you are
adding the correct partitions!
$ sudo mdadm -a /dev/md0 /dev/sdi1
$ sudo mdadm -a /dev/md1 /dev/sdi2
<etc>
- Wait for the drive to be completly restored.
- If possible, reboot to check that the new RAID is working correctly.
This probably won't be necesary very often but when it is...
- Unmount the RAID drive. Do not forget to do this.
$ sudo umount /dev/md10
- Try stopping the RAID. This usually works.
$ sudo mdadm -stop /dev/md10
- Determine the partitions that make up up the RAID
$ sudo mdadm -D /dev/md10
- If the RAID is a set of other RAID drives - eg a RAID 10 then it
may be sufficient to destryteh superblock on the individual
RAID sets
$ sudo mdadm -zero-superblock /dev/md11
$ sudo mdadm -zero-superblock /dev/md12
$ sudo mdadm -zero-superblock /dev/md13
$ sudo reboot
- If the RAID is made up of physical partitions or the above does not
work, use fdisk change the partiton from type FD (Linux raid
autodetect) to type 83 (Linux) and reboot. Fdisk will complain
that it cannot update the partition table in the kernel but you can
ignore that.
Next: 14 Obsolete RAID Procedures
Up: Redhat FAQ
Previous: 12 PPP
Contents
2005-03-20