RAID01 CONFIGURATION IN LINUX

raid01 in linux

 

Raid 01(0+1) is a combination of raid 0 (speed ) and raid 1 (secure) . In raid 01 , first  raid 1 is configured . Let data be 1, 2, 3, and 4 . Raid 1 is best known for data mirroring  . It saves data equally to both partitions  . RAid 1 size is 2000MB because it can data from any  one partition . Raid 0 and Raid 1 requires minimum two Disks  . Then comes raid 0 , which spreads data to both harddisks . That’s why it’s size is 2000MB .

HOW TO CONFIGURE RAID01 in linux

  • Create four partitions and of same size .
[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
  • Also change partition type to raid
  • Command t  ( to change partition type )
  • CODE :  fd ( linux raid )
  • Make you run partprobe command after that ( mandatory )
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.
[root@localhost ~]# partprobe /dev/sda
  • Fdisk -l command to check partition size and its type
[root@localhost ~]# fdisk -l

   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 create raid 0 .
  • After mdadm –create type raid name .
  • –level=0 means We want this raid to be raid 0.
  • Then include sda5 & sda6 in /dev/md3  and sda7 & sda8 in /dev/md4
[root@localhost ~]# mdadm --create /dev/md3 --level=0 --raid-devices=2 /dev/sda5 /dev/sda6
mdadm: /dev/sda5 appears to be part of a raid array:
    level=raid6 devices=4 ctime=Wed Jan 25 08:07:54 2017
mdadm: /dev/sda6 appears to be part of a raid array:
    level=raid6 devices=4 ctime=Wed Jan 25 08:07:54 2017
Continue creating array? yes
mdadm: array /dev/md3 started.

[root@localhost ~]# mdadm --create /dev/md4 --level=0 --raid-devices=2 /dev/sda7 /dev/sda8
mdadm: /dev/sda7 appears to be part of a raid array:
    level=raid6 devices=4 ctime=Wed Jan 25 08:07:54 2017
mdadm: /dev/sda8 appears to be part of a raid array:
    level=raid6 devices=4 ctime=Wed Jan 25 08:07:54 2017
Continue creating array? yes
mdadm: array /dev/md4 started.
  • Create raid 1 ( /dev/md1 ) above these two .
  • –level=1 , 1 for raid1
[root@localhost ~]# mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/md3 /dev/md4
  • To check raid in your system type cat  /proc/mdstat command
[root@localhost ~]# cat /proc/mdstat

md1 : active raid1 md4[1] md3[0]
      3951232 blocks 64k chunks
md4 : active raid0 sda8[1] sda7[0]
      1975680 blocks 64k chunks
md3 : active raid0 sda6[1] sda5[0]
      1975680 blocks 64k chunks
  • Now format /dev/md1 .
[root@localhost ~]# mkfs.ext3 /dev/md1
  • Mount it to any folder .
  • To mount  =    mount   raidname   foldername
  • 3usageeks is a folder .
  • To check type df   -h command .
[root@localhost ~]# mount /dev/md1 3usageeks/
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             379G  8.2G  351G   3% /
tmpfs                 947M     0  947M   0% /dev/shm
/dev/md1              3.8G   72M  3.5G   2% /root/3usageeks

But that was temporary mounting , when your system reboots raid will be lost .

For permanent mounting .go to  path    /etc/fstab

[root@localhost ~]# vim /etc/fstab
  • Make entry as shown below
  • First what you want to mount
  • Second where you want to mount
  • Third file type
  • Rest is same .
/dev/md0                /root/3usageeks            ext3    defaults  00

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