Linux RAID setup combines multiple drives into one storage array for greater capacity, performance, or fault tolerance, depending on the RAID level. For most software arrays, Linux’s built-in md driver and mdadm tool are the central pieces; a safe setup starts by choosing the right layout, identifying drives carefully, and planning how to recover from failure.
What RAID Does—and Does Not Do
RAID means redundant array of independent disks. It distributes data across drives according to a layout, or RAID level. Some layouts improve read or write performance; others keep data available after a drive fails; some do both. RAID is not a substitute for a separate backup: accidental deletion, malware, filesystem damage, theft, or an electrical event can affect an entire array.
Linux can provide software RAID through the kernel’s md subsystem. mdadm creates and manages these arrays, while the filesystem—such as ext4 or XFS—is created on the resulting device. Hardware RAID controllers instead present a logical disk to the operating system and manage the physical drives themselves. This guide focuses on Linux software RAID.
Choose a RAID Level
- RAID 0: Stripes data across two or more drives. It can improve throughput and uses the combined capacity, but has no redundancy: failure of any member can destroy the array’s data.
- RAID 1: Mirrors data. A two-drive mirror generally provides the capacity of one drive and can continue operating after one member fails. It is often a straightforward choice for a small system, but it is not a backup.
- RAID 5: Uses striping and distributed parity across at least three drives. It can tolerate one member failure, with usable capacity roughly equal to the total capacity minus one drive. Rebuilds can take time, and another failure during that period can make the array unavailable.
- RAID 6: Adds a second parity calculation and typically needs at least four drives. It can tolerate two member failures, at the cost of more capacity and write overhead.
- RAID 10: Combines mirrored pairs with striping and typically needs at least four drives. It can provide strong performance and redundancy, but usable capacity is about half of the total. Which drive failures it can survive depends on which members fail.
These are broad characteristics, not performance guarantees. Drive workload, controller, filesystem, stripe size, and workload all matter. RAID levels also do not make unlike drives identical: an array’s usable capacity is constrained by its layout and, in many configurations, the smallest member.
Prepare Drives and System
Before creating an array, save any data you need elsewhere. Creating or reconfiguring RAID can overwrite drive metadata or partition information. Make a separate backup and verify that you can access it.
- Install the distribution’s
mdadmpackage using its normal package manager. The package name is commonlymdadm, though availability and service setup vary by distribution. - Identify the intended devices with commands such as
lsblk -o NAME,SIZE,MODEL,SERIAL,FSTYPE,MOUNTPOINTSandsudo fdisk -l. Match model, size, and serial number; never rely only on a device name such as/dev/sdb, which can change. - Check that the chosen drives are not mounted or holding data you need. Decide whether to use whole disks or partitions, and use a consistent approach for all members.
- Consider drive health and connections before building. A RAID array cannot compensate for a loose cable, failing power supply, or unsuitable storage device.
Device names in examples are placeholders. Confirm each one on the actual system; a mistaken command targeting the wrong disk can destroy data.
Create and Mount an mdadm Array
For example, after confirming that /dev/sdb and /dev/sdc are the intended, empty drives, a two-member RAID 1 array can be created with:
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
The kernel may synchronize or initialize the array after creation. Inspect progress and status with cat /proc/mdstat and sudo mdadm --detail /dev/md0. Do not assume that an array is fully synchronized merely because the command returned.
Once the device is ready, create a filesystem—for example, sudo mkfs.ext4 /dev/md0—then create a mount point and mount it. Formatting is destructive, so verify that /dev/md0 is the intended new array before running it. For persistent use, configure the system to assemble the array at boot and mount the filesystem by a stable identifier, commonly a filesystem UUID in /etc/fstab. Exact package prompts and configuration-file locations differ among distributions; follow the distribution’s documentation and test boot-time assembly before relying on the array.
Monitor, Maintain, and Recover
RAID requires ongoing monitoring. Check /proc/mdstat and mdadm --detail periodically, and configure the distribution’s monitoring or alerting mechanism so a degraded array does not go unnoticed. A degraded array has lost redundancy; replace a failed member promptly, while preserving a separate backup.
Drive replacement is a deliberate recovery operation, not simply a matter of plugging in a disk. Confirm which member failed, verify the replacement device, and use the appropriate mdadm remove and add operations for the array’s state. The exact procedure depends on whether the array uses partitions or whole drives and on the failure condition. Follow the current mdadm documentation, and avoid copying commands blindly.
Rebuilding reads substantial data and can take hours or longer, depending on drive size, system activity, and hardware. Monitor the rebuild, maintain backups, and avoid unnecessary heavy workloads while it runs. SMART health checks can provide useful warnings, but no single health report guarantees a drive will not fail.
Common Problems and Misconceptions
- The array is missing after reboot: Check that it is assembled at startup, the relevant configuration is current, and the filesystem mount uses the correct UUID. Distribution-specific initramfs or boot configuration may also matter, especially if the root filesystem is on RAID.
- A drive appears as a different device: Linux device letters can change. Re-identify it by serial number and size before performing repair operations.
- The array is degraded: One member may be unavailable, disconnected, or failed. Review detailed status and system logs before changing array membership.
- RAID is mistaken for a backup: Mirroring faithfully duplicates deletions and corruption. Keep independent copies, ideally with at least one copy not continuously connected to the system.
- Mixing RAID types: Linux software RAID is not the same as motherboard firmware RAID or a dedicated hardware controller. Know which layer owns the array before moving drives or changing boot settings.
For home servers and workstations, software RAID can be practical and avoids requiring a particular RAID controller. If the goal is recovery from accidental changes or disasters, prioritize tested backups; RAID addresses certain drive failures, not every cause of data loss.
Frequently Asked Questions
Does Linux support RAID without a hardware controller?
Yes. Linux software RAID uses the kernel’s md subsystem, commonly managed with mdadm. The array is assembled by the operating system rather than by a dedicated RAID controller.
Can I create RAID without erasing my drives?
Do not assume it is safe. Creating an array or changing its layout can overwrite metadata and data. Back up anything important and treat member drives as disposable during setup unless you have a verified migration plan.
Which Linux RAID level is best?
There is no universal best level. RAID 1 is a simple mirror, RAID 5 and 6 trade capacity for parity protection, and RAID 10 combines mirrors with striping. Choose according to drive count, capacity, workload, and acceptable failure risk.
Will RAID protect me from ransomware or accidental deletion?
No. RAID can keep service running after some drive failures, but it usually reproduces writes and deletions across the array. Use separate, versioned backups for recovery from such events.
How do I check whether my array is healthy?
Start with cat /proc/mdstat and sudo mdadm --detail /dev/md0, replacing the device with your array’s name. Also check configured alerts and drive health, and investigate any degraded or rebuilding status.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Fix Error 0x80072f76 0x20016 in Windows
- How to Backup and Restore Drivers in Windows 11
- Fix Windows Couldn’t Complete the Requested Changes
- Move to iOS Stuck? Fixes That Actually Work
- USB Bluetooth Dongle: What It Is and How It Works
- ADB Device Not Found Error on Windows: Fixed