
A Redundant Array of Independent Disks (RAID) is a data technology that combines multiple disk drives to create a single logical storage unit. You can configure a RAID array to improve performance, duplicate data, or both. Usually, the RAID level determines the redundancy or performance improvement and depends on the number of disk drives, configuration, and data distribution across the storage devices.
To increase capacity and performance, create a level, such as RAID 0, that strips and distributes data across multiple disk drives. If your objective is to prevent data loss in case of a storage device failure, create a level that duplicates data across multiple physical disk drives. Typical arrays that prevent data loss include RAID 1, RAID 5, RAID 6, and RAID 10.
A combination of RAID levels, such as RAID 1+0 (RAID 10), provides both performance improvement and data redundancy. The array combines the data stripping of RAID 0 and the mirroring of RAID 1.
You can create almost any RAID level on Ubuntu and other Linux distributions if you have the minimum number of disk drives. This article uses Ubuntu 22.04 LTS to explain how to use the mdadm utility to create various software RAID levels.
To follow this guide, you need:
sudo user on the Ubuntu server.Because we cannot cover all the RAID arrays in one article, this guide focuses on RAID levels 0, 1, 5, and 10.
Connect to your server with SSH as a sudo user.
If working with previously partitioned disk drives, you need to delete existing partitions and create those that match your intended array size and configuration.
Check if there are previous RAID arrays and unmount them. If using new disk drives, skip this and go to step 3.
Output
If there is an existing RAID array. Unmount it using the syntax;
For example, for a RAID name md0, use the command:
To stop the RAID array md0, run:
Remove the array so that you can access and reuse the disk drives.
Run the following to identify the available disk drives, sizes, file systems, and mountpoints.
Typical output
In addition to the drive vda with the operating system, we have two more devices, vdb and vdc.
Before creating the RAID, it is good practice to partition disk drives such as vdb and vdc.
Create an empty partition table on vdb.
Run the same command for the second disk drive, vdc.
If you have more than two drives, use the above command for all of them while replacing vdc with the appropriate disk identifier.
Create the maximum partition on the drive. However, you can specify a smaller partition if you do not want to use the entire disk drive.
Repeat the command for all the drives by replacing vdb with the appropriate disk drive name.
The syntax for creating any RAID level is:
The verbose flag, which displays the progress in real-time, is optional.
RAID 0 requires a minimum of two storage devices.
Scan for available disk drives, partitions, and their identifiers.
Output
To create RAID 0 called md0 using the primary partitions vdb1 and vdc1, run the command;
Typical output
Check RAID status.
Output
The output shows the active RAID level and disk drives/partition it uses.
To configure automatic assembly and mounting of the RAID 0 array on boot, go to step 6.
RAID 1 requires a minimum of two storage devices.
Scan for available disk drives, partitions, and their identifiers.
Output
Although you can use partitions, such as in RAID 0 above, this section shows how to create RAID 1 using 120 GB disk drives without partitioning them first.
Type `y' for yes when prompted.
Output
Check the RAID status.
Typical output:
To display the list of disk drives, size assigned to RAID, and status, run:
Typical output
To configure automatic assembly and mounting of the RAID 1 array on boot, go to step 6.
RAID 5 requires a minimum of three storage devices.
Scan for available disk drives, partitions, and their identifiers.
Typical output
We assume they are all new and thus create RAID 5 without prior partitioning.
Output
To configure automatic assembly and mounting of the RAID 5 array on boot, go to step 6.
RAID 10 requires a minimum of four storage devices.
Scan for available disk drives, partitions, and their identifiers.
Output
Output
Once you configure a RAID array, you must create a file system and mount the array. The following instructions show you how to create the file system, mount the RAID array, and configure it to assemble and mount the RAID array when booting. The commands are the same for all levels.
The syntax for creating the file system is;
For example, to create the Ext4 file system on RAID 1 we created above, run the command;
To mount the RAID array, run:
Check whether the new file system is accessible.
To ensure that the server automatically assembles and mounts the RAID array when booting, you need to edit the configuration file /etc/mdadm/mdadm.conf.
Use the command below to scan the system, identify the active array and automatically make the necessary changes to the `/etc/mdadm/mdadm.conf file.
If you want the array loads early in the boot, update the initial RAM file system (initramfs).
Additionally, you must add the file system mount options to the etc/fstab file. Run the command below to get the array details and automatically add them to the etc/fstab file.
The above commands ensure automounting of the RAID array when the machine boots and applies to all the RAID levels. To confirm, reboot the server and run the command below to get the RAID status.
A RAID array is a storage technology that combines multiple physical disk drives to create a logical unit that offers data redundancy and recovery, performance improvement, or both. The choice of the RAID array level depends on whether you want to improve the read/write performance, add redundancy and prevent data loss in case of a drive failure. While the article focuses on a few RAID levels, you can use the instructions to create other arrays in Ubuntu 22.04 LTS and other Linux distributions.
0 Comments
Be the first to comment and share your perspective with the community.