Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Creating and assembling of RAID  (Read 2480 times)

0 Members and 1 Guest are viewing this topic.

Leo.Prince

  • Guest
Creating and assembling of RAID
« on: November 03, 2013, 06:13:32 pm »
Hi,

RAID (Redundant Array of Independent Disks) is an important component in the modern Linux as well as Windows machines. We can set up soft RAID using the tool mdadm

We can install mdadm by downloading source as compiling it.

Code: [Select]
wget https://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-1.4.0.tar.gz
tar -xvf ./mdadm-1.4.0.tar.gz
cd mdadm-1.4.0.tgz
make install

By using the mdadm tool, We will be able to access the raid devices. To see if there is any existing softRAID devices, use the following command

Code: [Select]
cat /proc/mdstat
If this produces a result as follows cat: /proc/mdstat: No such file or directory, That means, There are no raid devices configured so far. Let us see how to create raid devices. We can use the mdadm command for that

Code: [Select]
man mdadm
Code: [Select]
-A, --assemble Assemble a pre-existing array that was previously created with --create.
    -C, --create Create a new array. You only ever need to do this once, if you try to create arrays with partitions that are part of other arrays, mdadm will warn you.
    --stop Stop an assembled array. The array must be unmounted before this will work.

You can create and assemble a raid device to use it.

Creating Raid device

Code: [Select]
mdadm --create md-device --chunk=X --level=Y --raid-devices=Z devices
Code: [Select]
-c, --chunk= Specify chunk sihttp://en.wikipedia.org/wiki/RAIDze in kb. The default is 64.
    -l, --level= Set raid level, options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid4, 4, raid5, 5, raid6, 6, multipath, mp, fautly.
    -n, --raid-devices= Specify the number of active devices in the array.

for example:

Code: [Select]
mdadm --create /dev/md0 --chunk=4 --level=0 --raid-devices=2 /dev/sda1 /dev/sdb1
This will create a raid0 array /dev/md0 formed from /dev/sda1 and /dev/sdb1, with chunk size 4.

Note : We needed to specify the type of raid we needed to configure (eg: raid0,raid10,raid1 etc) at this point of creating the raid device.

This link will give you pretty clear idea about the soft RAIDs we have http://en.wikipedia.org/wiki/RAID

Assembling a RAID device

After creating the raid devices, We needed to assemble the raid device with the different disk arrays to make it mounted and usable.

The below pasted is the assembling syntax.

Code: [Select]
mdadm --assemble md-device component-devices
for example

Code: [Select]
mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1
Which will assemble the raid array /dev/md0 from the partitions /dev/sda1 and /dev/sdb1

Alternatively you can use:

Code: [Select]
mdadm --assemble --scan
It will assemble any raid arrays it can detect automatically.

So your raid device is fine to use. In case at any point of time, If you want to stop/unmount the device, You can simply stop the device.

Code: [Select]
mdadm --stop /dev/md0
This will stop the assembled array md0, so long as its not mounted.

Next if you want to have your raid device with ext3 file system, Use the following command

Code: [Select]
mkfs.ext3 /dev/md0
This will create an ext3 filesystem on /dev/md0

If you want to create a swapspace on /dev/sda7, Try this

Code: [Select]
mkswap /dev/sda7
After all, Please note that the configuration file for mdadm is /etc/mdadm/mdadm.conf. There are plenty of other options left for the raid tools. As I have limitations with this article, I am stopping this for now.

I hope you are having a basic idea to set up and configure various raid devices. That is it from my end.  8)