To create a Software RAID 1 (mirror) array on CentOS or Red Hat Enterprise Linux (RHEL), you can use the mdadm
utility.
mdadm
package using the yum
package manager:sudo yum install mdadm
Connect the disks that you want to use for the RAID 1 array to your system.
Identify the device names of the disks that you want to use for the RAID 1 array. You can do this by running the lsblk
command or by looking in the /dev/
directory.
Create the RAID 1 array using the mdadm
command. For example, to create a RAID 1 array using the /dev/sdb
and /dev/sdc
disks:
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
This will create the RAID 1 array using the specified disks. The --level=1
option specifies that the array should be a RAID 1 (mirror) array, and the --raid-devices=2
option specifies that the array should be created using two disks.
sudo mdadm --detail /dev/md0
This will display information about the RAID 1 array, including the status of the array and the devices that it is using.
ext4
file system on the array:sudo mkfs.ext4 /dev/md0
/mnt/raid1
mount point:sudo mount /dev/md0 /mnt/raid1
/etc/fstab
file and add an entry for the RAID 1 array to mount it automatically at boot. For example:/dev/md0 /mnt/raid1 ext4 defaults 0 0
The RAID 1 array is now set up and will be mounted automatically at boot.
Note: These steps assume that the disks that you are using for the RAID 1 array are not currently in use. If the disks are already in use, you will need to partition and format them before creating the RAID 1 array. You should also be careful when creating a RAID 1 array, as it involves modifying the disks and data on them. It is a good idea to make a backup of any important data on the disks before proceeding.