ndzlogo-1-1
0%
Loading ...

INDIA – HEADQUARTERS

INDIA

UNITED STATES

CANADA

 

We are now ready to begin our first Linux software RAID configuration.  The following steps will walk you through creating a RAID 5 array created from 2 physical disks.  Let’s get to it!

STEP1:

First we need to check whether there is any free disks are awailable in the server, it can be checked by ‘fdisk -l’ in the shell.

Eg:

 [root@Linux01 ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 13 104391 83 Linux

/dev/sda2 14 1305 10377990 8e Linux LVM

 Disk /dev/sdb: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 Device Boot Start End Blocks Id System

 Disk /dev/sdc: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

[root@Linux01 ~]#

STEP2:

Create a primary partition of type fb on each of the devices that will be used in the RAID array.  In the example below, we will create a primary partition on /dev/sdb.  This step should be repeated for each device in the array (i.e. /dev/sdc)

[root@Linux01 ~]# fdisk /dev/sdb

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-522, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-522, default 522):

Using default value 522

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): fb

Changed system type of partition 1 to fb (Unknown)

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@Linux01 ~]#

STEP3:

Repeat Step #2 for the remaining devices (i.e. /dev/sdc and /dev/sdd) in the array until each device has been configured with a partition of type fb

STEP4:

Use the RAID admin utility to create an array from the available partitions created from Step #2

[root@Linux01 ~]# mdadm –create /dev/md0 –level=5 –raid-devices=3 /dev/sdb1 /dev/sdc1

mdadm: array /dev/md0 started.

[root@Linux01 ~]#

STEP5:

Monitor the creation of the array

 [root@Linux01 ~]# cat /proc/mdstat

Personalities : [raid6] [raid5] [raid4]

md0 : active raid5 sdd1[3] sdc1[1] sdb1[0]

8385664 blocks level 5, 64k chunk, algorithm 2 [3/2] [UU_]

[

unused devices:

[root@Linux01 ~]#

STEP6:

Add the new array to the /etc/mdadm.conf so that it will be automatically activated upon reboot.  The start-up scripts will reference the mdadm.conf file upon boot and start any arrays listed within this file.  If the array is not listed in the /etc/mdadm.conf file, you will have to start the array manually.

 

===>……………..] recovery = 15.7% (660556/4192832) finish=0.8min speed=73395K/sec

The following was added to the /etc/mdadm.conf file to satisfy our configuration for the RAID5 array with the 2 devices (sdb1, sdc1):

ARRAY /dev/md0 level=raid5 num-devices=2 devices=/dev/sdb1,/dev/sdc1

STEP7:

Overlay the new RAID device with a file-system

[root@Linux01 ~]# mke2fs -j /dev/md0

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

1048576 inodes, 2096416 blocks

104820 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2147483648

64 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

 

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@Linux01 ~]#

STEP8:

Mount the file-system and verify its functionality

root@Linux01 ~]# mkdir /RAID5

[root@Linux01 ~]# mount /dev/md0 /RAID5/

[root@Linux01 ~]# ls -al /RAID5/

total 28

drwxr-xr-x 3 root root 4096 Jun 11 09:33 .

drwxr-xr-x 29 root root 4096 Jun 11 09:35 ..

drwx—— 2 root root 16384 Jun 11 09:33 lost+found

[root@Linux01 ~]#

STEP9:

Update the /etc/fstab file to auto mount the RAID device upon subsequent system reboots

The following was added to our /etc/fstab to support the RAID5 array we configured in this example:

/dev/md0 /RAID5 ext3 defaults 0 0

Thats it.. You have done it.. 🙂