Linux & RAID - very simple how to

---

Everything You Always Wanted to Know About RAID in Linux But Were Afraid to Ask

What you need:
mdadm

mdadm is a tool for managing Linux Software RAID arrays, it can create, assemble, report on, and monitor arrays.
You cant find in your distro (use your distro’s package manager to install it) or at: http://neilb.web.cse.unsw.edu.au/source/mdadm/ or http://www.kernel.org/pub/linux/utils/raid/mdadm/ or any of the kernel.org mirrors.


What you need to do:

You need some basic knowledge what RAID is - read about RAID at Wikipedia.
OK, now you know what RAID is.

You need to know “why do I need RAID on my Linux?”
Let’s assume you have two hard disks and need to boost up your disk performance (generally boost up your Linux performance).
So… you need RAID 0 should be your choice.

A RAID 0 (also known as a stripe set or striped volume) splits data evenly across two or more disks with no parity information for redundancy. RAID 0 is usually used to increase performance.
A RAID 0 can be created with disks (or disks partitions) of differing sizes, but the storage space added to the array by each disk/partition is limited to the size of the smallest disk—for example, if a 120 GB disk is striped together with a 100 GB disk, the size of the array will be 2*100 GB = 200 GB.

You need to create two partitions - lets assume you have two hard disks (hda and hdb) with about 100GB free space on each. To make RAID partition you need to create two partitions (one on hda and second one on hdb).

Warning: make some backup of your data before making any change on your hard disks.

So… using your fdisk tool (or any other you know) create 100GB’s partitions.

Creating RAID:

now you have two partitions
(for example):
hda3 & hdb2

to create RAID 0 and name it md0 type:

mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/hda3 /dev/hdb2

now you should make some file system on it (using mkfs command).

To create reiserfs system on your RAID partition type:

mkfs.reiserfs /dev/md0

if you prefer ext3 type:

mkfs.ext3 /dev/md0

Now (depending of your Linux distro) you could create mdadm.conf file, type:

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

or

mdadm --detail --scan >> /etc/mdadm/mdadm.conf (depending of your distro)

Finally you should mount your new RAID partition:

Let’s assume you want your RAID partition at /mnt/data and your filesystem is reiserfs

edit /etc/fstab file and add one line

/dev/md0 /mnt/data reiserfs defaults 0 1

Now you can restart your Linux machine or type:

mount /dev/md0

or

mount /mnt/data

That’s all!

Some usefull tips:

to check existing RAID partitions type:

mdadm --detail --scan

sample output:

ARRAY /dev/md1 level=raid0 num-devices=2 UUID=23229fa7:ae5e4cbb:e44dc3ab:a74065bb
ARRAY /dev/md0 level=raid0 num-devices=2 UUID=97fa925a:8164e2cf:327e4a2c:de536eaa

to start RAID partition from LiveCD:

mdadm -A /dev/md0 /dev/hda3 /dev/hdb2

to check details of selected RAID partition type:

mdadm --detail /dev/md0

sample output:

/dev/md0:
Version : 00.90.03
Creation Time : Wed Aug 30 21:02:19 2006
Raid Level : raid0
Array Size : 19550848 (18.65 GiB 20.02 GB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Wed Aug 30 21:02:19 2006
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Chunk Size : 64K

UUID : 97fa925a:8164e2cf:327e4a2c:de536eaa
Events : 0.1

Number Major Minor RaidDevice State
0 3 6 0 active sync /dev/hda6
1 8 1 1 active sync /dev/sda1

Related entries:

Comments are closed.