Monday, June 21, 2010

How to create software raid0

How to create software raid0

RAID:

RAID- Redundant Array of Independent Disks
RAID0- is a method of storing data on multiple computer storage devices to achieving faster read and write speeds.The data is broken down into blocks and each block is written to a separate disk drive. If one disk fails total data will loose.

Here we are going to create software raid0.

consider we have 2 hardisk sda and sdb

# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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        1318    10482412+  83  Linux
/dev/sda3            1319        1579     2096482+  82  Linux swap / Solaris
/dev/sda4            1580       60801   475700715   83  Linux

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1       60801   488384001   42  SFS


We are going to create raid in /dev/sda4 and /dev/sdb1

First we have to change the id of both the partitions.

# fdisk /dev/sda
..........
..........
Command (m for help):t
Partition number (1-4):4
Hex code (type L to list codes):fd
Command (m for help):w


# fdisk /dev/sdb
..........
..........
Command (m for help):t
Partition number (1-4):1
Hex code (type L to list codes):fd
Command (m for help):w

NOw,

# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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        1318    10482412+  83  Linux
/dev/sda3            1319        1579     2096482+  82  Linux swap / Solaris
/dev/sda4            1580       60801   475700715   fd  Linux

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1       60801   488384001   fd  SFS

Use the partprobe to reload the changes without rebooting the box:

# partprobe /dev/sda4
partprobe /dev/sdb1


Create raid0:

# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sda4 /dev/sdb1

create file system on our raid,

# mkfs.ext3 /dev/md0 

To check the raid0,

# cat /proc/mdstat 
Personalities : [raid0]
md0 : active raid0 sdb1[1] sda4[0]
      964083520 blocks 64k chunks
unused devices:


and,

# mdadm --detail /dev/md0 
/dev/md0:
        Version : 0.90
  Creation Time : Wed Jun 16 02:01:47 2010
     Raid Level : raid0
     Array Size : 964083520 (919.42 GiB 987.22 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Wed Jun 16 02:01:47 2010
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

     Chunk Size : 64K

           UUID : 7df3ae47:4d85c172:4522530b:f2487312
         Events : 0.1

    Number   Major   Minor   RaidDevice State
       0       8        4        0      active sync   /dev/sda4
       1       8       17        1      active sync   /dev/sdb1


Finally we have to mount the raid to any location like,

# mount /dev/md0 /raid

If you want to prementaly mount it, give the detais in the fstab.

I think this document is usefull for you...... :-)



.

No comments:

Post a Comment