Software RAID1, Debian Sarge fresh installation, kernel 2.6.8, GRUB


This works about the same for etch too. Absolutely no warranty, use entirely at your own risk, the author accepts no responsibility. It is quite likely some statements in this document are inaccurate.

Oh joy, I have a need to build an SMTP/IMAP server, and because all of our company's email will be stored on that server, I must not loose that data. I am going to use software RAID1 to mirror the hard drive and also use rdiff-backup to make a backup once each day. I experimented for days using bits and pieces of the many HOWTOs I found on the subject of RAID1 mirroring on Linux (and specifically Debian) and I found that there is a lot of stuff that did not work for me or is ancient history. I am not an expert on the subject by any means. Note: if you should ever want to install programs from 'testing' that depend on a recent version of libc6, installing libc6 from 'testing' may remove your kernel! You might consider trying to build your new system with an Etch CD if you desire any programs from 'testing' or 'unstable'.

The easiest way to get RAID1 functionality is to configure it using the 'partman' partition manager and 'mdcfg' presented to you when you first install Debian. Of course this is only useful if you are building a new system. I am going to document the procedure I followed. If you already have a system up and running with a single drive, and you wish to add a second drive and configure them as a RAID1 array, this document is not for you. See http://verchick.com/mecham/public_html/raid/raid-index.html for other choices.

This document in itself is not designed to get RAID1 functional on your computer. It is designed to get you comfortable with doing so in a test environment. Some of the steps we perform should not be performed on a production system with data on it. We do these things to educate us. Once you are comfortable in your understanding of the process, my job is done.

My setup is an i386 based machine. I am only using the 2.6.8 kernel, the ext3 file system and the GRUB boot loader. I recommend these only because I have not tested with any other combination.

There is a major problem with getting RAID1 to function. The software modules that are needed to read the data from the devices in the array need to be loaded at boot time, or the devices cannot be read. The problem is, these modules are not normally included in the boot ramdisk image (/boot/initrd.img-x.x.x). For our purposes we need two modules, 'md' (multi-disk) and 'raid1' (redundant array of inexpensive/independent disks, level 1). This is very similar to the problem Windows administrators face when dealing with device drivers for hard disk controllers that are not included with Windows. You have to install the device driver on the hard drive before you install the controller, or you cannot read your hard drive. While there is evidence it may be possible, I know of no straightforward way to include the needed modules in a series of boot floppies. The bottom line is, if you cannot get the modules loaded into the ramdisk, you may not be able to boot your machine from your hard drives. Also, it is not enough to get the modules into the boot ramdisk image. Doing so will get one or two RAID devices running but the remainder depend on additional RAID software that loads later on in the boot process. In addition, you must get your system configured in such a way that BOTH hard drives are bootable so you can boot your system from either drive if the other drive has failed, or is removed. I have to admit that I don't understand (whether Windows or Linux) how the disk is read if the software needed to read the disk is on the disk! It must be some special low-level boot magic.

If you happen to have a functioning Debian system available, view this:
man initrd

I am going to talk about both SCSI and EIDE hard drives because I have tested this with both, but the examples will be SCSI. There are not a lot of differences. Simply substitute 'sda' with 'hda', sdb with 'hdc' and so on. Sorry, but I have not tested with SATA drives. You will need two identical hard drives to complete this project. They can actually be different (within reason) but if they differ in size, the smallest drive will dictate the size of the partitions. Identical is better. It is also a good idea to have a spare drive available if one of the other two drives fails. That is the point isn't it?

Name your hard drives so it is easier for me to refer to them. Actually label these names on them. Name one of them apple, and the other pie. If the drives differ in size, label the smaller one apple. For an EIDE system, one drive must be installed on the primary master drive connector, and the other on the secondary master drive connector. I am going to refer to the EIDE drive that is connected to the primary master connector as being in the primary position. Linux should recognize this drive as /dev/hda. I am going to refer to the EIDE drive that is connected to the secondary master connector as being in the secondary position. Linux should recognize this drive as /dev/hdc.

For a SCSI system with both drives on one SCSI adapter, one drive should be configured as SCSI device id 0 (on my system removing all ID jumpers on the drive sets it to 0), and the other drive is typically configured as SCSI device id 1 (I add a jumper to the drive to set this). I am going to refer to the SCSI drive that is configured as SCSI device id 0 as being in the primary position. Linux should recognize this drive as /dev/sda. I am going to refer to the SCSI drive that is configured as SCSI device id 1 as being in the secondary position. Linux should recognize this drive as /dev/sdb. These statements assume both drives are installed. If only one drive is installed, it will be in the primary position regardless of the jumper setting.

For a SCSI system with each drive on separate SCSI adapters, both drives are typically configured as SCSI device id 0. You will need to determine which adapter is recognized first, and which is recognized second. If the adapters are the same model by the same manufacturer this is a more difficult task. You may have to temporarily remove one of the drives to see which adapter is recognized first. Then you may want to label them. I am going to refer to the SCSI drive that is on the adapter that is recognized first as being in the primary position. Linux usually recognizes this drive as /dev/sda. I am going to refer to the SCSI drive that is on the adapter that is recognized second as being in the secondary position. Linux should recognize this drive as /dev/sdb. These statements assume both drives are installed. If only one drive is installed, it will be in the primary position regardless of which adapter it is installed on.

All the data on the drives we use will be erased. Any drive that may be used in the future to replace a drive that has failed must be clean. Let me explain why. Let's pretend for a moment that we used apple in our array, then unplugged it and replaced it, then put it away for later use as an emergency replacement. A year from now one of our drives goes bad, so we shut the machine down and place apple in its place. Then we boot up, and to our horror, the remaining good drive has synched itself to the data stored on apple and not the other way around. Ideally the two drives we start with should be cleaned. To clean a drive, I install it in a computer by itself, boot up using a DBAN disk and change the Method to Quick. This will replace every bit on the drive with a zero. Install apple in the primary position and pie in the secondary position. A good place for the CDROM drive is the secondary slave EIDE interface but I should mention that having a CDROM on the same cable with an EIDE drive will slow the EIDE drive down. If you are using IDE drives, once Debian is installed it is best to unplug the CDROM drive if possible. Boot up using the appropriate Debian installer media. I use the stable netinst CD.

Index   page 2 (next)   page 3 (last)