Chapter 18. Managing RAID You can use a Redundant Array of Independent Disks (RAID) to store data across multiple drives. It can help to avoid data loss if a drive has failed. 18.1. Overview of RAID In a RAID, multiple devices, such as HDD, SSD, or NVMe are combined into an array to accomplish performance or redundancy goals not achievable with one large and expensive drive. This array of devices appears to the computer as a single logical storage unit or drive. RAID supports various configurations, including levels 0, 1, 4, 5, 6, 10, and linear. RAID uses techniques such as disk striping (RAID Level 0), disk mirroring (RAID Level 1), and disk striping with parity (RAID Levels 4, 5 and 6) to achieve redundancy, lower latency, increased bandwidth, and maximized ability to recover from hard disk crashes. RAID distributes data across each device in the array by breaking it down into consistently-sized chunks, commonly 256 KB or 512 KB, although other values are acceptable. It writes these chunks to a hard drive in the RAID array according to the RAID level employed. While reading the data, the process is reversed, giving the illusion that the multiple devices in the array are actually one large drive. RAID technology is beneficial for those who manage large amounts of data. The following are the primary reasons to deploy RAID: It enhances speed It increases storage capacity using a single virtual disk It minimizes data loss from disk failure The RAID layout and level online conversion 18.2. RAID types The following are the possible types of RAID: Firmware RAID Firmware RAID, also known as ATARAID, is a type of software RAID where the RAID sets can be configured using a firmware-based menu. The firmware used by this type of RAID also hooks into the BIOS, allowing you to boot from its RAID sets. Different vendors use different on-disk metadata formats to mark the RAID set members. The Intel Matrix RAID is an example of a firmware RAID system. Hardware RAID A hardware-based array manages the RAID subsystem independently from the host. It might present multiple devices per RAID array to the host. Hardware RAID devices might be internal or external to the system. Internal devices commonly consists of a specialized controller card that handles the RAID tasks transparently to the operating system. External devices commonly connect to the system via SCSI, Fibre Channel, iSCSI, InfiniBand, or other high speed network interconnect and present volumes such as logical units to the system. RAID controller cards function like a SCSI controller to the operating system and handle all the actual drive communications. You can plug the drives into the RAID controller similar to a normal SCSI controller and then add them to the RAID controller's configuration. The operating system will not be able to tell the difference. Software RAID A software RAID implements the various RAID levels in the kernel block device code. It offers the cheapest possible solution because expensive disk controller cards or hot-swap chassis are not required. With hot-swap chassis, you can remove a hard drive without powering off your system. Software RAID also works with any block storage, which are supported by the Linux kernel, such as SATA, SCSI, and NVMe. With today's faster CPUs, Software RAID also generally outperforms hardware RAID, unless you use high-end storage devices. Since the Linux kernel contains a multiple device (MD) driver, the RAID solution becomes completely hardware independent. The performance of a software-based array depends on the server CPU performance and load. The following are the key features of the Linux software RAID stack: Multithreaded design Portability of arrays between Linux machines without reconstruction Backgrounded array reconstruction using idle system resources Hot-swap drive support Automatic CPU detection to take advantage of certain CPU features such as streaming Single Instruction Multiple Data (SIMD) support. Automatic correction of bad sectors on disks in an array. Regular consistency checks of RAID data to ensure the health of the array. Proactive monitoring of arrays with email alerts sent to a designated email address on important events. Write-intent bitmaps, which drastically increase the speed of resync events by allowing the kernel to know precisely which portions of a disk need to be resynced instead of having to resync the entire array after a system crash. Note The resync is a process to synchronize the data over the devices in the existing RAID to achieve redundancy. Resync checkpointing so that if you reboot your computer during a resync, at startup the resync resumes where it left off and not starts all over again. The ability to change parameters of the array after installation, which is called reshaping. For example, you can grow a 4-disk RAID5 array to a 5-disk RAID5 array when you have a new device to add. This grow operation is done live and does not require you to reinstall on the new array. Reshaping supports changing the number of devices, the RAID algorithm or size of the RAID array type, such as RAID4, RAID5, RAID6, or RAID10. Takeover supports RAID level conversion, such as RAID0 to RAID6. Cluster MD, which is a storage solution for a cluster, provides the redundancy of RAID1 mirroring to the cluster. Currently, only RAID1 is supported. 18.3. RAID levels and linear support The following are the supported configurations by RAID, including levels 0, 1, 4, 5, 6, 10, and linear: Level 0 RAID level 0, often called striping, is a performance-oriented striped data mapping technique. This means the data being written to the array is broken down into stripes and written across the member disks of the array, allowing high I/O performance at low inherent cost but provides no redundancy. RAID level 0 implementations only stripe the data across the member devices up to the size of the smallest device in the array. This means that if you have multiple devices with slightly different sizes, each device gets treated as though it was the same size as the smallest drive. Therefore, the common storage capacity of a level 0 array is the total capacity of all disks. If the member disks have a different size, then the RAID0 uses all the space of those disks using the available zones. Level 1 RAID level 1, or mirroring, provides redundancy by writing identical data to each member disk of the array, leaving a mirrored copy on each disk. Mirroring remains popular due to its simplicity and high level of data availability. Level 1 operates with two or more disks, and provides very good data reliability and improves performance for read-intensive applications but at relatively high costs. RAID level 1 is costly because you write the same information to all of the disks in the array, which provides data reliability, but in a much less space-efficient manner than parity based RAID levels such as level 5. However, this space inefficiency comes with a performance benefit, which is parity-based RAID levels that consume considerably more CPU power in order to generate the parity while RAID level 1 simply writes the same data more than once to the multiple RAID members with very little CPU overhead. As such, RAID level 1 can outperform the parity-based RAID levels on machines where software RAID is employed and CPU resources on the machine are consistently taxed with operations other than RAID activities. The storage capacity of the level 1 array is equal to the capacity of the smallest mirrored hard disk in a hardware RAID or the smallest mirrored partition in a software RAID. Level 1 redundancy is the highest possible among all RAID types, with the array being able to operate with only a single disk present. Level 4 Level 4 uses parity concentrated on a single disk drive to protect data. Parity information is calculated based on the content of the rest of the member disks in the array. This information can then be used to reconstruct data when one disk in the array fails. The reconstructed data can then be used to satisfy I/O requests to the failed disk before it is replaced and to repopulate the failed disk after it has been replaced. Since the dedicated parity disk represents an inherent bottleneck on all write transactions to the RAID array, level 4 is seldom used without accompanying technologies such as write-back caching. Or it is used in specific circumstances where the system administrator is intentionally designing the software RAID device with this bottleneck in mind such as an array that has little to no write transactions once the array is populated with data. RAID level 4 is so rarely used that it is not available as an option in Anaconda. However, it could be created manually by the user if needed. The storage capacity of hardware RAID level 4 is equal to the capacity of the smallest member partition multiplied by the number of partitions minus one. The performance of a RAID level 4 array is always asymmetrical, which means reads outperform writes. This is because write operations consume extra CPU resources and main memory bandwidth when generating parity, and then also consume extra bus bandwidth when writing the actual data to disks because you are not only writing the data, but also the parity. Read operations need only read the data and not the parity unless the array is in a degraded state. As a result, read operations generate less traffic to the drives and across the buses of the computer for the same amount of data transfer under normal operating conditions. Level 5 This is the most common type of RAID. By distributing parity across all the member disk drives of an array, RAID level 5 eliminates the write bottleneck inherent in level 4. The only performance bottleneck is the parity calculation process itself. Modern CPUs can calculate parity very fast. However, if you have a large number of disks in a RAID 5 array such that the combined aggregate data transfer speed across all devices is high enough, parity calculation can be a bottleneck. Level 5 has asymmetrical performance, and reads substantially outperforming writes. The storage capacity of RAID level 5 is calculated the same way as with level 4. Level 6 This is a common level of RAID when data redundancy and preservation, and not performance, are the paramount concerns, but where the space inefficiency of level 1 is not acceptable. Level 6 uses a complex parity scheme to be able to recover from the loss of any two drives in the array. This complex parity scheme creates a significantly higher CPU burden on software RAID devices and also imposes an increased burden during write transactions. As such, level 6 is considerably more asymmetrical in performance than levels 4 and 5. The total capacity of a RAID level 6 array is calculated similarly to RAID level 5 and 4, except that you must subtract two devices instead of one from the device count for the extra parity storage space. Level 10 This RAID level attempts to combine the performance advantages of level 0 with the redundancy of level 1. It also reduces some of the space wasted in level 1 arrays with more than two devices. With level 10, it is possible, for example, to create a 3-drive array configured to store only two copies of each piece of data, which then allows the overall array size to be 1.5 times the size of the smallest devices instead of only equal to the smallest device, similar to a 3-device, level 1 array. This avoids CPU process usage to calculate parity similar to RAID level 6, but it is less space efficient. The creation of RAID level 10 is not supported during installation. It is possible to create one manually after installation. Linear RAID Linear RAID is a grouping of drives to create a larger virtual drive. In linear RAID, the chunks are allocated sequentially from one member drive, going to the drive only when the first is completely filled. This grouping provides no performance benefit, as it is unlikely that any I/O operations split between member drives. Linear RAID also offers no redundancy and decreases reliability. If any one member drive fails, the entire array cannot be used and data can be lost. The capacity is the total of all member disks. 18.4. Supported RAID conversions It is possible to convert from one RAID level to another. For example, you can convert from RAID5 to RAID10, but not from RAID10 to RAID5. The following table describes the supported RAID conversions: RAID conversion levels Conversion steps Notes RAID level 0 to RAID level 4 You need to add a disk to the MD array because it require at least 3 disks. RAID level 0 to RAID level 5 You need to add a disk to the MD array because it require at least 3 disks. RAID level 0 to RAID level 10 You need to add two extra disks to the MD array. RAID level 1 to RAID level 0 RAID level 1 to RAID level 5 RAID level 4 to RAID level 0 RAID level 4 to RAID level 5 RAID level 5 to RAID level 0 RAID level 5 to RAID level 1 RAID level 5 to RAID level 4 RAID level 5 to RAID level 6 RAID level 5 to RAID level 10 Converting RAID level 5 to RAID level 10 is a two step conversion: Convert to RAID level 0 Add two additional disks while converting to RAID10. RAID level 6 to RAID level 5 RAID level 10 to RAID level 0 Note Converting RAID 5 to RAID0 and RAID4 is only possible with the ALGORITHM_PARITY_N layout. After converting a RAID level, verify the conversion by using either the mdadm --detail /dev/md0 or cat /proc/mdstat command. Additional resources mdadm(8) man page on your system 18.5. RAID subsystems The following subsystems compose RAID: Hardware RAID Controller Drivers Hardware RAID controllers have no specific RAID subsystem. Since they use special RAID chipsets, hardware RAID controllers come with their own drivers. With these drivers, the system detects the RAID sets as regular disks. mdraid The mdraid subsystem was designed as a software RAID solution. It is also the preferred solution for software RAID in Red Hat Enterprise Linux. This subsystem uses its own metadata format, which is referred to as native MD metadata. It also supports other metadata formats, known as external metadata. Red Hat Enterprise Linux 9 uses mdraid with external metadata to access Intel Rapid Storage (ISW) or Intel Matrix Storage Manager (IMSM) sets and Storage Networking Industry Association (SNIA) Disk Drive Format (DDF). The mdraid subsystem sets are configured and controlled through the mdadm utility. 18.6. Creating a software RAID during the installation Redundant Arrays of Independent Disks (RAID) devices are constructed from multiple storage devices that are arranged to provide increased performance and, in some configurations, greater fault tolerance. A RAID device is created in one step and disks are added or removed as necessary. You can configure one RAID partition for each physical disk in your system, so that the number of disks available to the installation program determines the levels of RAID device available. For example, if your system has two disks, you cannot create a RAID 10 device, as it requires a minimum of three separate disks. To optimize your system's storage performance and reliability, RHEL supports software RAID 0 , RAID 1 , RAID 4 , RAID 5 , RAID 6 , and RAID 10 types with LVM and LVM Thin Provisioning to set up storage on the installed system. Note On 64-bit IBM Z, the storage subsystem uses RAID transparently. You do not have to configure software RAID manually. Prerequisites You have selected two or more disks for installation before RAID configuration options are visible. Depending on the RAID type you want to create, at least two disks are required. You have created a mount point. By configuring a mount point, you can configure the RAID device. You have selected the Custom radio button on the Installation Destination window. Procedure From the left pane of the Manual Partitioning window, select the required partition. Under the Device(s) section, click Modify . The Configure Mount Point dialog box opens. Select the disks that you want to include in the RAID device and click Select . Click the Device Type drop-down menu and select RAID . Click the File System drop-down menu and select your preferred file system type. Click the RAID Level drop-down menu and select your preferred level of RAID. Click Update Settings to save your changes. Click Done to apply the settings to return to the Installation Summary window. Additional resources Creating a RAID LV with DM integrity Managing RAID 18.7. Creating a software RAID on an installed system You can create a software Redundant Array of Independent Disks (RAID) on an existing system using the mdadm utility. Prerequisites The mdadm package is installed. You have created two or more partitions on your system. For detailed instructions, see Creating a partition with parted . Procedure Create a RAID of two block devices, for example /dev/sda1 and /dev/sdc1 : The level_value option defines the RAID level. Optional: Check the status of the RAID: Optional: Observe the detailed information about each device in the RAID: Create a file system on the RAID drive: Replace xfs with the file system that you chose to format the drive with. Create a mount point for RAID drive and mount it: Replace /mnt/raid1 with the mount point. If you want that RHEL mounts the md0 RAID device automatically when the system boots, add an entry for your device to the /etc/fstab file : 18.8. Creating RAID in the web console Configure RAID in the RHEL 9 web console. Prerequisites You have installed the RHEL 9 web console. You have enabled the cockpit service. Your user account is allowed to log in to the web console. For instructions, see Installing and enabling the web console . You have installed the cockpit-storaged package on your system. You have connected physical disks and they are visible by the system. Procedure Log in to the RHEL 9 web console. For details, see Logging in to the web console . In the panel, click Storage . In the Storage table, click the menu button and select Create MDRAID device . In the Create RAID Device field, enter a name for the new RAID. In the RAID Level drop-down list, select a level of RAID you want to use. From the Chunk Size drop-down list, select the size from the list of available options. The Chunk Size value specifies how large each block is for data writing. For example, if the chunk size is 512 KiB, the system writes the first 512 KiB to the first disk, the second 512 KiB is written to the second disk, and the third chunk is written to the third disk. If you have three disks in your RAID, the fourth 512 KiB is written to the first disk again. Select the disks you want to use for RAID. Click Create . Verification Go to the Storage section and check that you can see the new RAID in the RAID devices box. 18.9. Formatting RAID in the web console You can format and mount software RAID devices in the RHEL 9 web console. Formatting can take several minutes depending on the volume size and which formatting options are selected. Prerequisites You have installed the RHEL 9 web console. You have enabled the cockpit service. Your user account is allowed to log in to the web console. For instructions, see Installing and enabling the web console . You have installed the cockpit-storaged package. You have connected physical disks and they are visible by the system. You have created RAID. Procedure Log in to the RHEL 9 web console. For details, see Logging in to the web console . In the panel, click Storage . In the Storage table, click the menu button ... for the RAID device that you want to format. From the drop-down menu, select Format . In the Format field, enter a name. In the Mount Point field, add the mount path. From the Type drop-down list, select the type of file system. Optional: Check the Overwrite existing data with zeros option, if the disk includes any sensitive data and you want to overwrite them. Otherwise the RHEL web console rewrites only the disk header. In the Encryption drop-down menu, select the type of encryption. If you do not want to encrypt the volume, select No encryption . In the At boot drop-down menu, select when you want to mount the volume. In the Mount options section: If you want the to mount the volume as a read-only logical volume, select the Mount read only checkbox. If you want to change the default mount option, select the Custom mount options checkbox and add the mount options. Format the RAID partition: If you want to format and mount the partition, click the Format and mount button. If you want to only format the partition, click the Format only button. Verification After the formatting has completed successfully, you can see the details of the formatted logical volume in the Storage table on the Storage page. 18.10. Creating a partition table on RAID by using the web console Format RAID with the partition table on the new software RAID device created in the RHEL 9 interface. Prerequisites You have installed the RHEL 9 web console. You have enabled the cockpit service. Your user account is allowed to log in to the web console. For instructions, see Installing and enabling the web console . You have installed the cockpit-storaged package. You have connected physical disks and they are visible by the system. You have created RAID. Procedure Log in to the RHEL 9 web console. For details, see Logging in to the web console . In the panel, click Storage . In the Storage table, click the RAID device on which you want to create a partition table. Click the menu button ... in the MDRAID device section. From the drop-down menu, select Create partition table . In the Initialize disk dialog box, select the following: Partitioning : If the partition should be compatible with all systems and devices, select MBR . If the partition should be compatible with modern system and hard disks must be greater than 2 TB, select GPT . If you do not need partitioning, select No partitioning . Overwrite : Check the Overwrite existing data with zeros option if the disk includes any sensitive data and you want to overwrite them. Otherwise the RHEL web console rewrites only the disk header. Click Initialize . 18.11. Creating partitions on RAID by using the web console Create a partition in the existing partition table. You can create more partitions after the partition is created. Prerequisites The RHEL 9 web console is installed and accessible. For details, see Installing the web console . The cockpit-storaged package is installed on your system. A partition table on RAID is created. Procedure Log in to the RHEL 9 web console. For details, see Logging in to the web console . In the panel, click Storage . Click the RAID device on which you want to create a partition. On the RAID device page, scroll to the GPT partitions section and click the menu button [...]. Click Create partition and enter a name for the file system in the Create partition field. Do not use spaces in the name. In the Mount Point field, enter the mount path. In the Type drop-down list, select the type of file system. In the Size slider, set the size of the partition. Optional: Select Overwrite existing data with zeros , if the disk includes any sensitive data and you want to overwrite them. Otherwise the RHEL web console rewrites only the disk header. In the Encryption drop-down menu, select the type of encryption. If you do not want to encrypt the volume, select No encryption . In the At boot drop-down menu, select when you want to mount the volume. In the Mount options section: If you want to mount the volume as a read-only logical volume, select the Mount read only checkbox. If you want to change the default mount option, select the Custom mount options checkbox and add the mount options. Create the partition: If you want to create and mount the partition, click the Create and mount button. If you want to only create the partition, click the Create only button. Formatting can take several minutes depending on the volume size and which formatting options are selected. Verification You can see the details of the formatted logical volume in the Storage table on the main storage page. 18.12. Creating a volume group on top of RAID by using the web console Build a volume group from software RAID. Prerequisites You have installed the RHEL 9 web console. You have enabled the cockpit service. Your user account is allowed to log in to the web console. For instructions, see Installing and enabling the web console . You have installed the cockpit-storaged package. You have a RAID device that is not formatted and not mounted. Procedure Log in to the RHEL 9 web console. For details, see Logging in to the web console . In the panel, click Storage . In the Storage table, click the menu button [...] and select Create LVM2 volume group . In the Create LVM2 volume group field, enter a name for the new volume group. From the Disks list, select a RAID device. If you do not see the RAID in the list, unmount the RAID from the system. The RAID device must not be in use by the RHEL 9 system. Click Create . 18.13. Configuring a RAID volume by using the storage RHEL system role With the storage system role, you can configure a RAID volume on RHEL by using Red Hat Ansible Automation Platform and Ansible-Core. Create an Ansible playbook with the parameters to configure a RAID volume to suit your requirements. Warning Device names might change in certain circumstances, for example, when you add a new disk to a system. Therefore, to prevent data loss, use persistent naming attributes in the playbook. For more information about persistent naming attributes, see Persistent naming attributes . Prerequisites You have prepared the control node and the managed nodes You are logged in to the control node as a user who can run playbooks on the managed nodes. The account you use to connect to the managed nodes has sudo permissions on them. Procedure Create a playbook file, for example ~/playbook.yml , with the following content: --- - name: Manage local storage hosts: managed-node-01.example.com tasks: - name: Create a RAID on sdd, sde, sdf, and sdg ansible.builtin.include_role: name: rhel-system-roles.storage vars: storage_safe_mode: false storage_volumes: - name: data type: raid disks: [sdd, sde, sdf, sdg] raid_level: raid0 raid_chunk_size: 32 KiB mount_point: /mnt/data state: present For details about all variables used in the playbook, see the /usr/share/ansible/roles/rhel-system-roles.storage/README.md file on the control node. Validate the playbook syntax: Note that this command only validates the syntax and does not protect against a wrong but valid configuration. Run the playbook: Verification Verify that the array was correctly created: Additional resources /usr/share/ansible/roles/rhel-system-roles.storage/README.md file /usr/share/doc/rhel-system-roles/storage/ directory 18.14. Extending RAID You can extend a RAID using the --grow option of the mdadm utility. Prerequisites Enough disk space. The parted package is installed. Procedure Extend RAID partitions. For more information, see Resizing a partition with parted . Extend RAID to the maximum of the partition capacity: To set a specific size, write the value of the --size parameter in kB, for example --size= 524228 . Increase the size of file system. For example, if the volume uses XFS and is mounted to /mnt/ , enter: Additional resources mdadm(8) man page on your system Managing file systems 18.15. Shrinking RAID You can shrink RAID using the --grow option of the mdadm utility. Important The XFS file system does not support shrinking. Prerequisites The parted package is installed. Procedure Shrink the file system. For more information, see Managing file systems . Decrease the RAID to the size, for example to 512 MB : Write the --size parameter in kB. Shrink the partition to the size you need. Additional resources mdadm(8) man page on your system Resizing a partition with parted 18.16. Converting a root disk to RAID1 after installation You can convert a non-RAID root disk to a RAID1 mirror after installing Red Hat Enterprise Linux 9. On the PowerPC (PPC) architecture, take the following additional steps: Prerequisites Completed the steps in the Red Hat Knowledgebase solution How do I convert my root disk to RAID1 after installation of Red Hat Enterprise Linux 7? . Note Executing the grub2-install /dev/sda command does not work on a PowerPC machine and returns an error, but the system boots as expected. Procedure Copy the contents of the PowerPC Reference Platform (PReP) boot partition from /dev/sda1 to /dev/sdb1 : Update the prep and boot flag on the first partition on both disks: 18.17. Creating advanced RAID devices In some cases, you might want to install the operating system on an array that is created before the installation completes. Usually, this means setting up the /boot or root file system arrays on a complex RAID device. In such cases, you might need to use array options that are not supported by the Anaconda installer. To work around this, perform the following steps. Note The limited Rescue Mode of the installer does not include man pages. Both the mdadm and md man pages contain useful information for creating custom RAID arrays, and might be needed throughout the workaround. Procedure Insert the install disk. During the initial boot up, select Rescue Mode instead of Install or Upgrade . When the system fully boots into Rescue mode , you can see the command line terminal. From this terminal, execute the following commands: Create RAID partitions on the target hard drives by using the parted command. Manually create raid arrays by using the mdadm command from those partitions using any and all settings and options available. Optional: After creating arrays, create file systems on the arrays as well. Reboot the computer and select Install or Upgrade to install. As the Anaconda installer searches the disks in the system, it finds the pre-existing RAID devices. When asked about how to use the disks in the system, select Custom Layout and click . In the device listing, the pre-existing MD RAID devices are listed. Select a RAID device and click Edit . Configure its mount point and optionally the type of file system it should use if you did not create one earlier, and then click Done . Anaconda installs to this pre-existing RAID device, preserving the custom options you selected when you created it in Rescue Mode. 18.18. Setting up email notifications to monitor a RAID You can set up email alerts to monitor RAID with the mdadm tool. Once the MAILADDR variable is set to the required email address, the monitoring system sends the alerts to the added email address. Prerequisites The mdadm package is installed. The mail service is set up. Procedure Create the /etc/mdadm.conf configuration file for monitoring array by scanning the RAID details: Note, that ARRAY and MAILADDR are mandatory variables. Open the /etc/mdadm.conf configuration file with a text editor of your choice and add the MAILADDR variable with the mail address for the notification. For example, add new line: Here, example@example.com is an email address to which you want to receive the alerts from the array monitoring. Save changes in the /etc/mdadm.conf file and close it. Additional resources mdadm.conf(5) man page on your system 18.19. Replacing a failed disk in RAID You can reconstruct the data from the failed disks using the remaining disks. RAID level and the total number of disks determines the minimum amount of remaining disks needed for a successful data reconstruction. In this procedure, the /dev/md0 RAID contains four disks. The /dev/sdd disk has failed and you need to replace it with the /dev/sdf disk. Prerequisites A spare disk for replacement. The mdadm package is installed. Procedure Check the failed disk: View the kernel logs: Search for a message similar to the following: Press Ctrl + C on your keyboard to exit the journalctl program. Mark the failed disk as faulty: Optional: Check if the failed disk was marked correctly: At the end of the output is a list of disks in the /dev/md0 RAID where the disk /dev/sdd has the faulty status: Remove the failed disk from the RAID: Warning If your RAID cannot withstand another disk failure, do not remove any disk until the new disk has the active sync status. You can monitor the progress using the watch cat /proc/mdstat command. Add the new disk to the RAID: The /dev/md0 RAID now includes the new disk /dev/sdf and the mdadm service will automatically starts copying data to it from other disks. Verification Check the details of the array: If this command shows a list of disks in the /dev/md0 RAID where the new disk has spare rebuilding status at the end of the output, data is still being copied to it from other disks: After data copying is finished, the new disk has an active sync status. Additional resources Setting up email notifications to monitor a RAID 18.20. Repairing RAID disks You can repair disks in a RAID array by using the repair option. Prerequisites The mdadm package is installed. Procedure Check the array for the failed disks behavior: This checks the array and the /sys/block/md0/md/sync_action file shows the sync action. Open the /sys/block/md0/md/sync_action file with the text editor of your choice and see if there is any message about disk synchronization failures. View the /sys/block/md0/md/mismatch_cnt file. If the mismatch_cnt parameter is not 0 , it means that the RAID disks need repair. Repair the disks in the array: This repairs the disks in the array and writes the result into the /sys/block/md0/md/sync_action file. View the synchronization progress:

