What is RAID in Linux and How to configure RAID in Linux

RAID in Linux

1. What is RAID? What is the use of the RAID and how many types of RAIDs available?

RAID stands for Redundant Array of Independent Disks, which is a technology that combines multiple physical hard drives into a logical unit to improve performance, data reliability, or both.
There are several types of RAID configurations, each with its own advantages and disadvantages. For example, RAID 0 provides improved performance by striping data across multiple disks, but does not provide any data redundancy, meaning that if one disk fails, all data will be lost. On the other hand, RAID 1 mirrors data on two or more disks, providing redundancy at the expense of storage capacity.
RAID technology is commonly used in servers, data centers, and other applications that require high performance and data reliability.

{getToc} $title={Table of Contents}

There are mainly two types of RAIDs available.

(i) Hardware RAID (Depends on vendors and is also more expensive)
(ii) Software RAID (Does not depend on vendors and is less expensive when compared to Hardware RAID and also it is maintained by the system administrator only.

2. How many types of software RAIDs are available and their requirements?

(i) RAID - 0 ---- Stripping ---- Minimum 2 disks required
(ii) RAID - 1 ---- Mirroring ---- Minimum 2 disks required
(iii) RAID - (1+0) ---Mirroring + Stripping ---- Minimum 4 disks required
(iv) RAID - (0+1) --- Stripping + Mirroring ---- Minimum 4 disks required
(v) RAID - 5 ---- Stripping with parity ---- Minimum 3 disks required

3. How to configure RAID - 0 in Linux?

  • To configure RAID - 0, a minimum of 2 disks are required and the partition id is "fd".
  • Reading and writing are very fast. So, it produces high performance.
  • If one disk is failed we cannot recover the data.
  • So, there is no redundancy and fault tolerance in RAID - 0.

Example: For example, if the data is 1, 2, 3, 4, 5, and 6 then...

 

RAID Disk

If the Disk - 1 is /dev/sdb and the Disk - 2 is /dev/sdc then configure RAID - 0
To create the RAID-0 using disk-1 (/dev/sdb) and disk-2 (/dev/sdc).
# mdadm -Cv /dev/md0 -n 2 /dev/sdb /dev/sdc -l 0
To check if the RAID-0 is created or not.
# cat /proc/mdstat
To create an ext4 file system on the RAID-0.
# mkfs.ext4 /dev/md0
To create the mount point for the RAID-0.
# mkdir /mnt/raid0
To mount the RAID-0 on the mount point.
# mount /dev/md0 /mnt/raid0
To see the details of the RAID-0 partition.
# mdadm -D /dev/md0
To manually fail the disk /dev/sdb.
# mdadm /dev/md0 -f /dev/sdb
To remove the failed disk /dev/sdb.
# mdadm /dev/md0 -r /dev/sdb
To add a new disk /dev/sdd in place of the failed disk.
# mdadm /dev/md0 -a /dev/sdd
To unmount the RAID-0 file system.
# umount /mnt/raid0
To stop the RAID-0 volume.
# mdadm --stop /dev/md0
To add a third disk (/dev/sde) to the RAID-0 volume.
# mdadm /dev/md0 --add /dev/sde
To grow the RAID-0 file system.
# mdadm --grow /dev/md0 --raid_device=3

4. How to configure RAID - 1 in Linux?

  • To configure RAID - 1, a minimum of 2 disks are required and the partition id is "fd".
  • In this, the same data will be written on 2 disks ie., an exact copy on both disks.
  • If one disk is failed we can recover the data from another disk.
  • So, there is high availability, redundancy, and fault tolerance in RAID - 1.
  • In this writing, speed is slow compared to RAID - 0.

Example: For example, if the data is 1, 2, 3, 4, 5, and 6 then...

RAID Disk2

 

If the Disk - 1 is /dev/sdb, the Disk - 2 is /dev/sdc and Disk - 3 is /dev/sddthen,

If the Disk - 1 is /dev/sdb, the Disk - 2 is /dev/sdc and Disk - 3 is /dev/sddthen

To create a RAID-5 using disks disks - 1, 2, and 3 - /dev/sdb, /dev/sdc, and /dev/sdd:
mdadm -Cv /dev/md0 -n 2 /dev/sdb /dev/sdc /dev/sdd -l 5

This command creates a new RAID-5 array named /dev/md0 using 2 disks (-n 2) /dev/sdb and /dev/sdc with a RAID level of 5 (-l 5). The -v option is used to display verbose output during the creation of the RAID array.

To check if the RAID-5 is created or not:
cat /proc/mdstat

This command displays the current status of all software RAID devices, including /dev/md0, which was created in the previous step.

To create an ext4 file system on the RAID-5:
mkfs.ext4 /dev/md0

This command creates an ext4 file system on the newly created /dev/md0 device.

To create a mount point for the RAID-5:
mkdir /mnt/raid5

This command creates a new directory named /mnt/raid5 that will be used as the mount point for the RAID-5.

To mount the RAID-5 on the mount point:
mount /dev/md0 /mnt/raid5

This command mounts the /dev/md0 device to the /mnt/raid5 mount point.

To see the details of the RAID-5 partition:
mdadm -D /dev/md0

This command displays the detailed information about the /dev/md0 device, including its RAID level, the number of devices in the array, and their status.

To manually fail a disk:
mdadm /dev/md0 -f /dev/sdb

This command fails the disk /dev/sdb in the /dev/md0 array. The -f option is used to force the failure of the disk.

To remove the failed disk:
mdadm /dev/md0 -r /dev/sdb

This command removes the failed disk /dev/sdb from the /dev/md0 array.

To add a new disk in place of the failed disk:
mdadm /dev/md0 -a /dev/sde

This command adds the new disk /dev/sde to the /dev/md0 array in place of the failed disk /dev/sdb.

To unmount the RAID-5 file system:
umount /mnt/raid5

This command unmounts the /mnt/raid5 mount point.

To stop the RAID-5 volume:
mdadm --stop /dev/md0

This command stops the /dev/md0 RAID-5 volume.

To add a fourth disk to the RAID-5 volume:
mdadm /dev/md0 --add /dev/sdf

This command adds the fourth disk /dev/sdf to the /dev/md0 RAID-5 volume.

To grow the RAID-5 file system to include the fourth disk:
mdadm --grow /dev/md0 --raid-device=4

This command grows the RAID-5 file system

5. How to configure RAID - 5 in Linux?

  • To configure RAID - 5, minimum 3 disks are required and the partition id is "fd".
  • In every disk approximately 25 - 30% of space is reserved for parity.
  • Reading and writing is very fast. So, it produces high performance.
  • This is used Stripping with parity concept.
  • if one disk is failed we can recover the data using remaining two disks and parity.
  • If two disks are failed, then we cannot recover the data.
  • So, there is no redundancy and fault tolerance in RAID - 5. Example : For example if the data is 1, 2, 3, 4, 5 and 6 then ....
To create RAID-5 using disks /dev/sdb and /dev/sdc:
mdadm -Cv /dev/md0 -n 2 /dev/sdb /dev/sdc -l 5
To check the RAID-5 creation status:
cat /proc/mdstat
To create an ext4 file system on the RAID-5:
mkfs.ext4 /dev/md0
To create a mount point for the RAID-5:
mkdir /mnt/raid5
To mount the RAID-5 on the mount point:
mount /dev/md0 /mnt/raid5
To see the details of the RAID-5 partition:
mdadm -D /dev/md0
To manually fail the disk:
mdadm /dev/md0 -f /dev/sdb
To remove the failed disk:
mdadm /dev/md0 -r /dev/sdb
To add a new disk in place of the failed disk:
mdadm /dev/md0 -a /dev/sde
To unmount the RAID file system:
umount /mnt/raid5
To stop the RAID-5 volume:
mdadm --stop /dev/md0
To add a fourth disk to the RAID-5 volume:
mdadm /dev/md0 --add /dev/sdf
To grow the RAID-5 file system:
mdadm --grow /dev/md0 --raid_device=4

6. What are the main advantages of RAID - 5

RAID - 5 uses Stripping with parity and requires only three disks. Because of Stripping the data reading and writing will be fast. And by using parity we can recover the data if one of the three disks failed. So, the main advantage of RAID-5 we can get fast writing, reading, and also redundancy fault tolerance at less expensive.

7. I have four disks each 1TB in RAID - (1+0). So, total how much disk space can I utilize in that

RAID - (1+0)?

RAID - (1+0) means Mirroring + Stripping. It requires 4 disks, ie., 2 disks for mirroring and the remaining 2 disks for stripping. And 5 - 10% of disk space is used for superblock information. So, finally we can utilize 2TB - 2TB X 10% disk space in that RAID - (1+0).

8. If two disks failed in RAID - (1+0), can we recover the data?

The RAID - (1+0) requires minimum 4 disks and it uses Mirroring + Stripping. If one disk is failed we can recover the data, but if two disks are failed we cannot recover the data.

9. How many types of disk space issues can we normally get?

(i) Disk is full.
(ii) Disk is failing or failed.
(iii) File system corrupted or crashed.
(iv) O/S is not recognizing the remote luns when scanning, ...etc.,

Was this article of use to you? Post your insightful thoughts or recommendations in the comments section if you don't find this article to be helpful or if you see any outdated information, a problem, or a typo to help this article better.

Jay

I love keeping up with the latest tech trends and emerging technologies like Linux, Azure, AWS, GCP, and other cutting-edge systems. With experience working with various technology tools and platforms, I enjoy sharing my knowledge through writing. I have a talent for simplifying complex technical concepts to make my articles accessible to all readers. Always looking for fresh ideas, I enjoy the challenge of presenting technical information in engaging ways. My ultimate aim is to help readers stay informed and empowered on their tech journeys.

Post a Comment

Previous Post Next Post

Contact Form