Online Book Reader

Home Category

Managing RAID on Linux - Derek Vadala [44]

By Root 1341 0
disks. ARRAY lines specify device entries for arrays, as well as identifier information. This information can include lists of one or more UUIDs, md device minor numbers, or member devices.

A simple mdadm.conf file might look like this:

DEVICE /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

ARRAY /dev/md0 devices=/dev/sda1,/dev/sdb1

ARRAY /dev/md1 devices=/dev/sdc1,/dev/sdd1

In general, it's best to set up an /etc/mdadm.conf file after you have created an array.You should update the file when new arrays are created. Without an mdadm.conf file, you'd need to specify more detailed information about an array on the command line in order to activate it. That means you'd have to remember which devices belonged to which arrays. That could be a hassle on systems with a lot of disks.

mdadm even provides an easy way to generate ARRAY lines. The output is a single long line, but I have broken it here to fit the page:

# mdadm --detail --scan

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

UUID=410a299e:4cdd535e:169d3df4:48b7144a

If there were multiple arrays running on the system, mdadm would generate an array line for each one. Thus, after you're done building arrays, you could redirect the output of mdadm --detail --scan to /etc/mdadm.conf. Just make sure you manually create a DEVICE entry as well. Chapter 4 contains a complete reference for mdadm.conf.

The RAID Superblock

Starting with version 0.36 of the md driver (kernel version 2.0.35), each disk in an array includes a superblock that describes array properties and stores them on each member disk. The superblock consists of a 4K block of data written to member disks when the array is initialized for the first time. The RAID superblock contains metadata about the array, including its RAID level and member disks. The superblock also contains the UUID I mentioned earlier. It might be helpful to think of the superblock as an on-disk representation of an array's entry in /etc/raidtab. However, keep in mind that the superblock is part of the md driver and is not dependent on user-space utilities. The superblock also allows the kernel to automatically start arrays when the system boots.

The superblock is written near the end of each member disk or partition, at the start of the last 64K block. That means that although the superblock is only 4K long, the overhead for an md member disk is at least 64K. In cases in which there isn't a round number of 64K blocks, you can lose up to 128K worth of disk space for the superblock. So, if there isn't an even number of 64K blocks on the disk, the superblock is at an offset that is 64K less than the last odd-sized block. On member disks that are the same size, the superblock will reside at the same location for each disk. If member disks have varying sizes (in linear mode, for example) then the superblock won't be at a uniform location.

New arrays should always be created with an md superblock. That means setting the persistent-superblock parameter to 1 when working with /etc/raidtab and raidtools. mdadm automatically enables the md superblock by default. Both mdadm and raidtools also provide a way to disable the superblock. This is necessary for backward compatibility with md driver versions prior to 0.36.

Examining Arrays Using /proc/mdstat

The best way to find out if there are already software arrays connected to your system is to use the /proc filesystem. /proc is an interface to important kernel data structures. You can get valuable information about the state of a running Linux system by looking at special files in /proc. These special files act as a window into the running kernel. The /proc filesystem is essential for monitoring the health of any software array.

Once the RAID patches are applied to a kernel and the system is booted using the new kernel, the pseudofile /proc/mdstat will provide information about the current state of RAID devices and the md driver. Once arrays are configured and activated, information about their status will also be displayed. Initially, /proc/mdstat merely reports the available RAID levels:

$

Return Main Page Previous Page Next Page

®Online Book Reader