Combine multiple disks into a RAID array for higher capacity, read/write bandwidth, reliability, and availability.
Prerequisites
Multiple data disks of the same size and category are created and attached to an ECS instance. See Create a data disk and Attach a data disk.
Usage notes
RAID levels
Common RAID levels and their trade-offs:
Level | Advantage | Disadvantage | Scenario |
RAID 0 (Striping) | Data striping with parallel read/write for higher performance. Note Disk striping divides data into fixed-size blocks (stripes) and distributes them across multiple disks. | No redundancy. If one disk fails, all data is lost. | High-performance scenarios without redundancy needs, such as temporary storage and caching. |
RAID 1 (Mirroring) | Mirrors all data across disks. If one disk fails, data remains available. | Requires at least twice the disk capacity for mirroring. | Applications requiring high data protection, such as databases and file servers. |
RAID 10 | Combines RAID 1 mirroring and RAID 0 striping for both redundancy and high read/write performance. | Requires twice the disk capacity and at least four disks. | Applications requiring both high performance and redundancy. |
Select a RAID level based on your data protection, performance, capacity, and cost requirements.
The following figure illustrates how each RAID level stores data blocks A through F.
Disk bandwidth is subject to instance-level limits. For disk bandwidth limits of each instance type, see Instance family.
RAID stripe size
The optimal stripe size depends on your workload and application. Test different stripe sizes to determine the best fit.
Recommended stripe sizes by workload type:
General-purpose workloads: 64 KB or 128 KB. These sizes provide balanced read/write performance.
Sequential read workloads (such as large file transfers and video editing): 256 KB or 512 KB.
Random read workloads (such as database applications): 32 KB.
An excessively small stripe size can cause the following issues:
Disk file fragmentation, which wastes disk space.
IOPS limits may be reached before throughput limits. Larger stripe sizes yield higher throughput for sequential reads.
Disk snapshot limits
Ensure snapshot consistency when backing up RAID array disks. Restoring from unsynchronized snapshots can compromise array integrity.
Use snapshot-consistent groups to restore data from multiple disks to the same point in time.
Procedure
This section uses the mdadm command on Linux to create a RAID array named /dev/md0 for data disks on an ECS instance running Ubuntu 22.04.
-
Connect to an ECS instance.
For information about the connection methods, see Connection method overview.
View all disks on the instance:
lsblkSample output:

Create the /dev/md0 RAID array with the
mdadmcommand.Select a RAID level based on your business requirements.
NoteIf mdadm is not installed, run
sudo apt-get install mdadmto install it.RAID 0 level
sudo mdadm --create /dev/md0 --level=0 --raid-devices=5 --chunk=512 /dev/vd[bcdef]--level=0: the RAID 0 level.--raid-devices=5: the RAID array consists of five disks.--chunk=512: the stripe size is 512 KB. Adjust based on your workload./dev/vd[bcdef]: the five disks /dev/vdb, /dev/vdc, /dev/vdd, /dev/vde, and /dev/vdf.
Sample output:

RAID 1 level
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/vd[bc]--level=1: the RAID 1 level.--raid-devices=2: the RAID array consists of two disks./dev/vd[bc]: the two disks /dev/vdb and /dev/vdc.
RAID 10 level
sudo mdadm --create /dev/md0 --level=10 --raid-devices=4 --chunk=512 /dev/vd[bcde]--level=10: the RAID 10 level.--raid-devices=4: the RAID array consists of four disks.--chunk=512: the stripe size is 512 KB. Adjust based on your workload./dev/vd[bcde]: the four disks /dev/vdb, /dev/vdc, /dev/vdd, and /dev/vde.
View the /dev/md0 RAID array details:
sudo mdadm --detail /dev/md0Sample output:

Create a file system on the RAID array. This example creates an ext4 file system.
Replace ext4 with your preferred file system type.
sudo mkfs.ext4 /dev/md0Sample output:

Save the RAID configuration and enable automatic reassembly on boot:
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.confMount the file system.
(Optional) Create a mount point. This example creates /media/raid0.
sudo mkdir /media/raid0NoteYou can also mount the file system on an existing directory, such as /mnt.
Mount the file system. This example mounts /dev/md0 on /media/raid0.
To customize data security and performance trade-offs, specify
mountparameters. See Mount Ext4 file systems with options.(Recommended) For balanced data security and performance, mount without specifying parameters:
sudo mount /dev/md0 /media/raid0For high data security with lower performance:
sudo mount -o rw,atime,sync,barrier,data=journal /dev/md0 /media/raid0For high performance with lower data security:
sudo mount -o defaults,noatime,nodiratime,nobarrier,nodelalloc,data=writeback /dev/md0 /media/raid0
View the RAID array mount information:
df -hIf the file system appears at the specified mount point, the mount succeeded.

Configure automatic mount on boot.
Add an entry for the RAID array to
/etc/fstab.Add the mount entry to /etc/fstab:
sudo sh -c "echo `blkid /dev/md0 | awk '{print $2}' | sed 's/\"//g'` /media/raid0 ext4 defaults 0 0 >> /etc/fstab"/dev/md0: the RAID array name./media/raid0: the mount point. Replace with your actual mount point if different.ext4: the file system type. Replace with the actual type.defaults: the mount parameters. See Mount Ext4 file systems with options for details.
NoteTo allow the instance to boot without the RAID array mounted, add the
nofailmount option. Thenofailoption allows the instance to boot even if a disk mount error occurs. On Ubuntu, also add thenobootwaitoption.Verify the mount entry:
cat /etc/fstabIf the entry was added to the
/etc/fstabfile,/media/raid0appears in the output.
Mount all file systems in /etc/fstab. If no errors occur, the RAID array will auto-mount on the next boot.
sudo mount -aVerify the file system is mounted:
df -ThIf the file system appears in the output, the mount succeeded.


