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/sdc
Note: 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/sdc1
Note: 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/md0
Note: 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/raid1
Note: 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 -u
Note: This step may not be necessary on all systems, depending on the distribution and version of Linux.
Once the RAID array is created and mounted, you can use it like any other file system. The data written to one disk will be mirrored to the other disk, providing redundancy in case of a disk failure.