How To Configure RAID 6 On Linux Mint 20.2

To Configure RAID 6 on Linux Mint 20.2

Introduction:

RAID 6, also known as double-parity RAID (redundant array of independent disks), is one of several RAID schemes that work by placing data on multiple disks and allowing input/output (I/O) operations to overlap in a balanced way, improving performance. Not all types of RAID offer redundancy, although RAID 6 does.

Installation Procedure :

Step 1 : Check the OS version by using the below command

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Linuxmint
Description:	Linux Mint 20.2
Release:	20.2
Codename:	uma

Step 2 : List the Disks by using the below command

root@linuxhelp:~# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   60G  0 disk 
└─sda1   8:1    0   60G  0 part /
sdb      8:16   0    5G  0 disk 
sdc      8:32   0    4G  0 disk 
sdd      8:48   0   10G  0 disk 
sde      8:64   0   10G  0 disk 
sdf      8:80   0    6G  0 disk 
sdg      8:96   0   12G  0 disk 
sr0     11:0    1 1024M  0 rom  

Step 3 : Create partitions on those following disks

root@linuxhelp:~# fdisk /dev/sdb

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.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x88fd26ae.

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): 
First sector (2048-10485759, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485759, default 10485759): +2g

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

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.

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

Step 4 : Follow the same method to create all the partitions by using the below command

root@linuxhelp:~# fdisk /dev/sdc

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.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xdf7830ba.

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): 
First sector (2048-8388607, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-8388607, default 8388607): +2g

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

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.

Command (m for help): wq
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@linuxhelp:~# fdisk /dev/sdd

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.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xf5801994.

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): 
First sector (2048-20971519, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971519, default 20971519): +2g

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

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.

Command (m for help): wq
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@linuxhelp:~# fdisk /dev/sde

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.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xc304af18.

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): 
First sector (2048-20971519, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971519, default 20971519): +2g

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

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.

Command (m for help): wq
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@linuxhelp:~# fdisk /dev/sdf

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.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x3daeb6da.

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): 
First sector (2048-12582911, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-12582911, default 12582911): +2g

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

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.

Command (m for help): wq
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@linuxhelp:~# fdisk /dev/sdg

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.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x714aaee0.

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): 
First sector (2048-25165823, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-25165823, default 25165823): +2g

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

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.

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

Step 5 : List the disks by using the below command

root@linuxhelp:~# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   60G  0 disk 
└─sda1   8:1    0   60G  0 part /
sdb      8:16   0    5G  0 disk 
└─sdb1   8:17   0    2G  0 part 
sdc      8:32   0    4G  0 disk 
└─sdc1   8:33   0    2G  0 part 
sdd      8:48   0   10G  0 disk 
└─sdd1   8:49   0    2G  0 part 
sde      8:64   0   10G  0 disk 
└─sde1   8:65   0    2G  0 part 
sdf      8:80   0    6G  0 disk 
└─sdf1   8:81   0    2G  0 part 
sdg      8:96   0   12G  0 disk 
└─sdg1   8:97   0    2G  0 part 
sr0     11:0    1 1024M  0 rom  

Step 6 : Once created the partitions now create a RAID

root@linuxhelp:~# mdadm -C /dev/md0 -l 6 -n 4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

Step 7 : Now format the raid to ext4 file by using the below command

root@linuxhelp:~# mkfs.ext4 /dev/md0
mke2fs 1.45.5 (07-Jan-2020)
Creating filesystem with 1047040 4k blocks and 262144 inodes
Filesystem UUID: ee03e654-6b16-4786-8687-32def08eaa5a
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

Step 8 : Check the details of RAID partition by using the below command

root@linuxhelp:~# mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Sun Jan  9 04:31:18 2022
        Raid Level : raid6
        Array Size : 4188160 (3.99 GiB 4.29 GB)
     Used Dev Size : 2094080 (2045.00 MiB 2144.34 MB)
      Raid Devices : 4
     Total Devices : 4
       Persistence : Superblock is persistent

       Update Time : Sun Jan  9 04:33:09 2022
             State : clean 
    Active Devices : 4
   Working Devices : 4
    Failed Devices : 0
     Spare Devices : 0


    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       8       33        1      active sync   /dev/sdc1
       2       8       49        2      active sync   /dev/sdd1
       3       8       65        3      active sync   /dev/sde1

Step 9 : Create the directory in the name of details to mount by using the below command

root@linuxhelp:~# mkdir details

Step 10 : Mount the RAID in the details directory by using the below command

root@linuxhelp:~# mount /dev/md0 details/

Step 11 : Now check the mounted directory by using the below command

root@linuxhelp:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           391M  1.7M  390M   1% /run
/dev/sda1        59G  8.7G   48G  16% /
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
tmpfs           391M   20K  391M   1% /run/user/1000
/dev/md0        3.9G   16M  3.7G   1% /root/details

Step 12 : To get into the details directory use the below command

root@linuxhelp:~# cd details/

Step 13 : Create the empty file inside the details directory by using the below command

