Raid 10 configuration in linux

raid 10 in linux

Raid 10(1+0) is combination of raid 1 and raid 0 . Raid 1 provides safety and raid 0 provides speed. Raid system  starts from back means at top it will be raid 0 then raid 1 . So first is raid 0 and its best known for data stripping . Let data be 1, 2, 3, 4, 5 and 6 .

You can see in diagram how it spreads data to both partitions .Then comes Raid 1 which is best known for data mirroring .So even one hard disk crash , raid 10 can take data from remaining harddisk .

  • Create four partitions and of same size
  • Command n ( to create partitions )
  • Command t   (to change partition type )
  • Command w  ( to save partition )
[root@localhost ~]# fdisk /dev/sda
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (57368-65399, default 57368):
Using default value 57368
Last cylinder or +size or +sizeM or +sizeK (57368-65399, default 65399): +1000M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (57491-65399, default 57491):
Using default value 57491
Last cylinder or +size or +sizeM or +sizeK (57491-65399, default 65399): +1000M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (57614-65399, default 57614):
Using default value 57614
Last cylinder or +size or +sizeM or +sizeK (57614-65399, default 65399): +1000M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (57737-65399, default 57737):
Using default value 57737
Last cylinder or +size or +sizeM or +sizeK (57737-65399, default 65399): +1000M
Command (m for help): t
Partition number (1-8): 8
Hex code (type L to list codes): fd
Changed system type of partition 8 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-8): 7
Hex code (type L to list codes): fd
Changed system type of partition 7 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-8): 6
Hex code (type L to list codes): fd
Changed system type of partition 6 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-8): 5
Hex code (type L to list codes): fd
Changed system type of partition 5 to fd (Linux raid autodetect)

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
  • Run partprobe command to save all changes ( mandatory)
[root@localhost ~]# partprobe /dev/sda
  • Command  fdisk -l  , to check partition in your system and its type
[root@localhost ~]# fdisk -l
Disk /dev/sda: 537.9 GB, 537932857344 bytes
255 heads, 63 sectors/track, 65399 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       50993   409601241   83  Linux
/dev/sda2           50994       57367    51199155   82  Linux swap / Solaris
/dev/sda4           57368       65399    64517040    5  Extended
/dev/sda5           57368       57490      987966   fd  Linux raid autodetect
/dev/sda6           57491       57613      987966   fd  Linux raid autodetect
/dev/sda7           57614       57736      987966   fd  Linux raid autodetect
/dev/sda8           57737       57859      987966   fd  Linux raid autodetect
  • Now use sda5 and sda6 to make raid .
  • After mdadm –create  give raid name like /dev/md8 or md2 , md0 , any .
  • –level=1 means we want this Raid to be raid 1
  • Then connect sda5 and sda6
root@localhost ~]# mdadm --create /dev/md5 --level=1 --raid-devices=2 /dev/sda5 /dev/sda6
mdadm: /dev/sda5 appears to be part of a raid array:
    level=raid6 devices=4 ctime=Thu Jan 19 21:57:53 2017
mdadm: /dev/sda6 appears to be part of a raid array:
    level=raid6 devices=4 ctime=Thu Jan 19 21:57:53 2017
Continue creating array? yes
mdadm: array /dev/md5 started
  • Now create /dev/md6 including sda7 and sda8.
  • –level will be 1.
[root@localhost ~]# mdadm --create /dev/md6 --level=1 --raid-devices=2 /dev/sda7 /dev/sda8
mdadm: /dev/sda7 appears to be part of a raid array:
    level=raid6 devices=4 ctime=Thu Jan 19 21:57:53 2017
mdadm: /dev/sda8 appears to be part of a raid array:
    level=raid6 devices=4 ctime=Thu Jan 19 21:57:53 2017
Continue creating array? yes
mdadm: array /dev/md6 started.
  • Now make /dev/md0 over these two Raid ( /dev/md5 and /dev/md6)
  • –level will be 0 ( raid0)
[root@localhost ~]# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/md5 /dev/md6
mdadm: array /dev/md0 started.
  • To check run cat  /proc/mdstat command .
  • md6 is active on sda8 and sda7
  • md5 is active on sda6 and sda5
  • and md0 is active on md6 and md5
[root@localhost ~]# cat /proc/mdstat
Personalities : [raid1] [raid0]
md6 : active raid1 sda8[1] sda7[0]
      987840 blocks [2/2] [UU]
md5 : active raid1 sda6[1] sda5[0]
      987840 blocks [2/2] [UU]
md0 : active raid0 md6[1] md5[0]
  • Now format /dev/md0
[root@localhost ~]# mkfs.ext3 /dev/md0
  • Create one folder where you want to mount this Raid 10
  • To mount type   =   mount   raidname    folder where you want to mount
  • 3usageeks is a folder .
  • To check type df  -h command
[root@localhost ~]# mount /dev/md0 3usageeks
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             379G  7.7G  352G   3% /
tmpfs                 947M     0  947M   0% /dev/shm
/dev/md0              1.9G   35M  1.8G   2% /root/3usageeks
  • But that was temporary mounting , means it will be lost when system reboots .
  • For permanent mounting go to path   /etc/fstab
[root@localhost ~]# vim /etc/fstab
  • And make entry as shown below .
  • First what you want to mount
  • Second where you want to mount
  • Third file type
  • Rest will be same
/dev/md0                /root/3usageeks         ext3    defaults         0 0

Press ESC and type :wq ( to save and quit)

~
~
~
:wq

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s