Linux > Virtualization

Creating and assembling of RAID

(1/1)

Leo.Prince:
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: ---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

--- End code ---

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: ---cat /proc/mdstat
--- End code ---

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: ---man mdadm
--- End code ---


--- Code: ----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.
--- End code ---

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

Creating Raid device


--- Code: ---mdadm --create md-device --chunk=X --level=Y --raid-devices=Z devices
--- End code ---


--- Code: ----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.
--- End code ---

for example:


--- Code: ---mdadm --create /dev/md0 --chunk=4 --level=0 --raid-devices=2 /dev/sda1 /dev/sdb1
--- End code ---

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: ---mdadm --assemble md-device component-devices
--- End code ---

for example


--- Code: ---mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1
--- End code ---

Which will assemble the raid array /dev/md0 from the partitions /dev/sda1 and /dev/sdb1

Alternatively you can use:


--- Code: ---mdadm --assemble --scan
--- End code ---

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: ---mdadm --stop /dev/md0
--- End code ---

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: ---mkfs.ext3 /dev/md0
--- End code ---

This will create an ext3 filesystem on /dev/md0

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


--- Code: ---mkswap /dev/sda7
--- End code ---

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)

Navigation

[0] Message Index

Go to full version