Online Book Reader

Home Category

Managing RAID on Linux - Derek Vadala [57]

By Root 1337 0
move on. First, create the file /etc/mdadm.conf, using any editor and a DEVICE line that lists all RAID member disks. On my system, for example, I create the file with the following line:

DEVICE /dev/sd*

This means that mdadm will examine all the sd device files on my system (/dev/sdb1 through /dev/sdh1) when looking for member disks. Next, you should execute mdadm with the --detail and --scan options to generate array lines and redirect the output so that it is appended to /etc/mdadm.conf.

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

You should be left with an mdadm.conf file that contains the DEVICE line you created, plus an ARRAY line for each active RAID.

# cat /etc/mdadm.conf

DEVICE /dev/sd{b,c,d,e,f,g,h}1

ARRAY /dev/md1 level=raid0 num-devices=5 \

UUID=66b78871:dc09da58:60f57124:978e5dbf

ARRAY /dev/md0 level=raid1 num-devices=2 \

UUID=b047f5a4:b6f459e0:fb04a323:46a1a012

Arrays that are not active will not be scanned by mdadm. Remember that you aren't obligated to create an mdadm.conf file, but it will make managing arrays using mdadm much easier. Now you can start both arrays with a simple command:

# mdadm -As

mdadm: /dev/md1 has been started with 5 drives.

mdadm: /dev/md0 has been started with 2 drives.

Without the configuration file, you would need to know at least which disks were members. And you would need to execute a command such as the following for each array, every time you wanted to activate it:

# mdadm -A /dev/md1 /dev/sdc1 /dev/sdg1 /dev/sdd1 \

/dev/sdh1 /dev/sde1

If you're using raidtools, start arrays with the raidstart command:

# raidstart /dev/md1

Or, start all arrays listed in /etc/raidtab:

# raidstart -a

As I mentioned earlier in this chapter, you can stop an active array by using either raidstop or mdadm -S. Don't forget to unmount filesystems first.

# raidstop /dev/md0

# mdadm -S /dev/md1

Irrespective of which management tools you decided to use, you can now add entries for your arrays to /etc/fstab, provided that you are using kernel RAID autodetection. Otherwise, you will need to add entries to your system startup scripts to activate arrays using mdadm or raidstart.

The Next Step

Even if you spend large amounts of time planning and architecting your array, making a mistake is nearly inevitable. I think the best advice I can give for building these systems is: don't worry if it doesn't work perfectly the first time around. Trying out multiple solutions and then deciding which one best suits your needs is much more worthwhile than sitting at a whiteboard for three weeks, trying to plan in advance. Hopefully, this chapter has given you the information you need to get started in building a software RAID solution.

Choosing an appropriate RAID level is only the first step. You might need to trade some of the dollars you had planned to spend on storage capacity for a hardware controller. Chapter 5 offers advice on how to make that decision. But software RAID might help you to prototype the right system without spending much money. The next chapter offers reference material on the md driver, raidtools, and mdadm, which will help supplement the material in this chapter. Chapter 4 also contains more /etc/raidtab and mdadm examples that can help make your configurations more robust by using spare disks and hybrid arrays.

Chapter 4. Software RAID Reference

This chapter contains reference information about kernel RAID parameters and management tools, including the raidtools package and the newer mdadm. It also contains many example configurations and an in-depth guide to software RAID and the /proc filesystem.

Much of the material in this chapter is an amalgamation of my own experimentation with software RAID, combined with material from manual pages, the Linux kernel source code, and the various versions of the Software-RAID HOWTO and supporting documents. Linas Vepstas wrote the original version of "The Software-RAID HOWTO," which was extremely useful to me when I built my first software RAID. A replacement document, written from the ground up, was released by Jakob

Return Main Page Previous Page Next Page

®Online Book Reader