Commands:
mdadm --grow /dev/md0 --level=4 -n3 --add /dev/vdd
mdadm --grow /dev/md0 --level=5 -n3 --add /dev/vdd
mdadm --grow /dev/md0 --level 10 -n 4 --add /dev/vd[ef]
mdadm --grow /dev/md0 -l0
mdadm --grow /dev/md0 --level=5
mdadm --grow /dev/md0 --level=0
mdadm --grow /dev/md0 --level=5
mdadm --grow /dev/md0 --level=0
mdadm -CR /dev/md0 -l5 -n3 /dev/sd[abc] --assume-clean --size 1G mdadm -D /dev/md0 | grep Level mdadm --grow /dev/md0 --array-size 1048576 mdadm --grow -n 2 /dev/md0 --backup=internal mdadm --grow -l1 /dev/md0 mdadm -D /dev/md0 | grep Level
mdadm --grow /dev/md0 --level=4
mdadm --grow /dev/md0 --level=6 --add /dev/vde
mdadm --grow /dev/md0 --level=0 # mdadm --grow /dev/md0 --level=10 --add /dev/vde /dev/vdf
mdadm --grow /dev/md0 --level=5
mdadm --grow /dev/md0 --level=0
mdadm --create /dev/md0 --level= 0 --raid-devices=2 /dev/sda1 /dev/sdc1 mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started.
mdadm --detail /dev/md0 /dev/md0: Version : 1.2 Creation Time : Thu Oct 13 15:17:39 2022 Raid Level : raid0 Array Size : 18649600 (17.79 GiB 19.10 GB) Raid Devices : 2 Total Devices : 2 Persistence : Superblock is persistent Update Time : Thu Oct 13 15:17:39 2022 State : clean Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 [...]
mdadm --examine /dev/sda1 /dev/sdc1 /dev/sda1: Magic : a92b4efc Version : 1.2 Feature Map : 0x1000 Array UUID : 77ddfb0a:41529b0e:f2c5cde1:1d72ce2c Name : 0 Creation Time : Thu Oct 13 15:17:39 2022 Raid Level : raid0 Raid Devices : 2 [...]
mkfs -t xfs /dev/md0
mkdir /mnt/raid1 mount /dev/md0 /mnt/raid1
/dev/md0 /mnt/raid1 xfs defaults 0 0
--- - name: Manage local storage hosts: managed-node-01.example.com tasks: - name: Create a RAID on sdd, sde, sdf, and sdg ansible.builtin.include_role: name: rhel-system-roles.storage vars: storage_safe_mode: false storage_volumes: - name: data type: raid disks: [sdd, sde, sdf, sdg] raid_level: raid0 raid_chunk_size: 32 KiB mount_point: /mnt/data state: present
ansible-playbook --syntax-check ~/playbook.yml
ansible-playbook ~/playbook.yml
ansible managed-node-01.example.com -m command -a 'mdadm --detail /dev/md/data'
mdadm --grow --size=max /dev/md0
xfs_growfs /mnt/
mdadm --grow --size= 524228 /dev/md0
dd if= /dev/sda1 of= /dev/sdb1
parted /dev/sda set 1 prep on parted /dev/sda set 1 boot on parted /dev/sdb set 1 prep on parted /dev/sdb set 1 boot on
mdadm --detail --scan >> /etc/mdadm.conf
MAILADDR example@example.com
journalctl -k -f
md/raid:md0: Disk failure on sdd, disabling device. md/raid:md0: Operation continuing on 3 devices.
mdadm --manage /dev/md0 --fail /dev/sdd
mdadm --detail /dev/md0
Number Major Minor RaidDevice State 0 8 16 0 active sync /dev/sdb 1 8 32 1 active sync /dev/sdc - 0 0 2 removed 3 8 64 3 active sync /dev/sde 2 8 48 - faulty /dev/sdd
mdadm --manage /dev/md0 --remove /dev/sdd
mdadm --manage /dev/md0 --add /dev/sdf
mdadm --detail /dev/md0
Number Major Minor RaidDevice State 0 8 16 0 active sync /dev/sdb 1 8 32 1 active sync /dev/sdc 4 8 80 2 spare rebuilding /dev/sdf 3 8 64 3 active sync /dev/sde
echo check > /sys/block/ md0 /md/sync_action
echo repair > /sys/block/ md0 /md/sync_action
cat /sys/block/ md0 /md/sync_action repair cat /proc/mdstat Personalities : [raid0] [raid6] [raid5] [raid4] [raid1] md0 : active raid1 sdg[1] dm-3[0] 511040 blocks super 1.2 [2/2] [UU] unused devices: &lt;none&gt;