🌐 🇵🇱 Polski · 🇬🇧 EN
So far, we have covered basic partitions, SWAP partitions, logical volumes, and their configuration, modification, editing, and removal. Now it is time for the final partitioning task, namely - the RAID partition. A RAID partition enables advanced configurations that provide redundancy and improved performance. There are various types of RAID partitions:
- RAID 0 - Disks are grouped together to form one larger disk. This solution provides increased performance at the cost of availability. If one of the disks fails, the entire partition becomes unusable. This RAID type requires a minimum of 2 disks.
- RAID 1 - The contents of a disk are copied to another disk, enabling redundancy. If one of the disks fails, it can be repaired using the existing data copy on the second disk. For RAID 1, a minimum of 2 disks must be used.
- RAID 5 - The structure is similar to RAID 0, where disks are combined into a group to create one larger disk. The difference is that 25% of the disk space is used for parity, which allows data recovery if one of the disks fails. This partition type requires a minimum of 3 disks.
More details can be found via the links on Wikipedia.pl
RAID partitions can also be created at the hardware level. RedHat exams do not rely on hardware solutions but focus on software-based methods. For this solution, the MD driver will also be required.
To practice the following steps, you will need 3 disks in the system (hdb, hdc, hdd) to create the RAID partition.
Step 1 - Install the following package
# yum install -y mdadm
Step 2 - Verify the package installation
# rpm -qa | grep mdadm
mdadm-3.1.3-1.el6.x86_64
The above package should be installed with the system, but it is better to check and install it if necessary. To start, we will create 2 basic partitions, the same ones that were removed in the previous chapter... (practice makes perfect). We will begin by creating a RAID 5 partition, and for this purpose, we will use 3 different disks.
CREATING A RAID PARTITION
Creating basic partitions is no longer a problem, and assuming they have already been created, we will proceed to create the RAID partition. If 3 basic partitions (hdb, hdc, hdd) have not been created yet, you should do so now.
Step 1 - Check the output of the "fdisk -l" command
# fdisk -l
Disk /dev/hda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00021654
Device Boot Start End Blocks Id System
/dev/hda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/hda2 64 2611 20458496 8e Linux LVM
Disk /dev/hdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x8f3fa89a
Device Boot Start End Blocks Id System
/dev/hdb1 1 1044 8385898+ 83 Linux
Disk /dev/hdc: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6004464d
Device Boot Start End Blocks Id System
/dev/hdc1 1 1044 8385898+ 83 Linux
Disk /dev/hdd: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00079351
Device Boot Start End Blocks Id System
/dev/hdd1 1 1044 8385898+ 83 Linux
Now we can start creating a RAID 5 partition from the existing 3 logical disks. To create RAID partitions, we use the "mdadm" command.
mdadm command syntax: # mdadm [options]
mdadm command options:
- -a, xx - Add a disk to the current RAID table
- -C, -create - Create a new RAID partition
- -D, -detail - Display details about the RAID
- -G, -grow - Resize or reshape an active RAID partition
- -f, xx - Remove a disk from the RAID partition
- -l, -level - Specify the RAID partition level (type)
- -n, -raid-devices - Specify the number of devices in the RAID partition
- -q, -quiet - Operate in quiet mode
- -S, -stop - Stop the RAID
- -v, -verbose - Display information on output (verbose mode)
Step 2 - The above information should be sufficient to construct the command to create a RAID 5 partition containing 3 disks.
# mdadm -Cv /dev/md0 --level=5 -n3 /dev/hdb1 /dev/hdc1 /dev/hdd1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
Step 3 - Using the "mdadm" command, we will verify that the RAID partition was created correctly
# mdadm –D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Thu Jan 27 14:09:23 2011
Raid Level : raid5
Array Size : 16769024 (15.99 GiB 17.17 GB)
Used Dev Size : 8384512 (8.00 GiB 8.59 GB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Thu Jan 27 14:15:27 2011
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Name : RHEL-01:0 (local to host RHEL-01)
UUID : a02fb98a:63a7cbbf:762c7a7f:e681a8ee
Events : 18
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/hdb1
1 8 33 1 active sync /dev/hdc1
3 8 49 2 active sync /dev/hdd1
Step 4 - Check the status of the newly created RAID partition
# cat /proc/mdstat
Personalities : [raid0] [raid6] [raid5] [raid4]
md0 : active raid5 hdd1[3] hdc1[1] hdb1[0]
16769024 blocks super 1.2 level 5, 512k chunk, algorithm 2
[3/2] [UU_]
[===>.................] recovery = 17.8% (6148864/8384512)
finish=2.9min speed=22072K/sec
unused devices: <none>
As a result, we received information that RAID 5 is active, contains 3 disks, and is still in the process of being created.
Step 5 - Re-check the RAID status 2.9 minutes later
# cat /proc/mdstat
Personalities : [raid0] [raid6] [raid5] [raid4]
md0 : active raid5 hdd1[2] hdc1[1] hdb1[0]
8001280 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
unused devices: <none>
Now you can see that the RAID is fully created and ready for operation.
Comments