How to Configure and Test RAID 0 on Linux Mint 20

To Configure and Test RAID 0 on Linux Mint 20

Introduction:

Redundant Array of Independent Disks (RAID) is a data storage virtualization technology that connects multiple physical disk drive components into a single logical unit for the purposes of data redundancy, performance improvement. The concept of RAID 0 is the data that is split and stores in the drives. If the data from one drive is corrupted then the entire data will be lost. This tutorial will cover configure and test RAID 0 on Linux Mint 20.

Installation Procedure:

First check the version of the Linux mint 20.

root@LinuxHelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Linuxmint
Description:	Linux Mint 20
Release:	20
Codename:	ulyana

Now list the disk by executing 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 
sr0     11:0    1  1.9G  0 rom  /media/user/Linux Mint 20 Cinnamon 64-bit

Now create a partitions by using the 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 0xc74df8b6.
Press n to create partition
Command (m for help): n
Enter the partition type
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): 
Enter the partition size
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.
Enter t to change the type of partiton
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'.
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.

Now follow the steps to create the another partition

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 0x328e0fde.
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.

Create RAID by using the following command

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

Now format the raid in ext4 format by executing the 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: 9e759bbe-e7c7-497e-8432-e31da81a6632
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 list the raid details by enter the command

root@linuxhelp:~# mdadm --detail /dev/md0 
/dev/md0:
           Version : 1.2
     Creation Time : Tue Jan 19 15:49:23 2021
        Raid Level : raid0
        Array Size : 2093056 (2044.00 MiB 2143.29 MB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent
       Update Time : Tue Jan 19 15:49:23 2021
             State : clean 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0
            Layout : -unknown-
        Chunk Size : 512K
Consistency Policy : none
              Name : linuxhelp:0  (local to host linuxhelp)
              UUID : 13958fbe:5f733618:4e8fc7e7:88dcbd00
            Events : 0
    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       8       33        1      active sync   /dev/sdc1

Now create the directory for mount the raid to the drive

root@linuxhelp:~# mkdir raid

Now mount the raid to the directory

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

Edit the fstab file for permanent mounting for that I am copying from the mtab

root@linuxhelp:~# cat /etc/mtab 
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
.
.
.
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=400220k,mode=700,uid=1000,gid=1000 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0
/dev/sr0 /media/user/Linux\040Mint\04020\040Cinnamon\04064-bit iso9660 ro,nosuid,nodev,relatime,nojoliet,check=s,map=n,blocksize=2048,uid=1000,gid=1000,dmode=500,fmode=400 0 0
/dev/md0 /root/raid ext4 rw,relatime,stripe=256 0 0
root@linuxhelp:~# vim /etc/fstab 

Add the line for permanent mounting

/dev/md0 /root/raid ext4 rw,relatime,stripe=256 0 0

Now list the drive by executing the following command

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/sda5       945M  108M  773M  13% /boot
/dev/sda1       3.7G   15M  3.4G   1% /swap
tmpfs           391M   16K  391M   1% /run/user/1000
/dev/sr0        1.9G  1.9G     0 100% /media/user/Linux Mint 20 Cinnamon 64-bit
/dev/md0        2.0G  6.0M  1.9G   1% /root/raid

Now I am enter into the raid directory and add some files on the directory

root@linuxhelp:~# cd raid/
root@linuxhelp:~/raid# touch a b c
root@linuxhelp:~/raid# mkdir aa bb cc
root@linuxhelp:~/raid# ls -la
total 36
drwxr-xr-x 6 root root  4096 Jan 19 15:53 .
drwx------ 5 root root  4096 Jan 19 15:51 ..
-rw-r--r-- 1 root root     0 Jan 19 15:53 a
drwxr-xr-x 2 root root  4096 Jan 19 15:53 aa
-rw-r--r-- 1 root root     0 Jan 19 15:53 b
drwxr-xr-x 2 root root  4096 Jan 19 15:53 bb
-rw-r--r-- 1 root root     0 Jan 19 15:53 c
drwxr-xr-x 2 root root  4096 Jan 19 15:53 cc
drwx------ 2 root root 16384 Jan 19 15:49 lost+found

Unmount the directory and test the RAID 0.

root@linuxhelp:~# umount raid/

Now I am fail the sdb1 partition

root@linuxhelp:~# mdadm /dev/md0 -f /dev/sdb1 
mdadm: set device faulty failed for /dev/sdb1:  Device or resource busy

Now command the mounting from the fstab file by executing the following command

root@linuxhelp:~# vim /etc/fstab 

Restart my distro by executing the following command

root@linuxhelp:~# init 6

After the system is restarted then I am enter into the raid directory and list the directory all the datas from the raid is corrupted

root@linuxhelp:~# cd raid/
root@linuxhelp:~/raid# ls -la
total 8
drwxr-xr-x 2 root root 4096 Jan 19 15:50 .
drwxr------ 5 root root 4096 Jan 19 15:54 . .

With this method, to configure and test RAID 0 on Linux Mint 20 is comes to an end.

FAQ
Q
What is meant by the term "disk striping"?
A
Within a disk striping (RAID 0) volume, the information will be written evenly, or "striped", over at least 2 (if not more) disk drives.
Q
How many drives are needed for a RAID 0 volume?
A
To establish a RAID 0 volume, a minimum of at least 2 hard disk drives are required. Unlike RAID 1, the number of drives used in the array can be an odd or even number.
Q
What are the benefits of using drives set up as a RAID 0?
A
A RAID 0 (disk striping) set will use the maximum amount of available storage capacity of each drive in the array, and allows for faster access and retrieval of data.
Q
What is RAID 0?
A
RAID 0 (also known as a stripe set or striped volume) splits ("stripes") data evenly across two or more disks, without parity information, redundancy, or fault tolerance.
Once the stripe size is defined during the creation of a RAID 0 array, it needs to be maintained at all times.
Q
What is a RAID?
A
RAID ("Redundant Array of Inexpensive Disks" or "Redundant Array of Independent Disks") 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,
for more information refer to this link: https://en.wikipedia.org/wiki/RAID