Linux Create Software RAID 1 (Mirror) Array

https:/‮w/‬ww.lautturi.com
Linux Create Software RAID 1 (Mirror) Array

To create a software RAID 1 (mirror) array on a Linux system, you will need two or more block devices (e.g., hard drives, SSDs) that you want to use as part of the RAID array, and a system that supports software RAID.

Here is an example of how to create a software RAID 1 (mirror) array on a Linux system:

  1. Identify the block devices that you want to use in the RAID array. The first step is to identify the block devices that you want to use in the RAID array. You can use the lsblk command to list the block devices on your system, and look for the device names of the block devices (e.g., /dev/sda, /dev/sdb, etc.).

For example, to list the block devices on your system, you can use the following command:

$ lsblk
  1. Create a partition on each block device. Next, you will need to create a partition on each block device that you want to use in the RAID array. You can use a partitioning tool such as fdisk or parted to create the partitions.

For example, to create a partition on the block device /dev/sda using fdisk, you can use the following commands:

$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-209715199, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-209715199, default 209715199): 

Created a new partition 1 of type 'Linux' and of size 100 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

You will need to repeat these steps for each block device that you want to use in the RAID array.

  1. Create the RAID array. Once you have created the partitions on the block devices, you can use the mdadm command to create the RAID array. The mdadm command is a utility that is used to manage software RAID arrays on Linux systems.

To create a RAID 1 (mirror) array, you can use the mdadm command with the --create option and specify the name of the RAID device, the RAID level (1 for mirror), and the block devices that you want to include in the array.

For example, to create a RAID 1 (mirror) array with the name /dev/md0 using the block devices /dev/sda1 and /dev/sdb1, you can use the following command:

$ sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /
Created Time:2017-10-29 22:08:52  Author:lautturi