RAID 5 is an excellent choice for those looking to strike a balance between data redundancy and performance. In this tutorial, we’ll explore how to set up RAID 5 on Rocky Linux, a popular Linux distribution for servers and desktops. This guide assumes you have basic knowledge of RAID concepts. If you need a refresher, check out our articles on the differences between RAID 6 and RAID 10 in performance and the differences between software RAID vs hardware RAID.
Prerequisites
Before we dive in, ensure you have the following:
- A minimum of three storage devices (preferably the same size)
- A working installation of Rocky Linux
- Administrative (root) privileges
How to Set Up RAID 5 on Rocky Linux
Step 1: Install mdadm
mdadm
is the Linux utility used for managing software RAID devices. To install it on Rocky Linux, execute the following command:
sudo dnf install mdadm
For more details, read our guide on how to install mdadm on Rocky Linux.
Step 2: Create the RAID 5 Array
Now that we have mdadm
installed, we can create our RAID 5 array. First, list all available storage devices with the following command:
sudo fdisk -l
Identify the devices you want to include in the RAID 5 array. For this tutorial, let’s assume you have three devices: /dev/sdb
, /dev/sdc
, and /dev/sdd
.
Create the RAID 5 array using this command:
sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
This command creates a RAID 5 array named /dev/md0
with three devices. Adjust the command as needed for your specific setup.
Step 3: Verify the RAID 5 Array Status
Once the RAID 5 array has been created, check its status using the following command:
sudo mdadm --detail /dev/md0
You should see output similar to this:
/dev/md0:
Version : 1.2
Creation Time : Mon Apr 4 00:00:00 2023
Raid Level : raid5
Array Size : 2095104 (2045.37 MiB 2144.00 MB)
Used Dev Size : 1047552 (1022.68 MiB 1072.00 MB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Mon Apr 4 00:00:00 2023
State : clean, degraded, recovering
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
Layout : left-symmetric
Chunk Size : 512K
Rebuild Status : 25% complete
Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc
3 8 48 2 spare rebuilding /dev/sdd
Step 4: Create a Filesystem on the RAID Array
After setting up the RAID 5 array, you must create a filesystem on it. In this tutorial, we will create an ext4 filesystem, a widely used and supported option.
Execute the following command to create an ext4 filesystem on the RAID 5 array:
sudo mkfs.ext4 /dev/md0
Step 5: Mount the RAID 5 Array
Now that the filesystem has been created, it’s time to mount the RAID 5 array. First, create a new directory that will serve as the mount point:
sudo mkdir /mnt/raid5
Mount the RAID 5 array to the newly created directory:
sudo mount /dev/md0 /mnt/raid5
Step 6: Configure Automatic Mounting at Boot
To ensure that the RAID 5 array is mounted automatically upon system startup, you need to update the /etc/fstab
file. First, retrieve the filesystem UUID by running:
sudo blkid | grep /dev/md0
You should see output similar to this:
/dev/md0: UUID="a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6" TYPE="ext4"
Copy the UUID value and open the /etc/fstab
file with a text editor:
sudo nano /etc/fstab
Add the following line at the end of the file, replacing YOUR_UUID
with the UUID you copied earlier:
UUID=YOUR_UUID /mnt/raid5 ext4 defaults 0 0
Save and close the file. To verify the correct configuration, reboot your system and ensure the RAID 5 array mounts automatically.
Step 7: Monitor RAID Array Health
Finally, it’s essential to monitor the health of your RAID 5 array regularly. You can use the following command to check the array’s status:
sudo mdadm --detail /dev/md0
For more advanced monitoring, consider setting up a cron job to send you email notifications in case of any issues. Learn how to set up a cron job on Rocky Linux with our detailed guide.
Conclusion
You’ve successfully set up a RAID 5 array on Rocky Linux. RAID 5 provides a good balance of data redundancy and performance, making it an ideal choice for many use cases. Remember to monitor the health of your RAID array regularly and ensure you have a robust backup strategy in place.
If you’re interested in exploring other RAID configurations, we have guides on how to set up RAID 6 on Rocky Linux and how to set up RAID 10 on Rocky Linux.