Create a RAID0 with a size of 10 GB
1. Create two shards for RAID 0
Use/dev/sde1/and dev/sdf1 to create a partition. The partition capacity is 5 GB, And the partition is converted to fd.
123 # fdisk/dev/sde # fdisk/dev/sdf # fdisk-l/dev/sd {e, f}
Figure 1 and 2
Note: Do not format it after saving and exiting, because we cannot format a block device at the bottom of software raid, but format the software raid itself.
2. Let the kernel re-read the Partition Table
123 # partx-a/dev/sde1/dev/sde # partx-a/dev/sdf1/dev/sdf # cat/proc/partitions
Figure 3
3. Create the/dev/sde1 and/dev/sdf1 partitions as RAID 0.
Check whether there are related files under/proc/mdstat before creation.
1 # cat/proc/mdstat
Figure 4
1 # ls-l/dev/md *
Figure 5
Since md0 has not been used, let's start from 0!
1 # mdadm-C-a yes-n 2-l 0/dev/sd {e, f} 1
4. Create an md Device
1 # mdadm-C/dev/md00-a yes-l 0-n 2/dev/sd {e, f} 1
Figure 6
Description of md-related files ------> version number, device file, ID number -----------> ASCII code file, saving the ing relationship between all md devices on the current host, which disk partitions are used as md devices?
1 # ls-l/dev/md *
Figure 7
12 # cd/dev/md # file md-device-map
1 # cat md-device-ma
Figure 8
5. format the md Device
Note: After the md device is created, You Can format the md device. The md device is an independent device.
# Mke2fs-t ext4/dev/md0
1 # mke2fs-t ext4/dev/md0
Figure 9
Vi. Mounting
12345 # mkdir/raid0 # mount/dev/md0/raid0 # cd/raid0/# ls # mount
7. Monitor md0 devices and learn about md
1 # mdadm-D/dev/md0 ------ "displays details of md0
Figure 11
Create a RAID1 with a size of 20 GB
1. Create two 20 partitions respectively in the system
Figure 1
II,
1/# fdisk-l/dev/sd {B, c} ask the kernel to re-read and identify the partition/
Figure 2
3. Create an md Device
1 # mdadm-C/dev/md1-a yes-l 1-n 2/dev/sd {B, c} 1
Figure 3
Check whether the creation is successful
1 # cat/proc/mdstat
Figure 4
4. format the md Device
1 # mke2fs-t ext4/dev/md1-L RAID_1
Figure 5
VI,
Figure 6
Figure 7
Test the redundancy of RAID1.
1234 # cd/mnt # ls; pwd # cp/etc/issue./# mount
Figure 8
2. If a hard disk of RAID 1 breaks down, can the/mnt mount point be used?
For RAID1, if a hard disk is broken, does it really not affect data access?
Iii. Destruction
12 # mdadm/dev/md1-f/dev/sdb1 # mdadm-D/dev/md1
Figure 9
1 # cat issue
Figure 10
Copy the file and try to test the write operation.
Figure 11
Test read Operations
Figure 12
OK, no problem!
3. Remove a bad Disk
1 # mdadm/dev/md1-r/dev/sdb1
Figure 13
4. If the/dev/sd disk has been repaired, how can we add it to its RAID group?
12 # mdadm/dev/md1-a/dev/sdb1 # mdadm-D/dev/md1
Figure 14
1 # mdadm-D/dev/md1
Data Reconstruction successful
The second disk in Raid 1 is damaged.
I,
12 # mdadm/dev/md1-f/dev/sdc1 # mdadm-D/dev/md1
Figure 16
2. Read and Write the/mnt directory
1234 # ls/mnt/# cat/mnt/issue-n # echo "I love linux so much">/mnt/love.txt # cat/mnt/love.txt-n
Figure 17
Figure 18
Figure 19
Three disks in Raid 1 are used as backup disks.
1 # mdadm-C/dev/md2-a yes-l 1-n 2-x 1/dev/sd {B, c, d} 2
Figure 20
# Fdisk-l/dev/sd {B, c, d}
Figure 21
Format the md Device
1 # mke2fs-t ext4/dev/md2
Figure 22
1 mount # mount/dev/md2/mnt/12 # cp/etc/fstab/mnt/# cat/mnt/fstab
Figure 23
Simulate disk corruption
Figure 24
12 # mdadm/dev/md2-r/dev/sdb2 # mdadm-D/dev/md2
Figure 25
Check that the file is intact.
Figure 26
Create a RAID5 with a size of 10 GB
1 # ls/dev/md *
1 # mdadm-C/dev/md3-a yes-l5-n3/dev/sd {B, c, d} 3
Figure 27
Figure
28
1 # cat/proc/mdstat
Figure 29
Create an md Device
1 # mdadm-D/dev/md3
Figure 30
Format the md Device
1 # mke2fs-t ext4/dev/md3
Figure 31
123 # mount/dev/md3/mnt/# cp/etc/issue/mnt/issue # cat/mnt/issue
Figure 32
Damaged simulated/dev/sd Disk
12 # mdadm/dev/md3-f/dev/sdb3 # mdadm-D/dev/md3
Figure 33
Data can be accessed normally.
Figure 34
1 # mdadm-D/dev/md3
Figure 35
What will happen if one piece breaks down? You don't know how to try it !!!!
12 # mdadm/dev/md3-f/dev/sdc3 # cat-n/mnt/issue
Figure 36
Figure 37
1 # mdadm-D/dev/md3
At this point, the RAID-related practices have ended. This experiment is only for learning and communication purposes. Do not imitate it in the actual production environment!
All operations in this article are related to RAID and have nothing to do with me!