π‘οΈ RAID-5 From Zero to Pro: Complete Hands-On Guide

Learn RAID-5 setup, failure recovery, and real-world management β explained like you're talking to a friend
π― What You'll Master Today
By the end of this guide, you'll be able to:
β Understand RAID-5 deeply (not just commands)
β Build a production-ready RAID-5 array
β Handle disk failures like a pro
β Monitor and maintain your array
β Clean up safely without breaking your system
Difficulty: Beginner-friendly (we explain everything)
Lab environment: Virtual machine recommended
For a detailed understanding of each RAID level, please refer to my comprehensive article, RAID for Linux Admins (The Ultimate Intro Guide), available at the link below.
RAID for Linux Admins (The Ultimate Intro Guide)
β οΈ CRITICAL WARNING - Read This First!
π¨ THIS TUTORIAL WILL DESTROY DATA ON THE DISKS YOU USE! π¨
Never use your system disk (where your operating system lives)
Use virtual disks (VirtualBox, VMware, KVM) OR spare physical disks
Backup everything if you're unsure which disk is which
Double-check with
lsblkbefore every command
# Always verify your disks first!
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
If you see your operating system mounted on a disk β DO NOT USE THAT DISK!
π‘ RAID-5 Explained (The Simple Truth)
What is RAID?
RAID means Redundant Array of Independent Disks.
In simple words: You take multiple physical disks and combine them to work as one big disk. The magic is how you combine them.
What is RAID-5 specifically?
RAID-5 is a specific way of combining disks where:
You need at least 3 disks to start
Data is split and written across all disks
Special "recovery information" (called parity) is also written
How does it actually work? (The Easy Way)
Imagine you have 3 notebooks (disks):
Example - Storing the number "6":
| Notebook A | Notebook B | Notebook C |
| Stores: 2 | Stores: 4 | Stores: Parity (can recreate A or B) |
Now if you lose Notebook A:
You still have B (4) and C (parity)
The parity can help recreate A (2)
So you get your original number 6!
In RAID-5:
Your files are broken into pieces
Pieces are spread across all disks
Parity rotates (not always on same disk)
If one disk dies, parity helps rebuild it
Simple Benefits:
| What You Get | Why It's Good |
| Faster reading | Multiple disks read at once |
| One disk can fail | Your data survives! |
| More storage | 3 disks of 2GB each = 4GB usable (not just 2GB) |
Simple Math:
3 disks Γ 2GB = 6GB total
RAID-5 uses 1 disk worth for parity = 2GB
You get to use = 4GB
Formula: (Number of disks - 1) Γ Size of one disk
The Important Catch:
β οΈ If 2 disks fail at the same time = ALL DATA IS LOST
Why? Because parity can only rebuild ONE missing disk, not two.
When to use RAID-5:
β Good for:
Home file servers
Media storage (movies, photos)
Office document storage
When you want speed + safety + good storage
β Not good for:
When losing data would be a disaster (use RAID-6 or RAID-10)
Very important databases
When you need maximum write speed
Remember: RAID is NOT a backup! If your house burns down, all disks are gone. Always backup important data separately.
π Step 1: Find Your Practice Disks
Let's see what disks we have available.
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
Output:
root@rhel:~# lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
NAME SIZE TYPE MOUNTPOINT
sda 2G disk
sdb 2G disk
sdc 2G disk
sdd 2G disk
What we'll use:
/dev/sda,/dev/sdb,/dev/sdcβ Build RAID-5/dev/sddβ Spare disk (for failure simulation later)
Don't have these? If you're in a VM, add 4 new virtual disks (2GB each) through your hypervisor settings.
Step 1.1: Remove old metadata using (wipefs)
The wipefs command is a Linux utility used to erase filesystem, RAID, or partition-table signatures (often called "magic strings") from a specified device (like a disk or partition).
wipefs -a /dev/sda
wipefs -a /dev/sdb
wipefs -a /dev/sdc
wipefs -a /dev/sdd
π§ Step 2: Prepare Disks with Partitions
Each disk needs one partition. We'll use fdisk because it's straightforward.
Create partition on first disk:
sudo fdisk /dev/sda
Now type these commands inside fdisk:
n β Create new partition
p β Make it primary
1 β Partition number 1
[Enter] β Accept default start
[Enter] β Accept default end (use whole disk)
t β Change partition type
fd β Set to "Linux RAID autodetect"
w β Write changes and exit
Output:
root@rhel:~# sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.40.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS (MBR) disklabel with disk identifier 0xaac1d877.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-4194303, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-4194303, default 4194303):
Created a new partition 1 of type 'Linux' and of size 2 GiB.
Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Repeat for other disks:
sudo fdisk /dev/sdb # Repeat same steps
sudo fdisk /dev/sdc # Repeat same steps
sudo fdisk /dev/sdd # Repeat same steps (spare disk)
π‘ Note: The fd type tells Linux "this is a RAID disk". Modern Linux can work without it, but using fd is good practice.
Verify your work and update partition table:
lsblk -o NAME,SIZE,TYPE
partprobe /dev/sd{a,b,c,d}
Output result:
root@rhel:~# partprobe /dev/sd{a,b,c,d}
root@rhel:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 2G 0 disk
ββsda1 8:1 0 2G 0 part
sdb 8:16 0 2G 0 disk
ββsdb1 8:17 0 2G 0 part
sdc 8:32 0 2G 0 disk
ββsdc1 8:33 0 2G 0 part
sdd 8:48 0 2G 0 disk
ββsdd1 8:49 0 2G 0 part
π¦ Step 3: Install RAID Management Tool
mdadm (Multiple Device Administrator) is the Linux tool for managing RAID.
On Debian/Ubuntu:
sudo apt update
sudo apt install mdadm -y
On RHEL/CentOS/Rocky/AlmaLinux:
sudo dnf install mdadm -y
Verify installation:
mdadm --version
ποΈ Step 4: Build Your RAID-5 Array
Time to create the actual RAID! This combines three disks into one logical device.
sudo mdadm --create --verbose /dev/md0 \
--level=5 \
--raid-devices=3 \
/dev/sda1 /dev/sdb1 /dev/sdc1
#OR use short hand command
sudo mdadm -Cv /dev/md0 -l5 -n3 /dev/sda1 /dev/sdb1 /dev/sdc1
Command breakdown:
| Part | What It Does |
--create | Tell mdadm to make a new array |
--verbose | Show detailed progress |
/dev/md0 | Name of the new RAID device |
--level=5 | Use RAID-5 (one disk parity) |
--raid-devices=3 | How many disks in the array |
/dev/sda1 /dev/sdb1 /dev/sdc1 | The three partitions to use |
You might see a warning: "Continue creating array?" β Type y and press Enter.
Output:
root@rhel:~# sudo mdadm --create --verbose /dev/md0 \
--level=5 \
--raid-devices=3 \
/dev/sda1 /dev/sdb1 /dev/sdc1
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: size set to 2094080K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
Watch it build:
cat /proc/mdstat
You'll see:
md0 : active raid5 sdc1[2] sdb1[1] sda1[0]
4190208 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
[===>.................] resync = 15.2% (318464/2095104) finish=0.5min
What this means:
[UUU]= All 3 disks are healthy (U = Up)resync = 15.2%= Initial parity calculation in progressWait for this to complete (usually 1-2 minutes)
When done, you'll see:
root@rhel:~# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdc1[3] sdb1[1] sda1[0]
4188160 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
unused devices: <none>
No more resync line = Ready to use! β
πΎ Step 5: Make It Permanent (Survive Reboots)
Right now, if you reboot, Linux will forget about your RAID. Let's fix that.
On Debian/Ubuntu:
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
On RHEL/CentOS/Rocky/AlmaLinux:
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.conf
Output:
root@rhel:~# sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.conf
ARRAY /dev/md0 metadata=1.2 UUID=8ce9bb29:0baa7cbb:1f2aace8:5b96327f
What this command does:
--detail --scan= Look at all RAID arrays and get their infotee -a= Add (append) that info to the config fileConfig file = Where Linux remembers RAID settings
Why the different paths?
Ubuntu/Debian keeps config in
/etc/mdadm/mdadm.confRHEL/CentOS keeps it in
/etc/mdadm.confThe command above automatically uses the right path
Update boot system:
On Debian/Ubuntu:
sudo update-initramfs -u
On RHEL/CentOS/Rocky/AlmaLinux:
sudo dracut --force
What this does: Updates the boot system so RAID starts automatically when computer turns on.
π Step 6: Create Filesystem & Mount It
Now we'll format the RAID and make it usable for storing files.
Format with ext4:
sudo mkfs.ext4 -L PRODUCTION_RAID5 /dev/md0
Output:
root@rhel:~# sudo mkfs.ext4 -L PRODUCTION_RAID5 /dev/md0
mke2fs 1.47.1 (20-May-2024)
Creating filesystem with 1047040 4k blocks and 262144 inodes
Filesystem UUID: 66b729eb-4a12-4cd1-b8bd-2aed6cf63a03
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
Command breakdown:
| Part | Meaning |
mkfs.ext4 | Make filesystem - ext4 type (standard Linux) |
-L PRODUCTION_RAID5 | Give it a friendly name (label) |
/dev/md0 | Format the RAID device |
π‘ Why give it a label? Makes it easier to identify and mount later.
Create mount point and mount:
sudo mkdir -p /mnt/raid5
sudo mount /dev/md0 /mnt/raid5
What happened:
Created folder
/mnt/raid5(mount point)Connected RAID device to that folder
Now you can use
/mnt/raid5to save files!
Verify it's working:
df -hT | grep raid5
Output:
root@rhel:~# df -hT | grep raid5
/dev/md0 ext4 3.9G 24K 3.7G 1% /mnt/raid5
root@rhel:~#
Reading this:
ext4= filesystem type3.9G= total space available1%= only 1% used (almost empty)
π Success! You now have a working RAID-5 array with ~4GB usable space.
π Step 7: Inspect Your RAID Array
Let's look under the hood.
sudo mdadm --detail /dev/md0
You'll see something like:
root@rhel:~# sudo mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Tue Oct 21 05:36:53 2025
Raid Level : raid5
Array Size : 4188160 (3.99 GiB 4.29 GB)
Used Dev Size : 2094080 (2045.00 MiB 2144.34 MB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Tue Oct 21 05:42:57 2025
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Name : rhel:0 (local to host rhel)
UUID : 8ce9bb29:0baa7cbb:1f2aace8:5b96327f
Events : 18
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
3 8 33 2 active sync /dev/sdc1
root@rhel:~#
Key things to watch:
State: clean = Everything is perfect
Failed Devices: 0 = No problems
All disks show "active sync" = All healthy and working
Check the label:
sudo e2label /dev/md0
Output: PRODUCTION_RAID5 β
π§ͺ Step 8: Test It With Real Data
Let's make sure it actually works by creating some files.
# Create a test file
echo "RAID-5 is working perfectly!" | sudo tee /mnt/raid5/test.txt
# Create a larger file (10MB)
sudo dd if=/dev/zero of=/mnt/raid5/bigfile.dat bs=1M count=10
# List what's there
ls -lh /mnt/raid5/
Output:
root@rhel:~# echo "RAID-5 is working perfectly!" | sudo tee /mnt/raid5/test.txt
RAID-5 is working perfectly!
root@rhel:~# sudo dd if=/dev/zero of=/mnt/raid5/bigfile.dat bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.0236702 s, 443 MB/s
root@rhel:~# ls -lh /mnt/raid5/
total 11M
-rw-r--r--. 1 root root 10M Oct 21 05:47 bigfile.dat
drwx------. 2 root root 16K Oct 21 05:41 lost+found
-rw-r--r--. 1 root root 29 Oct 21 05:47 test.txt
root@rhel:~#
Perfect! Data is safely stored on your RAID!
π₯ Step 9: Simulate Real-World Disk Failure
This is where RAID-5 shows its power. Let's pretend /dev/sdb1 dies (maybe it physically breaks).
Mark disk as failed:
sudo mdadm --manage /dev/md0 --fail /dev/sdb1
Output: mdadm: set /dev/sdb1 faulty in /dev/md0
What we did: Told the RAID system "pretend this disk is broken"
Check what happened:
sudo mdadm --detail /dev/md0
Now you'll see:
root@rhel:~# sudo mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Tue Oct 21 05:36:53 2025
Raid Level : raid5
Array Size : 4188160 (3.99 GiB 4.29 GB)
Used Dev Size : 2094080 (2045.00 MiB 2144.34 MB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Tue Oct 21 05:48:40 2025
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 1
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Name : rhel:0 (local to host rhel)
UUID : 8ce9bb29:0baa7cbb:1f2aace8:5b96327f
Events : 20
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
- 0 0 1 removed
3 8 33 2 active sync /dev/sdc1
1 8 17 - faulty /dev/sdb1
Understanding "degraded":
Your RAID still works
Data is still accessible
BUT: No safety net anymore
If another disk fails now = data is gone!
Test if data is still accessible:
cat /mnt/raid5/test.txt
Output:
root@rhel:~# cat /mnt/raid5/test.txt
RAID-5 is working perfectly!
π Your data survived the disk failure! This is the magic of RAID-5.
Remove the failed disk from array:
sudo mdadm --manage /dev/md0 --remove /dev/sdb1
Output:
root@rhel:~# sudo mdadm --manage /dev/md0 --remove /dev/sdb1
mdadm: hot removed /dev/sdb1 from /dev/md0
root@rhel:~#
Important: You can only remove a disk AFTER marking it as faulty. That's why we did --fail first, then --remove.
π§ Step 10: Rebuild With a New Disk
Now we'll replace the dead disk with our spare /dev/sdd1.
In real life, this is when you'd physically replace the broken disk with a new one.
Add the new disk:
sudo mdadm --manage /dev/md0 --add /dev/sdd1
Output: mdadm: added /dev/sdd1
Watch the rebuild happen in real-time:
watch -n 2 cat /proc/mdstat
You'll see output like below:
md0 : active raid5 sdd1[3] sdc1[2] sda1[0]
4190208 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [U_U]
[====>................] recovery = 22.5% finish=0.8min speed=45000K/sec
What this means:
[U_U]= Two disks working (U), one rebuilding (the _ underscore)recovery = 22.5%= Rebuild is 22.5% completefinish=0.8min= About 0.8 minutes leftspeed=45000K/sec= How fast it's rebuilding
What's happening: The RAID is using parity from the good disks to recreate all data on the new disk.
In real life: With large disks (1TB+), this takes many minutes or hours as per disk speed!
Wait for it to complete. Press Ctrl+C to stop watching when done.
Verify rebuild success:
sudo mdadm --detail /dev/md0
You should see:
root@rhel:~# sudo mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Tue Oct 21 05:36:53 2025
Raid Level : raid5
Array Size : 4188160 (3.99 GiB 4.29 GB)
Used Dev Size : 2094080 (2045.00 MiB 2144.34 MB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Tue Oct 21 05:52:53 2025
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Name : rhel:0 (local to host rhel)
UUID : 8ce9bb29:0baa7cbb:1f2aace8:5b96327f
Events : 44
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
4 8 49 1 active sync /dev/sdd1
3 8 33 2 active sync /dev/sdc1
root@rhel:~#
Notice: /dev/sdd1 replaced the failed /dev/sdb1 in position 1.
Confirm data is still there:
ls -lh /mnt/raid5/
cat /mnt/raid5/test.txt
Output:
root@rhel:~# ls -lh /mnt/raid5/
total 11M
-rw-r--r--. 1 root root 10M Oct 21 05:47 bigfile.dat
drwx------. 2 root root 16K Oct 21 05:41 lost+found
-rw-r--r--. 1 root root 29 Oct 21 05:47 test.txt
root@rhel:~# cat /mnt/raid5/test.txt
RAID-5 is working perfectly!
root@rhel:~#
Both files are there!
π Perfect! You just recovered from a disk failure like a professional system administrator.
π Step 11: Real-World Monitoring
In production systems, you need to know when disks fail BEFORE you lose data.
Check RAID health regularly:
# Quick status check
cat /proc/mdstat
# Detailed health report
sudo mdadm --detail /dev/md0
# Check all RAID arrays
sudo mdadm --detail --scan
Set up a cron job to check daily(Optional but good) for this tutorial:
# Edit crontab
sudo crontab -e
# Add this line (checks every day at 2 AM)
0 2 * * * /usr/sbin/mdadm --detail --scan > /var/log/raid-check.log
Check disk health with SMART:
# Install smartmontools if not already installed
sudo apt install smartmontools -y # Debian/Ubuntu
sudo dnf install smartmontools -y # RHEL/CentOS
# Check individual disk health
sudo smartctl -a /dev/sda
sudo smartctl -a /dev/sdb
sudo smartctl -a /dev/sdc
sudo smartctl -a /dev/sdd
Look for:
SMART Health Status: OK= GoodReallocated_Sector_Ct= Should be 0 or very lowCurrent_Pending_Sector= Should be 0
Since SMART doesnβt work on virtual drives, you can:
Monitor the hostβs physical disks (from the hypervisor, not the VM).
Use software-level checks inside the VM:
sudo badblocks -sv /dev/sda sudo badblocks -sv /dev/sdb sudo badblocks -sv /dev/sdc sudo badblocks -sv /dev/sddor file-system checks (
fsck), if you want to detect logical corruption.
Output of just /dev/sda:
root@rhel:~# sudo badblocks -sv /dev/sda
Checking blocks 0 to 2097151
Checking for bad blocks (read-only test): done
Pass completed, 0 bad blocks found. (0/0/0 errors)
root@rhel:~#
(0/0/0 errors) means no error.
π Step 12: Make It Auto-Mount on Boot
Right now, you must manually mount after each reboot. Let's make it automatic.
Get the UUID:
sudo blkid /dev/md0
Output:
/dev/md0: LABEL="PRODUCTION_RAID5" UUID="a1b2c3d4-e5f6-7890-abcd-ef1234567890" TYPE="ext4"
What is UUID? A unique ID for this filesystem. It never changes, even if device names change.
Copy the UUID value (the part between quotes after UUID=).
Edit fstab:
sudo nano /etc/fstab
Add this line at the bottom (replace UUID with yours):
UUID=a1b2c3d4-e5f6-7890-abcd-ef1234567890 /mnt/raid5 ext4 defaults,nofail 0 2
What each part means:
| Part | Meaning |
UUID=... | Identifies the RAID filesystem |
/mnt/raid5 | Where to mount it |
ext4 | Filesystem type |
defaults | Use standard mount settings |
nofail | Don't stop boot if RAID fails to mount |
0 | Don't backup with dump |
2 | Check filesystem at boot (after root filesystem) |
Why nofail is important: If RAID has a problem, your computer will still boot (not get stuck).
Save and exit (Ctrl+X, then Y, then Enter).
Test it works:
# Unmount
sudo umount /mnt/raid5
# Try auto-mounting from fstab
sudo mount -a
# Verify
df -h | grep raid5
If you see it mounted, perfect! β
Output:
root@rhel:~# sudo mdadm --manage /dev/md0 --add /dev/sdd1
mdadm: added /dev/sdd1
root@rhel:~# watch -n 2 cat /proc/mdstat
root@rhel:~# sudo nano /etc/fstab
root@rhel:~# sudo umount /mnt/raid5
root@rhel:~# sudo mount -a
mount: (hint) your fstab has been modified, but systemd still uses
the old version; use 'systemctl daemon-reload' to reload.
root@rhel:~# df -h | grep raid5
/dev/md0 3.9G 11M 3.7G 1% /mnt/raid5
root@rhel:~#
Now RAID will automatically mount every time you boot.
π§Ή Step 13: Complete Cleanup (When Done Testing)
Let's remove everything cleanly to avoid problems later.
1οΈβ£ Unmount the filesystem:
sudo umount /mnt/raid5
Troubleshooting: If you get "device is busy":
# Find what's using it
sudo lsof | grep /mnt/raid5
# Or check if you're inside that directory
pwd # If you're in /mnt/raid5, type: cd ~
# Force unmount if really needed (be careful!)
sudo umount -l /mnt/raid5
2οΈβ£ Stop the RAID array:
sudo mdadm --stop /dev/md0
Output:
root@rhel:~# sudo mdadm --stop /dev/md0
mdadm: stopped /dev/md0
3οΈβ£ Verify it's stopped:
cat /proc/mdstat
Output:
root@rhel:~# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
unused devices: <none>
root@rhel:~#
You should see: No md0 listed (maybe just Personalities : [raid5]).
4οΈβ£ Erase RAID metadata (CRITICAL STEP):
sudo mdadm --zero-superblock /dev/sda1
sudo mdadm --zero-superblock /dev/sdb1
sudo mdadm --zero-superblock /dev/sdc1
sudo mdadm --zero-superblock /dev/sdd1
What this does: Removes RAID information from disks.
Why this is critical: Without this, Linux might try to auto-start the RAID on next boot, causing confusion or errors.
5οΈβ£ Delete partitions (optional - only if reusing disks):
sudo fdisk /dev/sda
# Type: d (delete partition), then w (write and exit)
sudo fdisk /dev/sdb
# Type: d, then w
sudo fdisk /dev/sdc
# Type: d, then w
sudo fdisk /dev/sdd
# Type: d, then w
6οΈβ£ Remove from config files:
On Debian/Ubuntu:
sudo nano /etc/mdadm/mdadm.conf
# Delete the line starting with "ARRAY /dev/md0 metadata=1.2 UUID=8ce9bb29:0baa7cbb:1f2aace8:5b96327f
"
# Save and exit
On RHEL/CentOS:
sudo nano /etc/mdadm.conf
# Delete the line starting with "ARRAY /dev/md0 metadata=1.2 UUID=8ce9bb29:0baa7cbb:1f2aace8:5b96327f
"
# Save and exit
Remove from fstab:
sudo nano /etc/fstab
# Delete the line with UUID and /mnt/raid5
# Save and exit
Update boot system:
# Debian/Ubuntu
sudo update-initramfs -u
# RHEL/CentOS
sudo dracut --force
7οΈβ£ Remove mount directory:
sudo rm -rf /mnt/raid5
8οΈβ£ Final verification:
# Should show nothing about md0
cat /proc/mdstat
ls /dev/md* 2>/dev/null
lsblk | grep md
π System is completely clean! You can now safely reboot or repurpose the disks.
π Troubleshooting Common Problems
Problem: "Device or resource busy" when unmounting
Why this happens: Something is still using the RAID (a program, terminal, or process).
Solution:
# Find what's using it
sudo lsof | grep /mnt/raid5
# Make sure you're not inside the directory
pwd
cd ~ # Go to home directory
# Try unmounting again
sudo umount /mnt/raid5
# If still stuck, force it (last resort)
sudo umount -l /mnt/raid5
Problem: RAID doesn't start after reboot
Why this happens:
Configuration wasn't saved
Boot system wasn't updated
Solution:
# Re-scan and save configuration
# For Ubuntu/Debian:
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
# For RHEL/CentOS:
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.conf
# Update boot system
sudo update-initramfs -u # Debian/Ubuntu
sudo dracut --force # RHEL/CentOS
Problem: Can't create RAID - "device has existing RAID data"
Why this happens: Disks still have old RAID information.
Solution:
# Wipe old RAID data first
sudo mdadm --zero-superblock /dev/sda1
sudo mdadm --zero-superblock /dev/sdb1
sudo mdadm --zero-superblock /dev/sdc1
# Then create RAID again
sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sda1 /dev/sdb1 /dev/sdc1
Problem: RAID shows "inactive" after reboot
Why this happens: RAID didn't auto-assemble.
Solution:
# Manually assemble it
sudo mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1
# Then fix config so it auto-starts next time
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u # or dracut --force
Problem: Rebuild is taking forever
Why this happens: This is normal! Large disks take many hours.
What you can do:
# Check progress anytime
cat /proc/mdstat
# Check speed
cat /proc/sys/dev/raid/speed_limit_min
cat /proc/sys/dev/raid/speed_limit_max
# Increase rebuild speed (if system is not busy)
echo 50000 | sudo tee /proc/sys/dev/raid/speed_limit_min
echo 200000 | sudo tee /proc/sys/dev/raid/speed_limit_max
Note: Faster rebuild = more system load. Don't do this on production servers under heavy use.
π Quick Reference Commands
Daily Operations:
# Check RAID health (quick)
cat /proc/mdstat
# Check RAID health (detailed)
sudo mdadm --detail /dev/md0
# Check disk space
df -h /mnt/raid5
# Check all RAID arrays
sudo mdadm --detail --scan
# Check physical disk health
sudo smartctl -a /dev/sda
Emergency Commands:
# Mark disk as failed
sudo mdadm --manage /dev/md0 --fail /dev/sdb1
# Remove failed disk
sudo mdadm --manage /dev/md0 --remove /dev/sdb1
# Add replacement disk
sudo mdadm --manage /dev/md0 --add /dev/sdd1
# Force assemble (if RAID won't start)
sudo mdadm --assemble --force /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1
# Stop RAID
sudo mdadm --stop /dev/md0
# Clean RAID metadata
sudo mdadm --zero-superblock /dev/sda1
π What You've Mastered
β
Understanding: You know exactly what RAID-5 is and how it works
β
Building: You can create a RAID array from scratch
β
Monitoring: You can check health and spot problems early
β
Recovery: You can handle disk failures and rebuild arrays
β
Maintenance: You can clean up and manage configurations properly
β
Troubleshooting: You can fix common problems
π Next Steps - Level Up Your Skills
Want to learn more?
Try RAID-6 (can lose 2 disks instead of 1):
sudo mdadm --create /dev/md0 --level=6 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1Learn RAID-10 (combines speed + mirroring):
sudo mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1Add hot spare (automatic replacement):
sudo mdadm --manage /dev/md0 --add-spare /dev/sde1Learn LVM on top of RAID (flexible storage management)
Compare hardware RAID vs software RAID
π¬ Final Words of Wisdom
RAID-5 is a balancing act between speed, safety, and storage:
β Good for:
Home file servers and NAS
Media storage (movies, music, photos)
Office document servers
Development environments
β Not ideal for:
Critical databases with lots of writes
Systems where 100% uptime is required
When maximum write speed is needed
Three Golden Rules:
π΄ RAID is NOT a backup!
Fire, theft, ransomware affects all disks
Always maintain separate backups
π‘ Monitor your RAID regularly
Disks fail when you least expect it
Check health weekly (or setup automatic checks)
π’ Test your recovery plan
Practice rebuilding before you need to
Know your commands by heart
You now have real-world RAID-5 skills! π
You can confidently manage RAID arrays in home labs, small offices, or production environments.
Keep practicing, stay curious, and may all your disks stay healthy! π‘οΈ
Remember: The best system administrator is the one who tests their backups and recovery procedures regularly.



