Click to See Complete Forum and Search --> : How I made RAID 1


thread_killer
11-22-2002, 08:17 PM
Making Software Based RAID 1


So the boss told me he wanted to mirror the hard drive on a box we use for
logging PIX activity. So I went to www.tldp.org and got the HOWTO.
Everything looked pretty simple and I gave the boss an enthusiastic "No
problem." Little did I know.....


I did this on a Slackware 8.1 machine, and haven't tried it with any other
distro, so your milage may vary. But in my experience, at least one of three
things is true:
1) Slackware is totally different then anything the author of the HOWTO made
RAID 1 on.
2) The author of the HOWTO is incredibly vague, skipping a few important steps
3) I'm an idiot.
Which ever it is, a lot of playing around trying stuff and I finally got it to
work.

First, make sure you have a kernel that supports RAID as well as the
RAIDtools. They both come native with Slack, but if you don't have the
necessary kernel/tools you can download them and recompile your kernel. Once
that's done, you should have a file called /proc/mdstat. Open a terminal and
type:

cat /proc/mdstat

The output should look like this:

Personalities : [linear] [raid0] [raid1] [raid5]
read_ahead not set
unused devices: <none>

If you see that, you're ready to go! In my example we are going to mirror all
of /dev/hda to /dev/hdc. Use your favorite formating tool to ensure that
there is nothing on your second drive. It should be totally free of any
partition information. Now open your favorite text editor to /etc/raidtab.
What you want to enter here is this:

raiddev /dev/md0
raid-level 1
nr-raid-disks 2
nr-spare-disks 0
chunk-size 4
persistent-superblock 1
device /dev/hda
raid-disk 0
device /dev/hdc
raid-disk 1

Save that guy and now you want to edit /etc/lilo.conf. In lilo you want to
change the line

boot=/dev/hda
to
boot=/dev/md0

In theory, you should be ready to go, but this is where the HOWTO lost me. As
soon as I tried to

mkraid /dev/md0

I would get a slew of errors and the RAID wouldn't work. Why not? Well,
/dev/hda is already mounted! In order to bypass this problem, this is what I
did:
Boot with the CDROM. In Slackware, the first option you get is the option of
which kernel to load. Although I'm pretty sure the bare.i kernel supports
it, I chose raid.s figuring I couldn't go wrong, even if it is support for
hardware RAID. Once the kernel has loaded, login as root. No problems so
far......now it gets interesting. At the prompt type:

vi /etc/raidtab

You'll see a blank screen. Now enter again all the stuff you put into your
original /etc/raidtab.

raiddev /dev/md0
raid-level 1
nr-raid-disks 2
nr-spare-disks 0
chunk-size 4
persistent-superblock 1
device /dev/hda
raid-disk 0
device /dev/hdc
raid-disk 1

Now, if you aren't a vi user, the next thing you'll want to do is hit the
<esc> key then type:

:wq

You're back at the command prompt. Now when you type:

mkraid /dev/md0

Your disks will start to sync up. How do you know? type:

cat /proc/mdstat

You will now see the progress of the disks syching up. I've done this on two
different machines of vastly different hardware specs and on both machines it
took between a minute and a half and two minutes per Gigabyte to sync up.
Keep hitting the up arrow and enter to watch the progress. Once the
synchronization process gets to 99.9 percent, it's not going to go any
further. Go ahead and pop out the boot disk or cdrom and reboot. Everything
should look just as it did before. Open up a terminal and type:

raidstart /dev/md0
then
cat /proc/mdstat

You'll now see that you have active RAID 1 on your system. Viola` ! Simple
IDE based disk mirroring to have a little fault tolerance on your
workstation. Finally, use cfdisk or fdisk and change the type of your
primary linux partition on /dev/hda to type 'fd'. This is the RAID
autodetect partition type. I hope this saves you the time I put into
figuring this out. Good luck!

X_console
11-22-2002, 09:13 PM
Good job. :)

Piix4
11-26-2002, 06:10 AM
Interesting and informative, I have to admit, I probably would have tried to mkraid with mounted partitions.

My question is, how would I take the above nhf/how-to and use 'hardware raid 1' as opposed to 'software raid 1'?

I have to do an install of a hardware raid 1 system, but the first time I can access the system 'on a one day install', will be the first time I get to experiment too?

Any ideas?

pelipala
03-07-2003, 03:24 PM
Thread killer, I am having a problem here. I setup Raid 1 both my both identical hdd. Everything is fine. But when I tried this
unplug my first hdd and boot up from my second hdd--and it worked fine
unplug my second hdd and plugin back my first hdd and boot up from it -- it worked fine. It looked exactly the same. After that, I thought everything is ok. So I plugin all the hdd and continue my work. after few days, I tried it again plug and unplug but this time the hdd is stop sync. So I went to my webmin and check out.
Device file /dev/md4
RAID level Mirrored (RAID1)
Status Active and mounted on /boot
Persistent superblock? Yes Chunk size 64k kB
Partitions in RAID IDE device A partition 1 (Down)
IDE device C partition 1

Device file /dev/md3 RAID
level Mirrored (RAID1)
Status Active and mounted on /
Persistent superblock? Yes Chunk size 64k kB
Partitions in RAID IDE device A partition 6 (Down)
IDE device C partition 6

and etc.etc......

Do you guys have any idea how to sync it back? Thank you