PARTITION HARD DISKS
The first thing we’ll need to do to configure our hard disks is to partition them as Linux RAID auto.
STEP1
We can see our hard disks by using the fdisk command. This will show us how they are named, which we will need for future commands. As you can see in the screenshot below, our disks are called /dev/sdb and /dev/sdc. These disks are just raw storage at the moment – they don’t have a partition table or anything else configured.
fdisk -l

fdisk shows our two disks that we plan to use for our RAID 1 setup
STEP2
Use the following command to begin partitioning the first disk. This will open up the fdisk menu. Substitute your own disk name if yours is different.
fdisk /dev/sdb
STEP3
We will enter the following commands into the fdisk prompts in order to create a new partition and configure it as Linux RAID autodetect.
1. Enter n to create a new partition.
2. Enter p to mark this as a primary partition.
3. Enter 1 for the partition number.
4. For first and last sector (2 prompts), just press the enter key for default response.
5. Enter t to select the partition we’ve just created.
6. Enter fd to configure Linux RAID autodetect on the partition.
7. Enter w to write all these changes to the disk.

Partitioning the hard disk
STEP4
We now need to do the exact same steps for our second disk. In our case, that would be disk /dev/sdc. Repeat Step 2 and Step 3 for your second disk. Afterwards, you should be able to see your newly configured RAID partitions with the fdisk command.
fdisk -l

Both drives have been partitioned as Linux RAID autodetect
CREATE RAID DEVICE
Now that we have our hard drives properly partitioned, we can use mdadm to create a RAID device with the following command. Remember that even though we have two hard drives, the system will see them as a single device and mirroring will happen in the background.
STEP1
Create a RAID array called /dev/md0 with this command, substituting your own drive names as necessary.
mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
STEP2
Next, put a file system on the device. We’ll use ext4 in this example.
mkfs.ext4 /dev/md0
STEP3
Now, make a directory to where you can mount the newly created RAID device. And then mount the device there.
mkdir -p /mnt/raid1
mount /dev/md0 /mnt/raid1
STEP4
Your RAID array should now be accessible at the mount point you defined.
cd /mnt/raid1
We can access our mounted RAID array and also use the df command to view details about it
CONFIGURE PERSISTENT RAID MOUNT
The only issue now is that your RAID mount will not survive a reboot. To avoid needing to manually mount it every time, we can configure the fstab file. We’ll also save our mdadm configuration in the following steps.
STEP1
Edit the fstab file with nano or your favorite text editor,
nano /etc/fstab
and add the following line.
/dev/md0 /mnt/raid1 ext4 defaults 0 0

Adding the RAID mount to fstab file
STEP2
Next, use the following command to save your current mdadm configuration.
mdadm -D --scan >> /etc/mdadm/mdadm.conf
update-initramfs -u -k all
That’s all there is to it. If you’ve made it this far, you should now have a working RAID 1 array that stays mounted even after a system reboot.


