Software raid

From INIwiki
Jump to: navigation, search


[edit] Centos 5.3

unmount any active partitions that are using the drives that will become part of the RAID set

In this example I will use following 2 drives to create a RAID 0


Prepare the drives

fdisk /dev/sdb

Remove any existing partitions (THIS WILL DESTROY THE DATA ON THE DRIVE)

Command (m for help): d
Selected partition 1

[edit] Create new partition

Command (m for help):


Command action

e extended

p primary partition (1-4)


Partition number (1-4):


For full disk use defaults

First cylinder (1-121601, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-121601, default 121601):
Using default value 121601

[edit] Set Partition Type to RAID

Command (m for help):


Selected partition


Hex code (type L to list codes):


Changed system type of partition 1 to fd (Linux raid autodetect)

[edit] Verify

Command (m for help):


Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      121601   976760001   fd  Linux raid autodetect

Commit the changes

Command (m for help):


The partition table has been altered!

Calling ioctl() to re-read partition table.


The warning may occur if so reboot.

Follow same steps for other drives

[edit] Preparing the RAID Set

  1. Merge them into a new RAID partition
  2. format
  3. mount

Use mdadm to create RAID

mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/sdb1 /dev/sdd1


cat /proc/mdstat

Personalities : [raid0]
md0 : active raid0 sdd1[1] sdb1[0]
     1953519872 blocks 64k chunks

unused devices: <none>

[edit] Format The New RAID Set

mkfs.ext3 /dev/md0

[edit] Create the mdadm.conf Configuration File

Verify output

mdadm --detail --scan --verbose

Export output

mdadm --detail --scan --verbose > /etc/mdadm.conf

[edit] Create A Mount Point For The RAID Set


[edit] Update fstab

/dev/md0                /data                   ext3    defaults        1 2

[edit] Test the mount

mount /dev/md0 /data/

[edit] Centos 4.x

  • NOTE: this process may be over simplified

Get mdadm


untar and install

tar zxfv mdadm-2.6.7.tgz
cd mdadm-2.6.7
make install

[edit] Five major modes of operation

Create and Assemble, are used to configure and activate arrays.

Manage mode is used to manipulate devices in an active array.

Follow or Monitor mode allows administrators to configure event notification and actions for arrays.

Build mode is used when working with legacy arrays that use an old version of the md driver. - I will not cover build mode here

The remaining options are used for various housekeeping tasks and are not attached to a specific mode of operation, although the mdadm documentation calls these options Misc mode.

[edit] Creating an Array

Create (mdadm --create) mode is used to create a new array. In this example I use mdadm to create a RAID-0 at /dev/md0 made up of /dev/sdb1 and /dev/sdc1:

mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2  /dev/sdb1 /dev/sdc1

Output of...

mdadm: chunk size defaults to 64K
mdadm: array /dev/md0 started.

The --level option specifies which type of RAID to create in the same way that raidtools uses the raid-level configuration line. Valid choices are 0,1,4 and 5 for RAID-0, RAID-1, RAID-4, RAID-5 respectively. Linear (--level=linear) is also a valid choice for linear mode. The --raid-devices option works the same as the nr-raid-disks option when using /etc/raidtab and raidtools.

[edit] Reference:
Personal tools