Create Software RAID 10 on CentOS

Source: Internet
Author: User

When I reinstalled an old server yesterday, I found that the Intel hardware RAID Controller has a problem and cannot identify all hard disks. However, during operating system installation, I can identify all hard disks. Another problem is that the operating system is properly installed, however, the system cannot be started after installation. For some reason, the BIOS cannot start the system from the hard disk. Therefore, we plan to install the operating system on a USB disk, start the system from the USB disk, and create Software RAID 10 for the above six hard disks and then mount them to the system for use.

Hard disks of the same manufacturer, model, and size are strongly recommended for Software RAID. Why RAID 10? What about RAID 0, RAID 1, and RAID 5? A: RAID0 is too dangerous. RAID1 has a slightly inferior performance. RAID5 has poor performance when it is frequently written. RAID10 seems to be the best choice for today's disk arrays, it is particularly suitable for the local storage system (if SAN and distributed storage are not considered) of KVM, Xen, and VMware virtual machine host ).

This server has 6 identical hard disks, which are divided into one partition. The partition format is Linux software raid:

# fdisk /dev/sdaWARNING: DOS-compatible mode is deprecated. It's strongly recommended to         switch off the mode (command 'c') and change display units to         sectors (command 'u').Command (m for help): nCommand action   e   extended   p   primary partition (1-4)pPartition number (1-4): 1First cylinder (1-91201, default 1):Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-91201, default 91201):Using default value 91201Command (m for help): pDisk /dev/sda: 750.2 GB, 750156374016 bytes255 heads, 63 sectors/track, 91201 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0005c259   Device Boot      Start         End      Blocks   Id  System/dev/sda1               1       91201   732572001   83  LinuxCommand (m for help): tSelected partition 1Hex code (type L to list codes): fdChanged system type of partition 1 to fd (Linux raid autodetect)Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.

Based on the above/dev/sda partition example, we will give the remaining five hard drive sdc, sdd, sde, sdf, sdg partitions, and change the partition format:

# fdisk /dev/sdc...# fdisk /dev/sdd...# fdisk /dev/sde...# fdisk /dev/sdf...# fdisk /dev/sdg...

After the partition is complete, you can create RAID. In the preceding six partitions of the same size, create RAID 10:

# mdadm --create /dev/md0 -v --raid-devices=6 --level=raid10 /dev/sda1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 /dev/sdg1mdadm: layout defaults to n2mdadm: layout defaults to n2mdadm: chunk size defaults to 512Kmdadm: size set to 732440576Kmdadm: Defaulting to version 1.2 metadatamdadm: array /dev/md0 started.

Check the disk array initialization process (build). The entire process takes about several hours based on the disk size and speed:

# watch cat /proc/mdstatEvery 2.0s: cat /proc/mdstat                                       Tue Feb 11 12:51:25 2014Personalities : [raid10]md0 : active raid10 sdg1[5] sdf1[4] sde1[3] sdd1[2] sdc1[1] sda1[0]      2197321728 blocks super 1.2 512K chunks 2 near-copies [6/6] [UUUUUU]      [>....................]  resync =  0.2% (5826816/2197321728) finish=278.9min speed=130948K/secunused devices: 

After the array is initialized, you can create a partition and file system for the md0 device. With the file system, you can mount it to the system:

# fdisk /dev/md0# mkfs.ext4 /dev/md0p1# mkdir /raid10# mount /dev/md0p1 /raid10

Modify the/etc/fstab file to enable automatic mounting upon each system startup:

# vi /etc/fstab.../dev/md0p1 /raid10 ext4 noatime,rw 0 0

In the above/etc/fstab file, using the/dev/md0p1 device name is not a good method. Because of udev, this device name often changes after the system is restarted, so it is best to use UUID, use the blkid command to find the UUID of the corresponding partition:

# blkid.../dev/md0p1: UUID="093e0605-1fa2-4279-99b2-746c70b78f1b" TYPE="ext4"

Then modify the corresponding fstab and mount it with UUID:

# vi /etc/fstab...#/dev/md0p1 /raid10 ext4 noatime,rw 0 0UUID=093e0605-1fa2-4279-99b2-746c70b78f1b /raid10 ext4 noatime,rw 0 0

View RAID information:

# mdadm --query --detail /dev/md0/dev/md0:        Version : 1.2  Creation Time : Tue Feb 11 12:50:38 2014     Raid Level : raid10     Array Size : 2197321728 (2095.53 GiB 2250.06 GB)  Used Dev Size : 732440576 (698.51 GiB 750.02 GB)   Raid Devices : 6  Total Devices : 6    Persistence : Superblock is persistent    Update Time : Tue Feb 11 18:48:10 2014          State : clean Active Devices : 6Working Devices : 6 Failed Devices : 0  Spare Devices : 0         Layout : near=2     Chunk Size : 512K           Name : local:0  (local to host local)           UUID : e3044b6c:5ab972ea:8e742b70:3f766a11         Events : 70    Number   Major   Minor   RaidDevice State       0       8        1        0      active sync   /dev/sda1       1       8       33        1      active sync   /dev/sdc1       2       8       49        2      active sync   /dev/sdd1       3       8       65        3      active sync   /dev/sde1       4       8       81        4      active sync   /dev/sdf1       5       8       97        5      active sync   /dev/sdg1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.