You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
Volume
Setting up RAID (Linux)
Copy page
Download PDF
Setting up RAID (Linux)
This topic explains how to set up RAID arrays on your Linux instance, using RAID 10 as an example.​
Background information​
RAID stands for Redundant Array of Independent Disks. It is a technology that combines multiple disks into an array. RAID allows systems to deliver higher performance, greater data reliability, and improved availability. RAID operates at different levels, each with a distinct data distribution and redundancy strategy. Common RAID levels include RAID 0, which improves read/write performance; RAID 1, which uses mirroring; RAID 5, which balances performance and data redundancy; and RAID 10, which combines the advantages of RAID 1 and RAID 0.​
​
RAID level​
Description​
Minimum number of volumes​
RAID 0​
This level stripes data evenly across two or more disks. With two disks in RAID 0, for example, data is split into small blocks that are stored alternately on the two disks.​
Striping involves dividing data into fixed-size blocks, called stripes, and distributing them sequentially across different disk drives.​
  • Advantages: It offers high read/write performance.​
  • Disadvantages: There is no data redundancy. If one disk fails, the entire array loses all its data, making it unreliable.​
  • Use cases: Use this level for scenarios that require high read/write speeds but low data security, such as video editing, temporary data storage, and caching.​
2​
RAID 1​
This level consists of an exact copy, or mirror, of a set of data stored on two or more disks.​
  • Advantages: It provides high data security. As long as one disk is functioning properly, the data remains intact. Additionally, read operations can run in parallel across multiple disks, improving read performance.​
  • Disadvantage: Disk space utilization is low at only 50% when using two disks, and the cost is higher.​
  • Use cases: Use this level for scenarios with extremely high data security requirements, such as critical data storage in finance and healthcare.​
2​
RAID 5​
This level stripes both data and parity information across multiple disks. The parity information is used to recover data in the event of a disk failure.​
  • Advantages: It strikes a balance between performance and data redundancy. The read performance is better than RAID 0, but the write performance is lower. However, it is still acceptable. It allows for a single disk failure without data loss.​
  • Disadvantages: Writing data requires calculating and updating parity information, which increases performance overhead. Data recovery becomes relatively complex when a disk fails.​
  • Use cases: Use this level for enterprise applications that require performance and data security, such as database or file servers.​
3​
RAID 6​
This level extends RAID 5 by adding a second parity block. This enables the system to withstand the failure of two disks simultaneously without losing data.​
  • Advantages: It offers even higher data security and can tolerate up to two disk failures.​
  • Disadvantages: Write performance is worse than with RAID 5 because the system must calculate and update two parity blocks. Disk space utilization is relatively low, and the cost is higher.​
  • Scenario: Use this level for critical business systems that require an extremely high level of data security and cannot tolerate data loss from disk failures. Examples include large data centers and core banking systems.​
4​
RAID 10​
First, this level pairs disks into RAID 1 mirrored pairs. Then, it combines those mirrored pairs into a RAID 0 array.​
  • Advantages: It delivers the benefits of both RAID 0 and RAID 1, providing high read/write performance and data security.​
  • Disadvantages: Disk space utilization is low, and cost is higher.​
  • Use cases: Use this level for scenarios that require high performance and reliability, such as for high-end database applications or virtual servers.​
4​
​
Notes​
  • Before you begin, back up your data. Creating a RAID array may initialize your volumes, which could result in data loss.​
  • A system volume stores the operating system and critical system files, which are essential for startup and operation of the system. Therefore, it is not recommended to set up RAID with system volumes.​
  • To ensure optimal performance and compatibility, we recommend using data volumes of the same capacity and specifications to create a RAID array.​
Prerequisites​
You have created an ECS instance with the following basic settings.​
  • Image: CentOS Stream 9 64-bit.​
  • Storage: Four 20-GiB ESSD data volumes attached to the instance.​
  • Network: An Elastic IP Address (EIP) associated with the instance.​
Steps​
  1. Get information about block devices.​
  • ​
    lsblk​
    ​
  • The example output shows that the instance has four data volumes attached with the following device names: "dev/vdb", "dev/vdc", "dev/vdd", and "dev/vde".​
  • ​​​
  1. Create a RAID array with mdadm.​
tip​
mdadm stands for "multiple devices admin". It is a Linux utility used to manage software RAID devices. This simple yet powerful application is compatible with almost any RAID level.​
  1. Install mdadm.​
  • ​
    sudo yum install mdadm​
    ​
  • ​​​
  1. Create a RAID array. To create an array called "/dev/md0", for example, run the following command:​
tip​
Creating the array takes a long time. The exact time depends on the size of the volumes. Although the entire process requires no manual intervention, you must not shut down or restart the instance during this time. Recovering an array is much more complex than creating it for the first time.​
  • ​
    sudo mdadm --create /dev/md0 --level=10 --raid-devices=4 --chunk=512 /dev/vdb /dev/vdc /dev/vdd /dev/vde​
    ​
  • --create /dev/md0: The device name of the RAID array. This example uses "/dev/md0".​
  • --level=10: The RAID level. This example creates a RAID 10 array.​
  • --raid-devices=4: The number of volumes in the RAID array. This example uses four volumes.​
  • /dev/vd[bcde]: The names of the devices that participate in the array, which are separated by spaces.​
  • --chunk=512: The chunk size of the RAID array. This example uses 512 KB. Based on the workload type, the following chunk sizes are recommended:​
  • For general-purpose workloads, a chunk size of 64 KB or 128 KB provides balanced read/write performance.​
  • For sequential read workloads, such as video editing or large file transfers, a larger chunk size (256 KB or 512 KB) may offer better performance.​
  • For random read workloads, such as database applications, a smaller chunk size (e.g., 32 KB) may be preferable.​
  • The example output indicates that the RAID 10 array has been successfully started.​
  • ​​​
  1. View the RAID status.​
  • ​
    sudo mdadm --detail /dev/md0​
    ​
  • You will see output similar to the following:​
  • ​​​
  1. Mount the RAID array.​
  1. Create a file system on the RAID array. This example creates an ext4 file system. You can create other types of file systems based on your needs.​
  • ​
    sudo mkfs -t ext4 /dev/md0​
    ​
  • ​​​
  1. Create a mount directory. To create a mount directory called "/mnt/raid10", for example, run the following command:​
  • ​
    sudo mkdir /mnt/raid10​
    ​
  1. Mount the RAID array on /mnt/raid10.​
  • ​
    sudo mount /dev/md0 /mnt/raid10​
    ​
  1. Verify the mount result.​
  • ​
    df -h​
    ​
  • ​​​
  • If successful, the command returns output similar to the above.​
  1. If you need to set up automatic mounting of the RAID array upon boot, see Setting up automatic mounting of volume partitions upon boot.​
Last updated: 2026.10.19 19:41:53