RAID-1 configuration and management
RAID-1 configuration via Kickstart
(Under construction) How to change the Kickstart file to define RAID-1
The following examples uses two serial ATA disks (/dev/sda and /dev/sdb) with four partitions (/boot, /, swap and /tmp), each in RAID-1 configuration:
part raid.01 --size=128 --ondisk=sda part raid.02 --size=8192 --ondisk=sda part raid.03 --size=3072 --ondisk=sda part raid.04 --size=512 --ondisk=sda part raid.05 --size=128 --ondisk=sdb part raid.06 --size=8192 --ondisk=sdb part raid.07 --size=3072 --ondisk=sdb part raid.08 --size=512 --ondisk=sdb raid /boot --level=RAID1 --device=md0 --fstype=ext2 raid.01 raid.05 raid / --level=RAID1 --device=md1 --fstype=ext3 raid.02 raid.06 raid swap --level=RAID1 --device=md2 --fstype=swap raid.03 raid.07 raid /tmp --level=RAID1 --device=md3 --fstype=ext3 raid.04 raid.08
Restoring data on a new disk
OK, so there are two disks in a RAID-1 (mirror) configuration. What to do if on of them dies?
Well, all data are still available on the other disk, so they can be restored when a new disk is placed. The following steps show how to restore the data:
0. Do not reboot the machine! A reboot may change the drive names (e.g., /dev/sdb becoming /dev/sda) and hang the machine if it cannot find the boot loader grub.
1. Remove the partitions of the defect disk from the RAID configuration:
mdadm /dev/mdX -r /dev/sdYZ (X=0,1,2,... Y=a,b,c,... Z=1,2,3,...)
For example,
mdadm /dev/md0 -r /dev/sdb1
to remove partition 1 on disk sdb from raid device md0.
2. Replace the bad disk by a fresh one. Do not reboot the machine!
3. Rescan the SCSI bus for new devices. Use the script
/usr/local/bin/rescan-sci-bus.sh
(if installed from rpm), or download it from:
http://stal.nikhef.nl/scripts/rescan-scsi-bus.sh
4. Now the partition table should be created on the new disk. Use the following command to clone the partition table of existing disk sdX to the new disk sdY:
sfdisk -d /dev/sdX | \ sed -e s/sdX/sdY/ | \ sdisk /dev/sdY
(using
X=a,b,c,..
and
Y=a,b,c,...
, X different from Y).
5.