Linux Create Software RAID 1 (Mirror) Array
In Linux, you can create a software RAID 1 (mirror) array using the mdadm utility. Here are the steps to create a RAID 1 array:
- Check the current disk configuration using the
fdiskcommand:# fdisk -l - Partition the disks that will be used in the RAID array using the
fdiskcommand:# fdisk /dev/sdb # fdisk /dev/sdcNote: Replace
/dev/sdband/dev/sdcwith the appropriate disk device names for your system. - Create a RAID 1 array using the
mdadmcommand:# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1Note: Replace
/dev/md0,/dev/sdb1, and/dev/sdc1with the appropriate device names for your system. The--level=1option specifies that the array should be a RAID 1 (mirror) array, and the--raid-devices=2option specifies that there will be two disks in the array. - Format the RAID array using the
mkfscommand:# mkfs.ext4 /dev/md0Note: Replace
/dev/md0with the appropriate device name for your system. - Create a mount point for the RAID array:
# mkdir /mnt/raid1 - Mount the RAID array using the
mountcommand:# mount /dev/md0 /mnt/raid1Note: Replace
/dev/md0and/mnt/raid1with the appropriate device and mount point names for your system. - Add the RAID array to the
mdadmconfiguration file so that it will be automatically assembled at boot time:# mdadm --detail --scan >> /etc/mdadm.conf - Update the
initramfsimage to include the RAID array configuration:# update-initramfs -uNote: This step may not be necessary on all systems, depending on the distribution and version of Linux.
