Friday, April 17, 2015

RAID Configuration


-         It depends on utility called mdadm (multiple disk administration)
-         I can use more than one hard disk and manage them as a compact unit called RAID device.
-         Go to VM tabe, add hard disks of the same size, and it should be the same size. Then reboot.
-         So we will have three hard disks sdb, sdc, sdd

Configuration Steps:
1-               fdisk –l
//it will show all hard disks with their already
//created partitions.
2-               fdisk –cu /dev/sdb
//c: makes sure that the partition label is mbr 
//u:disk spaces counter by sectors.
m:help
n:new partition
p:primary
1:partition number
fisrt sector: default
last sector:default
t: system id=fd(Liunex raid autodetect)
             //repeat this for the two other hard disks with the same conf.     
*mark: if the disk size it by TB, you should change the partition’s label type to GPT( parted, mklabel gpt)
*all partitions should have the same size.
*partition type should be RAID

3-               partprobe /dev/sdb1
partprobe /dev/sdc1
partprobe /dev/sdd1
// informs os about partition table changes on disk
//use partition without reboot
4-               man mdadm (manage MD devices) also known as linux sw RAID
5-               mdadm --create  /dev/md0 --level=5 –raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
6-               mdadm --detail /dev/md0
7-               watch cat /proc/mdstat
//shows RAID statistics
8-               mkfs.ext4 /dev/md0
//make file system to raid, now you are dealing with partitions through the md0 layer.
9-               mkdir /myriad
10-         mount /dev/md0 /my raid

11-         vi /etc/fstab
                             /dev/md0         /myraid             /ext4         defaults   0 0
12-         mount –a
13-         cp –r /etc/ /myraid/
cp –r /usr/ /myraid/
//we will try to write data on the array disk
            *mark: at raid 5 at least one hard disk that can be faulty.
14-         mdadm /dev/md0 –f /dev/sdc1
//we will fail a hard disk sdc
15-         cat /proc/mdstat
// sdc1 will be faulty and down
            *try to write data it will be written normally
16-         df –h
17-         mdadm /dev/md0 –r /dev/sdc1
//hot remove
18-         mdadm /dev/md0 –a /dev/sde1
//add new device to array
Normally Linux system doesn’t automatically remember components that are part of RAID. This info should be added to /etc/mdadm.conf.
19-         mdadm --detail --scan 
mdadm --detail /dev/md0
20-         mdadm --detail --scan > /etc/mdadm.conf
//append the conf. file