To create a Software RAID 1 array in CentOS or Redhat, you can follow the steps below:
- Identify the disks that you want to use for the RAID array. In this example, we will assume that the disks are named /dev/sda and /dev/sdb.
- Partition the disks using the fdisk utility. For each disk, create a primary partition of type “fd” (Linux RAID autodetect) and make it the same size as the other disk’s partition.
- Create the RAID array using the mdadm utility. Run the following command to create a RAID 1 array with two disks:
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
In this command, “/dev/md0” is the name of the new RAID array, “–level=1” specifies that it should be a RAID 1 array, and “–raid-devices=2” indicates that there will be two disks in the array. Finally, “/dev/sda1” and “/dev/sdb1” are the partitions that will be used for the array.
- Format the new RAID array with the desired file system. For example, to format it with ext4:
sudo mkfs.ext4 /dev/md0
- Mount the new RAID array to a directory. For example, to mount it to the /data directory:
sudo mkdir /data
sudo mount /dev/md0 /data
- Verify that the RAID array is working correctly by checking its status with the mdadm utility:
sudo mdadm --detail /dev/md0
This should show information about the new RAID array, including its status and the disks that are part of it.
- Update the /etc/mdadm.conf file to make the RAID array configuration persistent:
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.conf
This will add a line to the end of the file that specifies the RAID array configuration, so that it will be automatically assembled at boot time.