Linux Raid Guide
Have you ever lost precious files when your hard disk died suddenly? If yes, then you should know about RAID. For those who haven't heard of it, RAID is a Redundant Array of Inexpensive Disks, ie a way of arranging data on two (or more) disks in order to maximize performance and/or availability. There are many possible RAID setups, most of which are probably too excessive for home/desktop uses (if you need to ask, then you don't need it!). The simplest and most useful one is RAID 1 (mirroring), which maintains at all times a persistent copy of your data on two physical disks. If one disk fails, you can replace it without losing any data.
Let me give you a real life example: On my 24/7 linux file and proxy server I had installed a RAID 1 mirror for the home directory. I hadn't checked the status of the server, but a friend of mine, who was using it regularly, complained of slower performance. Curious to check this out, I went on-site and realized that one disk had failed 15 days ago. I realize that I sound like a crappy sysadmin, but this was really a server for limited use by me and a few of my friends. Nevertheless, no data had been lost from the home directory, the machine had kept running and merely complained about the inability to do reads/writes on the second drive. I replaced the drive and the server was up and running in less than 30 minutes.
The good news is that you can have a RAID setup under linux using only a software driver and two disks (same can also be done under XP, to be fair). Although you probably have a RAID controller on your motherboard, it's a less flexible solution and it's not going to be faster unless you invest on specialized hardware. Most on-board RAID controllers are not “true” hardware RAID.
I'm not going to give an extensive article on software RAID, there are special HOWTOs for that. I am going to show you how to install a very simple RAID-1 setup to protect crucial files (photos, documents and anything that is very hard to replace). You will need:
- 1. Root access (!)
- 2. Two partitions of approximately the same size on separate hard drives. If you're going to use PATA disks, the drives should be connected to different channels, ie not on the same ribbon cable. The location and the number of the partitions do not matter. Neither does it matter if one drive is SATA and the other PATA or SCSI. Any combination can work, including drives from different makers, different sizes and different speeds.
- 3. A recent linux kernel, preferrably newer than 2.6.16 with the appropriate modules. Most probably, your distribution already includes them by default. Note that software RAID has been available for a very long time under Linux, I had been running RAID-0 with 2.2 series kernels.
- 4. The mdadm software.
We will take these steps one by one and in very little time you'll have a “safe” RAID-1 partition that you can use for your most important files.