root@linuxhelp:~/details# touch linuxhelp.txt

Step 14 : Now edit the following file by using the below command

root@linuxhelp:~/details# nano linuxhelp.txt 

Step 15 : List the directory by using the following command

root@linuxhelp:~/details# ls -la
total 28
drwxr-xr-x 3 root root  4096 Jan  9 04:46 .
drwx------ 6 root root  4096 Jan  9 04:44 ..
-rw-r--r-- 1 root root    23 Jan  9 04:46 linuxhelp.txt
drwx------ 2 root root 16384 Jan  9 04:33 lost+found

Step 16: To Fail the 2 disks by using the below command

root@linuxhelp:~/details# mdadm /dev/md0 -f /dev/sdc1 /dev/sde1
mdadm: set /dev/sdc1 faulty in /dev/md0
mdadm: set /dev/sde1 faulty in /dev/md0

Step 17 : Check the details of the Raid partitions by using the below command

root@linuxhelp:~/details# mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Sun Jan  9 04:31:18 2022
        Raid Level : raid6
        Array Size : 4188160 (3.99 GiB 4.29 GB)
     Used Dev Size : 2094080 (2045.00 MiB 2144.34 MB)
      Raid Devices : 4
     Total Devices : 4
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 2
     Spare Devices : 0
    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       -       0        0        1      removed
       2       8       49        2      active sync   /dev/sdd1
       -       0        0        3      removed

       1       8       33        -      faulty   /dev/sdc1
       3       8       65        -      faulty   /dev/sde1

Step 18 : Remove the failed disks by using the below command

root@linuxhelp:~/details# mdadm /dev/md0 -r /dev/sdc1 /dev/sde1
mdadm: hot removed /dev/sdc1 from /dev/md0
mdadm: hot removed /dev/sde1 from /dev/md0

step 19 : Add the new disks by using the below command

root@linuxhelp:~/details# mdadm /dev/md0 --add /dev/sdf1 /dev/sdg1
mdadm: added /dev/sdf1
mdadm: added /dev/sdg1

Step 20 : Check the details in the RAID partitions by using the below command

root@linuxhelp:~/details# mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Sun Jan  9 04:31:18 2022
        Raid Level : raid6
        Array Size : 4188160 (3.99 GiB 4.29 GB)
     Used Dev Size : 2094080 (2045.00 MiB 2144.34 MB)
      Raid Devices : 4
     Total Devices : 4
    Active Devices : 4
   Working Devices : 4
    Failed Devices : 0
     Spare Devices : 0
 Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       5       8       97        1      active sync   /dev/sdg1
       2       8       49        2      active sync   /dev/sdd1
       4       8       81        3      active sync   /dev/sdf1

Step 21 : List the Directory and check whether any data lose or file corrupted by using the below command

root@linuxhelp:~/details# ls -la
total 28
drwxr-xr-x 3 root root  4096 Jan  9 04:46 .
drwx------ 6 root root  4096 Jan  9 04:44 ..
-rw-r--r-- 1 root root    23 Jan  9 04:46 linuxhelp.txt
drwx------ 2 root root 16384 Jan  9 04:33 lost+found

Step 22 : List the partition and the RAID is working perfectly by using the below command

root@linuxhelp:~/details# lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda       8:0    0   60G  0 disk  
└─sda1    8:1    0   60G  0 part  /
sdb       8:16   0    5G  0 disk  
└─sdb1    8:17   0    2G  0 part  
  └─md0   9:0    0    4G  0 raid6 /root/details
sdc       8:32   0    4G  0 disk  
└─sdc1    8:33   0    2G  0 part  
sdd       8:48   0   10G  0 disk  
└─sdd1    8:49   0    2G  0 part  
  └─md0   9:0    0    4G  0 raid6 /root/details
sde       8:64   0   10G  0 disk  
└─sde1    8:65   0    2G  0 part  
sdf       8:80   0    6G  0 disk  
└─sdf1    8:81   0    2G  0 part  
  └─md0   9:0    0    4G  0 raid6 /root/details
sdg       8:96   0   12G  0 disk  
└─sdg1    8:97   0    2G  0 part  
  └─md0   9:0    0    4G  0 raid6 /root/details
sr0      11:0    1 1024M  0 rom   

With this, the process of Configuring RAID 6 On Linux Mint 20.2 has comes to an end…!!!

FAQ
Q
How can we add the new disks to the RAID partitions?
A
We can add the new disks to the RAID partitions by using the mdadm /dev/md0 --add /dev/sdf1 /dev/sdg1 command.
Q
How can we fail the disk on RAID?
A
We can fail the disk on RAID by using the Command mdadm /dev/md0 -f /dev/sdc1 /dev/sde1
Q
How to format the RAID to ext4 file?
A
To format the RAID to ext4 file using the mkfs.ext4 /dev/md0 command.
Q
How do you create the RAID partitions?
A
To create a RAID partition using the command mdadm -C /dev/md0 -l 6 -n 4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
Q
How to create a partition using the command?
A
To create a partition using the command fdisk /dev/sdb