How to Configure and Test RAID 5 on Linux Mint 20
To Configure and Test RAID 5 on Linux Mint 20
Introduction:
RAID is a data storage virtualization technology that combines multiple physical disk drive components into one or more logical units for the purposes of data redundancy, performance improvement. RAID 5 is a redundant array of self-supporting disks configuration that utilizes disk striping with parity. Because the data and parity are striped uniformly across all of the disks. Striping also allows users to reconstruct data in case of a disk failure. RAID 5 groups have a minimum of three hard disk drives (HDDs) and no maximum. Because the parity data is spread across all drives, RAID 5 is considered one of the most secure RAID configurations. This tutorial will cover Configure and Test RAID 5 on Linux Mint 20.
Installation Procedure:
First check the version of Linux mint OS
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Linuxmint
Description: Linux Mint 20
Release: 20
Codename: ulyana
List the disk information by using the following command
root@linuxhelp:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 3.7G 0 part /swap
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 976M 0 part /boot
└─sda6 8:6 0 15.3G 0 part /
sdb 8:16 0 20G 0 disk
sdc 8:32 0 20G 0 disk
sdd 8:48 0 2G 0 disk
sde 8:64 0 2G 0 disk
sr0 11:0 1 1.9G 0 rom
Now I will create a partition of SDB,SDC,SDD drives by executing following command
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 0x2173ae80.
Press n to create new partition
Command (m for help): n
Enter the type of partition
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-41943039, default 2048):
Entre the size of the partition
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039): +1G
Created a new partition 1 of type 'Linux' and of size 1 GiB.
Press t to change the partition format
Command (m for help): t
Selected partition 1
Enter the code of partition
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.
Press w to write the partition
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
I follow the above steps to create partition of SDC and SDD drives
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 0x365a8cf0.
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-41943039, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039): +1G
Created a new partition 1 of type 'Linux' and of size 1 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): w
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 0x893c36f9.
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-4194303, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-4194303, default 4194303): +1G
Created a new partition 1 of type 'Linux' and of size 1 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): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
After the partition created now I am check the disk
root@linuxhelp:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 3.7G 0 part /swap
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 976M 0 part /boot
└─sda6 8:6 0 15.3G 0 part /
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 1G 0 part
sdc 8:32 0 20G 0 disk
└─sdc1 8:33 0 1G 0 part
sdd 8:48 0 2G 0 disk
└─sdd1 8:49 0 1G 0 part
sde 8:64 0 2G 0 disk
sr0 11:0 1 1.9G 0 rom
Now Create RAID 5 by executing the following command
root@linuxhelp:~# mdadm -C /dev/md0 -l 5 -n 3 /dev/sdb1 /dev/sdc1 /dev/sdd1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
After the RAID Is created then I am format the RAID file system using below command
root@linuxhelp:~# mkfs.ext4 /dev/md0
mke2fs 1.45.5 (07-Jan-2020)
Creating filesystem with 523264 4k blocks and 130816 inodes
Filesystem UUID: a932d24a-b6f0-43aa-8742-92146cf99e4b
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
Now I view the details of RAID file
root@linuxhelp:~# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Wed Jan 20 14:12:23 2021
Raid Level : raid5
Array Size : 2093056 (2044.00 MiB 2143.29 MB)
Used Dev Size : 1046528 (1022.00 MiB 1071.64 MB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Wed Jan 20 14:13:05 2021
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Name : linuxhelp:0 (local to host linuxhelp)
UUID : 01efc0c7:2c10bf97:ba096e3f:40d25615
Events : 18
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
3 8 49 2 active sync /dev/sdd1
Now I am going to create a directory for mount the RAID 5
root@linuxhelp:~# mkdir /data
Now I am mount RAID 5 into the directory
root@linuxhelp:~# mount /dev/md0 /data/
Now list the disk of the RAID is mounted or not
root@linuxhelp:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 391M 1.6M 390M 1% /run
/dev/sda6 16G 6.8G 7.5G 48% /
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
/dev/sda1 3.7G 15M 3.4G 1% /swap
/dev/sda5 945M 108M 773M 13% /boot
tmpfs 391M 16K 391M 1% /run/user/1000
/dev/md0 2.0G 6.0M 1.9G 1% /data
Now I am get into the newly created directory
root@linuxhelp:~# cd /data/
Inside the directory I will create some files on it
root@linuxhelp:/data# touch linuxhelp.txt
Now I am going to edit the text file by using vim command
root@linuxhelp:/data# vim linuxhelp.txt
Welcome to LinuxHelp
Now I am list the directory
root@linuxhelp:/data# ls -la
total 28
drwxr-xr-x 3 root root 4096 Jan 20 14:18 .
drwxr-xr-x 25 root root 4096 Jan 20 14:14 ..
-rw-r--r-- 1 root root 21 Jan 20 14:18 linuxhelp.txt
drwx------ 2 root root 16384 Jan 20 14:13 lost+found
Now I am going to test RAID 5 for that first I am fail the one partition from the RAID
root@linuxhelp:/data# mdadm /dev/md0 -f /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md0
Now I will view the RAID details if the partition is failed or not
root@linuxhelp:/data# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Wed Jan 20 14:12:23 2021
Raid Level : raid5
Array Size : 2093056 (2044.00 MiB 2143.29 MB)
Used Dev Size : 1046528 (1022.00 MiB 1071.64 MB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Wed Jan 20 14:21:03 2021
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 1
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Name : linuxhelp:0 (local to host linuxhelp)
UUID : 01efc0c7:2c10bf97:ba096e3f:40d25615
Events : 20
Number Major Minor RaidDevice State
- 0 0 0 removed
1 8 33 1 active sync /dev/sdc1
3 8 49 2 active sync /dev/sdd1
0 8 17 - faulty /dev/sdb1
After that I will check the directory if the data are corrupted or not
root@linuxhelp:/data# ls -la
total 28
drwxr-xr-x 3 root root 4096 Jan 20 14:18 .
drwxr-xr-x 25 root root 4096 Jan 20 14:14 ..
-rw-r--r-- 1 root root 21 Jan 20 14:18 linuxhelp.txt
drwx------ 2 root root 16384 Jan 20 14:13 lost+found
Now I will remove the failed drive from the RAID
root@linuxhelp:/data# mdadm /dev/md0 -r /dev/sdb1
mdadm: hot removed /dev/sdb1 from /dev/md0
Now I am create SDE partition and add the partition to the RAID
root@linuxhelp:/data# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 3.7G 0 part /swap
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 976M 0 part /boot
└─sda6 8:6 0 15.3G 0 part /
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 1G 0 part
sdc 8:32 0 20G 0 disk
└─sdc1 8:33 0 1G 0 part
└─md0 9:0 0 2G 0 raid5 /data
sdd 8:48 0 2G 0 disk
└─sdd1 8:49 0 1G 0 part
└─md0 9:0 0 2G 0 raid5 /data
sde 8:64 0 2G 0 disk
sr0 11:0 1 1.9G 0 rom
root@linuxhelp:/data# 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 0x5a68dcc7.
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-4194303, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-4194303, default 4194303): +1G
Created a new partition 1 of type 'Linux' and of size 1 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): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
List the disk by executing the following command
root@linuxhelp:/data# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 3.7G 0 part /swap
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 976M 0 part /boot
└─sda6 8:6 0 15.3G 0 part /
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 1G 0 part
sdc 8:32 0 20G 0 disk
└─sdc1 8:33 0 1G 0 part
└─md0 9:0 0 2G 0 raid5 /data
sdd 8:48 0 2G 0 disk
└─sdd1 8:49 0 1G 0 part
└─md0 9:0 0 2G 0 raid5 /data
sde 8:64 0 2G 0 disk
└─sde1 8:65 0 1G 0 part
sr0 11:0 1 1.9G 0 rom
Now format the sde1 drive to ext4 file system by using the following command
root@linuxhelp:/data# mkfs.ext4 /dev/sde1
mke2fs 1.45.5 (07-Jan-2020)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: a25bc884-ccef-47e6-8056-a2cafde432a4
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
After the format is completed then I am add the sde1 drive to the RAID
root@linuxhelp:/data# mdadm /dev/md0 --add /dev/sde1
mdadm: added /dev/sde1
Now I am list the RAID for if the sde1 is added or not
root@linuxhelp:/data# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Wed Jan 20 14:12:23 2021
Raid Level : raid5
Array Size : 2093056 (2044.00 MiB 2143.29 MB)
Used Dev Size : 1046528 (1022.00 MiB 1071.64 MB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Wed Jan 20 14:28:43 2021
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Name : linuxhelp:0 (local to host linuxhelp)
UUID : 01efc0c7:2c10bf97:ba096e3f:40d25615
Events : 40
Number Major Minor RaidDevice State
4 8 65 0 active sync /dev/sde1
1 8 33 1 active sync /dev/sdc1
3 8 49 2 active sync /dev/sdd1
Finally list the directory if the files are stored are not
root@linuxhelp:/data# ls -la
total 28
drwxr-xr-x 3 root root 4096 Jan 20 14:18 .
drwxr-xr-x 25 root root 4096 Jan 20 14:14 ..
-rw-r--r-- 1 root root 21 Jan 20 14:18 linuxhelp.txt
drwx------ 2 root root 16384 Jan 20 14:13 lost+found
With this method, the Configuration and Test RAID 5 on Linux Mint 20 comes to an end.