Online Book Reader

Home Category

Managing RAID on Linux - Derek Vadala [69]

By Root 1319 0
existing array to a single block device.

-h, --help

Displays some helpful information about the command.

-V, --version

Displays the command's version.

Example usage

The following example imports data from /dev/sda8 to a new array, /dev/md0, as defined in /etc/raidtab.

# raidreconf -i /dev/sda8 -n /etc/raidtab -m /dev/md0

Since /dev/sda8 and /dev/md0 differ in size, the filesystem that is already on /dev/sda8 will need to be resized once it is copied to /dev/md0. Since it's an ext2 filesystem, we can use resize2fs to change the size of the filesystem to fill the new array. But first, we have to fsck the filesystem.

# e2fsck -fy /dev/md0

# resize2fs /dev/md0

To resize an array, simply make a copy of your /etc/raidtab file and edit the stanza for the array you want to resize to include a new disk, or to remove an existing one. Then use raidreconf. Remember that if you remove a disk, you need to be certain that the resulting array is large enough to store the data that's already on it. Whether you add a disk or remove one, you will need to resize the filesystem, using resize2fs or the appropriate utility for the filesystem you have chosen. If you add a disk, you should resize the filesystem after you run raidreconf. Shrink the filesystem before running raidreconf if you are removing a disk. In the next example, the array /dev/md0, defined in /etc/raidtab, will be converted to the array defined in /root/raidtab.new:

# raidreconf -o /etc/raidtab -n /root/raidtab.new -m /dev/md0

Once the conversion is completed, manually fsck the new array to ensure that everything was successful.

# e2fsck -f /dev/md0

If e2fsck (or another filesystem check program) returns no errors, raidreconf was a success. Errors mean that something went wrong and that you will need to restore from backups. Using e2fsck to repair any problems that are detected is likely to be a fruitless effort.

You can also change the raid-level in the new raidtab file to convert between RAID-0 and RAID-5. raidreconf also ships with a HOWTO written by Danny Cox.

Name

raidsetfaulty

Synopsis

raidsetfaulty mddevice memberdevice

Use raidsetfaulty to mark a member disk as failed. For example, if you suspect there are problems with a disk, but the md driver hasn't yet kicked it out of the array, you can use raidsetfaulty to fail the disk manually. Once a disk is failed, you can use raidhotremove to pull it out of the array.

Options

raidsetfaulty has no command-line options. It takes an md device and a member disk as its only arguments.

Example usage

The following marks /dev/sdd1, a member of /dev/md0, as failed:

# raidsetfaulty /dev/md0 /dev/sdd1

Once raidsetfaulty is executed, /proc/mdstat will show that the disk has failed. If a spare disk is available, recovery will automatically begin:

# cat /proc/mdstat

Personalities : [linear] [raid0] [raid1] [raid5] [multipath]

read_ahead 1024 sectors

md0 : active raid1 sdb1[2] sdd1[0](F) sdf1[1]

17920384 blocks [2/1] [_U]

[>....................] recovery = 4.2% (764480/17920384)

finish=10.4min speed=27302K/sec

unused devices:

Name

raidstart

Synopsis

raidstart [options] mddevice

Although the modern kernel can now automatically detect and initialize RAID devices, it might be necessary to manually start a device. Maybe the array was not properly initialized when the system booted, or perhaps you are simply experimenting with various types of arrays. The command is also useful for restarting arrays in the unlikely event that they have crashed.

Options

-a, --all

Applies the command to all RAID devices found in /etc/raidtab. You will not need to specify an mddevice.

-c, --configfile filename

Uses a configuration file other than the default /etc/raidtab.

-h, --help

Displays some helpful information about the command.

-V, --version

Displays the command's version.

Example usage

The following starts all arrays described in /etc/raidtab:

# raidstart -a

The following starts all arrays defined in /home/derek/example-raid0:

# raidstart -a

Return Main Page Previous Page Next Page

®Online Book Reader