RAID - redundant array of inexpensive disks
RAID basics most common: RAID 0, 1, 5 and in some cases 1+0 (10)
RAID 0 - "disk striping." - written to more than two disks - faster writes/reads - NO fault tolerance
RAID 1 - "disk mirroring." - duplicates drive, cuts capacity in have - excellent fault tolerance.
RAID 5 - distributes data across 3 or more disks with parity bits. hot swappable. slower writes, faster reads - very common
RAID 6 - like RAID 5 but uses one more parity block, two disks can fail, slower writes, faster reads - not as common
RAID 10 or RAID 1+0 - combination of RAID 1 and 0. stripe and mirror - fast and fault tolerant - twice as many disks needed
OTHER RAID TYPES:
RAID 2 is similar to RAID 5, striping occurs at the bit-level. expensive (requires 10 disks or more) and gives poor performance with some disk I/O operations.
RAID 3 is similar to RAID 5, has a dedicated parity drive. used for specialized applications - rarely used.
RAID 4 disk striping at the byte level, rather than at the bit-level as in RAID 3. - rarely used.
RAID 7 is a proprietary level of RAID owned by the now-defunct Storage Computer Corporation.
RAID 0+1 is a mirrored array with segments that are RAID 0 arrays.
1. Create a new RAID array
mdadm --create is used to create a new array:
--> mdadm --create --verbose /dev/md0 --level=1 /dev/sda1 /dev/sdb2
compact notation:
--> mdadm -Cv /dev/md0 -l1 -n2 /dev/sd[ab]1
2. /etc/mdadm.conf - main configuration file
/etc/mdadm.conf or
/etc/mdadm/mdadm.conf (on debian)
UPDATE file after RAID creation by:
--> mdadm --detail --scan >> /etc/mdadm.conf
Debian: mdadm --detail --scan >> /etc/mdadm/mdadm.conf
3. Remove a disk from an array
A drive must be failed before it can be removed from the array.
It can be in a failed state because of a fault - remove it. Or
Fail it using: --> mdadm --fail /dev/md0 /dev/sda1
then remove it: --> mdadm --remove /dev/md0 /dev/sda1
Single command using:
--> mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sda1
4. Add a disk to an array
add or replace a new disk to an array --> mdadm --add /dev/md0 /dev/sdb1
5. Status of the RAID arrays
check the status: --> cat /proc/mdstat or,
--> mdadm --detail /dev/md0
The output of this command will look like:
--> cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]
md1 : active raid1 sdb3[1] sda3[0]
19542976 blocks [2/2] [UU]
md2 : active raid1 sdb4[1] sda4[0]
223504192 blocks [2/2] [UU]
both drives are in use and working –
Failed drive shows as F
degraded array will miss the 2nd disk
Monitor the status of a RAID rebuild using watch:
watch cat /proc/mdstat
6. Stop and delete a RAID array
To completely remove a raid array we stop if first, then remove it:
--> mdadm --stop /dev/md0
--> mdadm --remove /dev/md0
and then we can delete the superblock from the individual drives:
--> mdadm --zero-superblock /dev/sda
In using RAID 1 arrays, we create identical partitions on both drives
so we can copy the partitions from sda to sdb by using sfdisk:
--> sfdisk -d /dev/sda | sfdisk /dev/sdb
This "dumps" the partition table of sda on sdb, removing existing partitions on sdb... without warning.
mdadm help info
to install: (SuSE has it installed by default, if not: zypper install mdadm)
# yum install mdadm [on RedHat systems]
# apt-get install mdadm [on Debain systems]
--> man mdadm | col -b | grep -v ^$ | tee -a man.mdadm.txt
--> mdadm --help
see also: https://raid.wiki.kernel.org/index.php/RAID_setup
RAID 0 setup using mdadm - 2 disks
RAID-0:
--> mdadm --create --verbose /dev/md0 --level=stripe --raid-devices=2 /dev/sdb6 /dev/sdc5
RAID 1 setup using mdadm - 2 disks
RAID-1:
--> mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1
RAID 1 setup using mdadm - 2 disks with a spare
Add a spare disk:
--> mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1 --spare-devices=1 /dev/sdd1
Check the /proc/mdstat file to see the status of the mirror.
RAID 5 setup using mdadm - 3 disks with a spare
--> mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1 --spare-devices=1 /dev/sde1
saving RAID configuration
MUD: (MUD = Mint, Ubuntu, or Debian)
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
Others (check your distribution's documentation):
mdadm --detail --scan >> /etc/mdadm.conf
|