Linux RAID Configuration and Details
What is RAID?
RAID (Redundant Array of Independent Disks) is a data storage virtualization technology that combines multiple physical drives into a single logical unit to improve performance, redundancy, or both.
Types of RAID
- RAID 0: Striping for performance, no redundancy.
- RAID 1: Mirroring for redundancy.
- RAID 5: Striping with parity for redundancy and performance.
- RAID 6: Striping with double parity for higher redundancy.
- RAID 10: Combination of RAID 1 and RAID 0 for redundancy and performance.
RAID Configuration Commands
Below are some common commands used to configure RAID in Linux:
Install mdadm
sudo apt install mdadm
Redhat base installation
sudo yum install mdadm
Create a RAID Array
sudo mdadm --create /dev/md0 --active yes --level=1 --raid-devices=2 /dev/sdX /dev/sdY
Options:
--create: Create a new RAID array./dev/md0: The name of the RAID device to create.--active yes: Activate the array immediately.--level: Specify the RAID level (e.g., 0, 1, 5, 6, 10).--raid-devices: Number of devices in the array.
Check RAID Status
cat /proc/mdstat
Stop a RAID Array
sudo mdadm --stop /dev/md0
Remove a RAID Array
sudo mdadm --remove /dev/md0
Example RAID Configuration
To create a RAID 1 array with two devices:
sudo mdadm --create /dev/md0 --active yes --level=1 --raid-devices=2 /dev/sdX /dev/sdY
After creating the array, format it with a filesystem:
sudo mkfs.ext4 /dev/md0
Then mount it:
sudo mount /dev/md0 /mnt
Add a new disk in RAID configuration
To add a new disk to an existing RAID array, follow these steps:
- Identify the new disk (e.g., /dev/sdZ).
- Add the new disk to the RAID array:
- Resync the RAID array:
sudo mdadm --add /dev/md0 /dev/sdZ
sudo mdadm --grow /dev/md0 --raid-devices=3