Raid 1

Karl Larsen k5di at zianet.com
Thu Apr 3 21:35:03 UTC 2008


  I put things in google and it found:

http://mywheel.net/blog/index.php/software-raid-in-ubuntu/

and I copied the words to my computer for study. It is like this:



This is a small tutorial to help you getting started with Software RAID 
in Ubuntu. It was tested on Ubuntu Server 6.06 but it will probably work 
on Breezy or even on Debian.

Actually, it could possibly work in any GNU/Linux flavour around but I 
won’t guarantee on that :-)

Please take in attention that you can loose your data! If it happens, 
don’t complain to me. Follow these guidelines on your own risk.

Why I became paranoid

Five years ago I lost an IBM 80G hard drive that was full of photos, 
past works and several other important stuff that really mattered to me. 
I almost cried.

Since then, I became a paranoid with keeping my data safe from harm. I 
have several machines and there’s a lot of files spawned among them. 
Call it “Distributed backuping”. Unfortunately, it’s not very useful so 
I decided I had to have a system that was yet easily usable.

RAID 1 was the answer.

What I bought

To accomplish such, I bought 2x Seagate Barracuda 7200RPM 160GB 8MB 
Cache. Seagate is well known for is fiability so I didn’t consider any 
other branch.

Software RAID vs Hardware RAID

Hardware RAID is a must for servers who have a high demand and need 
serious throughput. Not the case of my home server that’s acting as a 
fileserver!

Plus, I didn’t have any RAID controller around and sparing €140 on the 
hard drivers was enough for one day.

I won’t stand my claims (that Software RAID works great for a home 
server) since you can do it for yourself. Adaptec has some really nice 
research papers that should how good software RAID can be — although 
stating that their hardware RAID is better ;-)

Setting up the hardware

I don’t know in depth how the IDE controller works so I couldn’t 
conclude for myself (nor I had the time to investigate it any further 
:-) if setting up both hard drives on the same IDE connector (1x Master, 
1x Slave) would be faster than having separate IDE connectors (1x 
Master, 1x Mater). I picked the latter. I’ll wait for some insightful 
response to this question.

Update

Here’s the response, from Carlos Rodrigues. Thanks Carlos :-)

An IDE channel is a shared bus, so only one drive may be 
pumping/receiving data at any given time, and some commands lock the bus 
(try having a CD-Writer and a CD reader on the same channel, and opening 
and closing the tray on the reader while the writer is recording
 
instant buffer underrun). Plus, changing directions (write a “read?? 
command/read data/write a “write?? command/
) is expensive over IDE, so 
software RAID on a single IDE channel is very bad performance-wise.

On the mean time, you can proceed with any of the approaches and revert 
it later.

Setting it all from the command line

The system was all set up prior to the Software RAID. Also, I don’t have 
any X server so all I did was through the command line. Actually, 
through an SSH session.

The hard work

The first thing I did was checking if both hard drives were being 
correctly detected on BIOS. They were, let’s move on.

Next, let’s set a partition on each disk and then set its type to Linux 
RAID. To do such, let’s first figure out which devices the disks got 
mapped to.

Type $ cat /proc/diskstats. Mine were detected as /dev/hda and /dev/hdc.

To set up a partitition, run fdisk twice, each one for each disk and do 
the following:

$ fdisk /dev/hdX

Type ‘n’, create a logic partition. Write down the cylinders you used 
because the partitions on the others disk have to fill the same exact 
ammount of space. Set it’s type to ‘fd’ by typing t. Finally, save the 
changes by typing w.

I’ll remember once again than you have to follow this procedure twice, 
once of earch hard drive.

Now it’s time to create the virtual disk. Make sure mdadm is installed. 
If it isn’t, I can lend you a hand on that. Just do

$ apt-get install mdadm

Then, fire up the following command

$ mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/hda1 
/dev/hdc1

Congratulations, your virtual RAID1 hard drive has been successfully 
created!

Now we need to create a partition with a real file system instead of 
that virtual Linux RAID you set before.

We’re almost done. Restart the computer.

$ shutdown -r now

The disks are now being synced. You can’t use the virtual disk.. yet. Type

$ watch cat /proc/mdstat and wait until the rsync finishes. In the 
meanwhile, get a nice cup of coffee of your favourite beverage.

Did it finish? Great!

Format it:

$ mkfs -t reiserfs /dev/md0

Add the new virtual disk entry to /etc/fstab (explaining how /etc/fstab 
works is out of the scope of this article) and do issue

$ mount -a

Conclusions

You just set a Software RAID on GNU/Linux through the command line. 
Bottom line conclusions: Linux rocks! :-)

References

http://www.linuxdevcenter.com/pub/a/linux/2002/12/05/RAID.html

https://wiki.ubuntu.com/Raid?highlight=%28raid%29

http://www.howtoforge.com/linux_software_raid

Future work

There’s still a question to be answered. I also welcome any comments 
correcting grammar, syntax or any other kind of errors.


This gets you well on the way to Software Raid 1 and it should work. I 
got mdadm with no problems. When time permits I will try and get it set 
up with one HD an IDE and the other a SATA. Not sure how this will work 
but will find out by doing it :-)

Karl

-- 

	Karl F. Larsen, AKA K5DI
	Linux User
	#450462   http://counter.li.org.
   PGP 4208 4D6E 595F 22B9 FF1C  ECB6 4A3C 2C54 FE23 53A7





More information about the ubuntu-users mailing list