WHAT’S Raid10 IN LINUX AND HOW TO CONFIGURE

RAID stands for redundant array of independent disks.How the data is distributed between these drives depends on the RAID level used.RAID 10 has the benefits of RAID 0 speed and RAID 1 safety .excellent choice for both performance and redundancy. Minimum disk required is four .

raid 10

HOW IT WORKS :

As shown in diagram, Raid10 requires 4 harddisk and of same size . Let the data be 123456 and i’ll explain you how it distributes data .First comes Raid 0 (requires 2 disk)  which is made on  /dev/md1 and /dev/md2 (raid1) . Raid0 is known for stripping of data , so its saving half part of data in /dev/md1 and half part in /dev/md2 . That’s why /dev/md0 (raid0) size is 2000MB . Then comes raid 1 (mirroring of data ) , which saves data equally on both harddisk . So data the is still safe if there is  loss of any drive (one in each group)  . Raid 10 is better than raid 01 .

HOW TO CONFIGURE RAID10 IN LINUX

  • Check how many partition you have in your system by fdisk -l command .
[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
  • Create four partition of equal size .
  • command n (for creating partition )
  • command p ( to print)
[root@localhost ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 65399.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

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): p
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   83  Linux
/dev/sda6           57491       57613      987966   83  Linux
/dev/sda7           57614       57736      987966   83  Linux
/dev/sda8           57737       57859      987966   83  Linux

creating partition in linux

  • We also need to change partition type to Raid .
  • command t (for changing partition type )
  • CODE –  fd  ( Linux RAID)
  • command w ( to save )
Command (m for help): t
Partition number (1-8): 8
Hex code (type L to list codes): l
 0  Empty           1e  Hidden W95 FAT1 80  Old Minix       bf  Solaris
 1  FAT12           24  NEC DOS         81  Minix / old Lin c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          82  Linux swap / So c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  83  Linux           c6  DRDOS/sec (FAT-
 4  FAT16 fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
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.

changing partition type in linux

  • After creating partition and changing its type dont forget to run partprobe command
[root@localhost ~]# partprobe /dev/sda
  • Run fdisk -l command to check
[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 we will create Raid 1 including sda5 and sda6  as shown in above diagram
  • after mdadm –create give raid name like i’m giving /dev/md1
  • –level=1  means we want /dev/md1 to be raid 1
  • then give raid partition you want to include .
  • It might ask you ” continue creating array?” Type yes and hit Enter .
[root@localhost ~]# mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sda5 /dev/sda6
mdadm: /dev/sda5 appears to contain an ext2fs file system
    size=1975616K  mtime=Fri Jan 13 03:17:40 2017
mdadm: /dev/sda5 appears to be part of a raid array:
    level=raid0 devices=2 ctime=Fri Jan 13 03:14:33 2017
mdadm: /dev/sda6 appears to be part of a raid array:
    level=raid0 devices=2 ctime=Fri Jan 13 03:14:33 2017
Continue creating array? yes
mdadm: array /dev/md1 started.

create raid in linux

  • Now  /dev/md2 which includes sda7 and sda8
  • level should 1 because it’s also raid 1 .
[root@localhost ~]# mdadm --create /dev/md2 --level=1 --raid-devices=2 /dev/sda7 /dev/sda8
mdadm: /dev/sda7 appears to contain an ext2fs file system
    size=1975616K  mtime=Fri Jan 13 03:17:40 2017
mdadm: /dev/sda7 appears to be part of a raid array:
    level=raid0 devices=2 ctime=Fri Jan 13 03:15:14 2017
mdadm: /dev/sda8 appears to be part of a raid array:
    level=raid0 devices=2 ctime=Fri Jan 13 03:15:14 2017
Continue creating array? yes
mdadm: array /dev/md2 started.

creating raid in linux

  • Now /dev/md0 will include both raid device /dev/md1 and /dev/md2
  • Its level will be 0  ( raid 0)
[root@localhost ~]# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/md1 /dev/md2
mdadm: /dev/md1 appears to contain an ext2fs file system
    size=1975616K  mtime=Fri Jan 13 03:17:40 2017
mdadm: /dev/md2 appears to contain an ext2fs file system
    size=1975616K  mtime=Fri Jan 13 03:17:40 2017
Continue creating array? yes
mdadm: array /dev/md0 started.

create raid in linux

  • Check by cat  /proc/mdsta command whether your raid10 is been created or not .
  • As you can see md2(raid1) is active including sda8 and sda7
  • md1 (raid1) is active on sda6 and sda5
  • And md0(raid0) is active on md2 and md1
[root@localhost ~]# cat /proc/mdstat
Personalities : [raid1] [raid0]
md2 : active raid1 sda8[1] sda7[0]
      987840 blocks [2/2] [UU]
md1 : active raid1 sda6[1] sda5[0]
      987840 blocks [2/2] [UU]
md0 : active raid0 md2[1] md1[0]
      1975552 blocks 64k chunks
unused devices:

raid in linux

  • To use raid 10 we have to mount it for saving data but before mounting we have to format it . Type mkfs.ext3  /dev/md0   ( it defines /dev/md0 is ext3 type )
[root@localhost ~]# mkfs.ext3 /dev/md0
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
247296 inodes, 493888 blocks
24694 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=507510784
16 block groups
32768 blocks per group, 32768 fragments per group
15456 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override

format raid in linux

  • Now mount it to any  Folder . My folder name is Deepit .
  • And check by df -h command .
[root@localhost ~]# mount /dev/md0 Deepit
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             379G  4.8G  355G   2% /
tmpfs                 947M     0  947M   0% /dev/shm
/dev/md0              1.9G   35M  1.8G   2% /root/Deepit

mounting in linux

  • For permanant mounting open /etc/fstab file
[root@localhost ~]# vim /etc/fstab
  • And make entry as shown below .
  • First what you want to mount (/dev/md0)
  • Second path where you want to mount . (/root/Deepit)
  • Third is file type . Its ext3
  • Rest will be same .
LABEL=/                 /                       ext3    defaults        1 1
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda2         swap                    swap    defaults        0 0
/dev/md0                /root/Deepit            ext3    defaults        0 0
~
~
~
~
~
~
~

permanent mount in linux

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

NOW HOW TO DELETE RAID10 FROM YOUR SYSTEM

  •  Go to fstab file .
[root@localhost ~]# vim /etc/fstab
  • An d add # in front of that entry it will comment out that line .
  • Press Esc and type :wq(to save and quit)
#/dev/md0                /root/Deepit            ext3    defaults        0 0

removing permanent raid in linux

  • Check by df -h command .
  • And type umount folder name ( to unmout that folder)
  • Again run df -h command to check whether its been removed or not .
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             379G  4.8G  355G   2% /
tmpfs                 947M     0  947M   0% /dev/shm
/dev/md0              1.9G   35M  1.8G   2% /root/Deepit
[root@localhost ~]# umount Deepit
  • Check by cat  /proc/mdstat command which raid is active .
[root@localhost ~]# cat /proc/mdstat
Personalities : [raid1] [raid0]
md2 : active raid1 sda8[1] sda7[0]
      987840 blocks [2/2] [UU]
md1 : active raid1 sda6[1] sda5[0]
      987840 blocks [2/2] [UU]
md0 : active raid0 md2[1] md1[0]
      1975552 blocks 64k chunks
unused devices:
  • First stop that raid .
  • Then remove it  Start from above (/dev/md0)
[root@localhost ~]# mdadm --stop /dev/md0
mdadm: stopped /dev/md0
[root@localhost ~]# mdadm --remove /dev/md0
[root@localhost ~]# mdadm --stop /dev/md1
mdadm: stopped /dev/md1
[root@localhost ~]# mdadm --remove /dev/md1
[root@localhost ~]# mdadm --stop /dev/md2
mdadm: stopped /dev/md2
[root@localhost ~]# mdadm --remove /dev/md2
  • Now we will remove that partition .
  • Command d( to delete partition )
  • Run partprobe command after deleteing prtition .
[root@localhost ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 65399.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): d
Partition number (1-8): 8
Command (m for help): d
Partition number (1-7): 7
Command (m for help): d
Partition number (1-6): 6
Command (m for help): d
Partition number (1-5): 5
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.
[root@localhost ~]# partprobe /dev/sda
  • Check by fdisk -l command
[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

Don’t hesitate to comment if you got any problem .

RAID01 . HOW TO CONFIGURE RAID 01 IN LINUX.

WHAT IS VNC SERVER . HOW TO CONFIGURE VNC SERVER IN LINUX AS SERVER AND WINDOWS, ANDROID , IPHONE OR IPAD AS CLIENT.

KDE – HOW TO INSTALL KDE DESKTOP IN LINUX & GET START BUTTON (WINDOWS ) IN LINUX .

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