Linux software raid operation guide

  
                

Raid is divided into software Raid and hardware Raid. Because the hardware Raid is expensive, some people choose to use the software Raid. Raid is easy to use and low cost. The following small series will introduce you how to operate the software Raid.

First, what is Raid

Raid was originally called Redundant Arrays of Inexpensive Disks, which is now called Redundent Array of Independent Disks. This is a storage module that uses a mechanism to combine multiple hard drives with fault tolerance. It can be simply understood that this is a combination of several small hard drives into a large hard drive with fault tolerance. Raid is usually divided into several levels. For example, Raid0, Raid1, Raid4, Raid5, Raid6, Raid10, and Raid01 are common. The level of Raid is not a level in the usual sense. This level represents a combination of disks with different internal storage structure patterns. Raid is often used in projects where data storage is at risk and data reading and writing capabilities are high.

Raid is divided into hardware Raid and software Raid. The two Raid structures are the same, and the implementation mechanism is similar. The difference is that the hardware Raid has a separate chip responsible for processing data, powerful, and outstanding performance; while the software Raid can only read and write data by CPU, so the performance is weak, can be used for emergency processing. In other cases, I don't agree with the software Raid.

Second, the operation of software Raid in Linux

In Linux, the mdadm tool is usually used to perform soft Raid operation on the disk partition. mdadm generally calls the md module of the system. When md is used as a soft raid, any block device can be made into a raid, such as a system partition. It is not recommended to use two partitions on the same hard disk when doing raid0 to the system disk. Because raid0 itself is for data dispersion, but this situation still stores the data on a hard disk, so this situation does not make any sense. Here, for the experimental reasons, the operation is performed on the virtual machine, so this factor is not considered for the Raid0 operation.

mdadm is a patterning tool with the following modes

-A: assembly mode

-C: creation mode

-F: monitoring mode

-C: Common parameters for creating mode:

-n #: Number of devices used to create RAID devices

-x #: Number of hot spare disks < Br>

-l Level: Custom raid level, raid0, 0 can be written

-a yes: Automatically create device files for the created raid device;

-c Chunk_Size: Specifies the block size, the default is 512, the unit is KB

mdadm other unique parameters:

-f: the simulated device is damaged

-r: analog pullout Bad Disk

-a: Plug the new device into

-S: Stop the RAID, this operation needs to uninstall the device

-D(--detail): Display Array details

Next, let's create a new 12G Raid0

1. First use the system fdisk tool to partition the hard disk, and divide the two disks into 6G format for Linux raid autodetect.

Here are two of my disks /dev /sdb1 and /dev /sdb2

2, and the use of kpart partx command to refresh the system partition table records

kpartx -af /dev/sdb

partx -a /dev/sdb

Then use the cat command to view the partition table records. When your new partition appears in the list, you can Create a raid

cat /proc/partitions

3. Create a Raid0 using the command mdadm -C

mdadm -C /dev/md0 -a yes -l 0 -n 2 /dev/sdb{1,2}

-C /dev/md0 The device name is /dev/md0

-a yes The problem is automatically answered as yes

-l 0 Level is raid0

-n 2 Number of devices is 2

/dev/sdb{1,2} Devices are /dev/sdb1 and /dev/sdb2

Sometimes the partition is occupied, but it can still be created successfully. You can view the raid without interruption during the operation
Previous12Next page Total 2 pages

Copyright © Windows knowledge All Rights Reserved