From: http://hi.baidu.com/xms_hero/blog/item/62fd0354dc2c01143b293525.html
Linux softraid Management
The tool software includes mdadm and raidtools, which are software packages with the same functions. mdadm is powerful and new.
Raidtools is an old software package with limited functions, but is the default raid package of RedHat as3.
Manage Linux raid.
1. Prepare partitions and use fdisk to plan partitions of the same size (not on a hard disk. This is meaningless and can only be used for testing). Theoretically
The partition size can be different. However, the partition size must be the same. The partition type is not required.
2. Create raid, use command
Mdadm-CV/dev/md0-L1-N2-C64/dev/sda2/dev/sdb2
After the command is executed, you can use CAT/proc/mdstat to view the raid creation status.
3. View array information
Mdadm-D/dev/md0
CAT/proc/mdstat
4. Adjust the raid synchronization speed by using the following files:
/Proc/sys/dev/raid/speed_limit_max
/Proc/sys/dev/raid/speed_limit_min
5. After the raid is created, it can be used normally without synchronization. For example, you can create a file system mkfs. ext3/dev/md0,
However, it is recommended that you do not restart or stop raid. After the raid is started next time, the system will re-sync the raid. If the raid is large, it will be a waste of time.
6. Simulate hard disk failure.
Mdadm/dev/md0-F/dev/sdb2
You can simulate a/dev/hdc2 hard disk failure. You can run the command to view the raid response.
Remove faulty disk from Array
Mdadm/dev/md0-r/dev/sdb2
7. Add a new disk to replace the faulty disk.
The size of the new partition must be greater than or equal to the size of the original raid partition.
Mdadm/dev/md0-A/dev/sdc2
After the raid is added, it is automatically synchronized.
8. modify the configuration file/etc/mdadm. conf
Device/dev/sda2/dev/sdb2
Array/dev/md0 level = raid1 num-devices = 2 UUID = 24d599bd: ac87524e: 087a4740: ff3837bc
The array can be listed in the mdadm-d-s column.
9. modify the configuration file/etc/raidtab,/etc/fstab.
Modify these two configuration files to automatically start the RAID system after the system is started.
Raiddev/dev/md0
Raid-Level 1
Persistent-superblock 1
NR-raid-Disks 2
NR-Spare-Disks 0
Chunk-size 64
Device/dev/hda1
Raid-disk 0
Device/dev/hdb1
Raid-Disk 1
The persistent-superblock must be 1, because all RAID files created by mdadm have superblocks.
The chunk-size must be the same as the number following-C when mdadm is used to create a raid. The raid-disk number must be the same as the number following mdadm.
The order of devices written in is the same.
Modify the Mount entry of/etc/fstab to/dev/md0. Do not use the volume label.
10. restart the system and test whether Linux raid can be started properly.
Note: If three sda2/sdb2 sdc2 partitions of the same size exist at the same time, if you create sda2 and sdb2 as raid1 at first, if you want to change sda2 and sdc2 to take effect after the restart, perform the following operations:
1) mdadm/dev/md0-F/dev/sdb2-r/dev/sdb2-A/dev/sdc2
2) mdadm -- zero-superblock/dev/sdb2 (Important: The purpose is to clear the MD superblock content on the partition. The method for viewing the MD superblock information of the partition is mdadm-E/dev/sdb2)
3) adjust/etc/mdadm. conf