RAID allows an administrator to form an array of several hard drives into one logical drive recognized as one drive by the operating system. It also spreads the data stored over the array of drives to decrease disk access time and accomplish data redundancy. The data redundancy can be used to recover data should one of the hard drives in the array crash.
RAID level 0, or striping,
Means that data is written across all hard drives in the array to accomplish the fast disk performance. No redundancy is used, so the size of the logical RAID drive is equal to the size of all the hard drives in the array. Because there is no redundancy, recovering data from a hard drive crash is not possible through RAID.
RAID level 1, or mirroring,
Means that all data is written to each disk in the array, accomplishing redundancy. The data is “mirrored” on a second drive. This allows for easy recovery should a disk fail. However, it does mean that, for example, if there are two disks in the array, the size for the logical disk is size of the smaller of the two disks because data must be mirrored to the second disk.
RAID level 5
Combines striping and parity. Data is written across all disks as in RAID 0, but parity data is also written to one of the disks. Should a hard drive failure occur, this parity data can be used to recover the data from the failed drive, including while the data is being accessed and the drive is still missing from the array.
RAID level 6
Data is written across all disks as in RAID 5, but two sets of parity data is calculated. Performance is slightly worse than RAID 5 because the extra parity data must be calculated and written to disk. RAID 5 allows for recovery using the parity data if only one drive in the array fails. Because of the dual parity, RAID 6 allows for recovery from the failure of up to two drives in the array.
In real life we never create raid on same hard disk. But its exam and examiner is not going to provide you three separate hard disk so you should be able to create three raid partition on same physical hard disk.
To create raid partition we will use fdisk utility.
Execute fdisk command with -l switch it will show hard disk mount point
[root@localhost`]# fdisk -l
Check the output for hard disk mount point. Use that mount point with fdisk command. My hard disk is mounted in /dev/sda so I am using it with fdisk command. If output of above command is different for you then use that mount point. you should use the proper hard disk option whatever you receive in the output of above command, for example it could be hdd sdb
[root@localhost`]# fdisk /dev/sda
Create a new partition and assign file type to raid
Command (m for help)n
First cylinder (1543-2610, deaults 1543):
press enter Using deafults value 1543 Last cylender ..............): +100M
Now create two more partition repeating the same process don't forget to save with w command.
Inform kernel about this change by partprobe commands and verify with fdisk -l commands
Okey now you have 3 raid partitions and Linux will treat these partition same as three physical hard disks. You can create raid device with these partitions
Create raid 5 device with these partitions
Now format this newly created md0 raid device
To use this device you must have specify mount point. we are going to use this raid device on /data directory. So create a /data directory and mount md0 on it.
This way will mount temporary. To permanently mount make its entry in /etc/fstab file.
At this point you have successfully created a raid device md0 and permanently mounted it on /data. In our next article we would add new hard disk in raid device and remove faulty media from raid devices.
Using cat /proc/mdstat is the fastest, simplest indication of the health and status of the RAID arrays. If there are no RAID arrays on the system, the output of the command would return output like this:
[root@sujeet~]# cat /proc/mdstat
Personalities :unused devices: <none>
Removing a RAID Device
To remove an existing RAID device, first deactivate it by running the following command as root
:
mdadm
--stop
raid_device
Once deactivated, remove the RAID device itself:
mdadm
--remove
raid_device
Finally, zero super blocks on all devices that were associated with the particular array:
mdadm
--zero-superblock
component_device…
Example 6.5. Removing a RAID device
Assume the system has an active RAID device, /dev/md3
, with the following layout .
~]# mdadm --detail /dev/md3 | tail -n 4
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
2 8 33 2 active sync /dev/sdc1
In order to remove this device, first stop it by typing the following at a shell prompt:
~]# mdadm --stop /dev/md3
mdadm: stopped /dev/md3
Once stopped, you can remove the /dev/md3
device by running the following command:
~]# mdadm --remove /dev/md3
Finally, to remove the super blocks from all associated devices, type:
~]# mdadm --zero-superblock /dev/sda1 /dev/sdb1 /dev/sdc1