Its been quite long I did not post any article under the category “Linux System” on my blog. Recently, I configured a RAID1 (Mirroring data across 2 disks.) at work. Since, I do not have any article that covered that one, so let me just present how it was done.
Once the two physical disks are inserted on the server, consider checking if the disks have been detected. So, the two disks have been detected as /dev/sdc and /dev/sdd. For security reasons, I am hiding the name of the hostname and other sensitive data.
1. This is the output of the lsblk. As you can see sdc and sdd are 223.6G each:
2. Then, format the disk as follows. Repeat same action for the disk /dev/sdd:
fdisk /dev/sdc option n -> choose p option p -> choose 1 option t -> choose 1 hex code -> fd option w to write and save.
3. Time to confirm if disk has been formatted using mdadm command. I used the following:
mdadm -E /dev/sd[c-d]
4. Since it has been detected as type “fd”, we are good to start the mirroring using mdadm. The mirrored disk will be called /dev/md0:
mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sd[c-d]1
5. You can now check the progress whilst it is being mirrored using the following:
cat /prod/mdstat
6. Once mirroring is completed, create a file system on /dev/md0
mkfs.ext4 /dev/md0
7. You can now create a directory where it need to be mounted:
mkdir /home/backup
8. Find the UUID of the disk using ‘blkid’ command:
blkid | grep "/dev/md0"
9. Insert the Entry in the fstab:
UUID=<UUID here> /home/backup ext4 defaults 1 1
10. I then fired a mount all in verbose mode.
mount -av
11. You can also check if the two devices are seen on raid1