|< Day Day Up >|
Add a fourth drive to a three-drive software RAID 5 array without a backup and restore .
[Hack #64] explored a method of increasing the disk space in a RAID 1 array by adding a single drive and converting the array to RAID 5. With the ever-increasing storage needs in most businesses, you may find yourself needing to expand a RAID 5 array as well. You can replace all of the drives in the RAID with larger drives and copy all of the files over to the new, larger RAID. Of course, for a three-drive RAID 5 array, this means buying three new drives to use. A cheaper alternative is to back up the array, create a new array using four drives, and copy back the data. This method requires the four drives for the array and a medium to back up to, such as a hard drive large enough to hold the entire RAID or possibly tape. Although, backups and restores aren't as fun as watching a RAID 5 array grow in front of your very eyes.
Some expensive hardware RAID controllers support adding new drives to RAID 5 arrays without requiring a backup and restore. This feature did not exist in software RAID until the creation of raidreconf a tool that can grow RAID 0 and RAID 5 drives. This hack is a step-by-step guide to adding a fourth disk to a three-disk RAID 5 array.
Now that all the caveats are out of the way, let's talk about the example RAID used in this hack. It is a 20-GB three-disk RAID 5 array at /dev/md0 that contains the root partition for a filesystem that spans three hard drives: /dev/hda1 , /dev/hdb1 , and /dev/hdc1 , which are 10 GB each. You then add a fourth 10-GB drive to this array, located at /dev/hdd1 , which makes the final four-disk RAID 5 array 30 GB.
To add a drive to md0 , mount the array and create two copies of the raidtab file: one to represent the original state of the RAID and one to modify to represent the new state of the array. Then unmount the array and stop it, so that raidreconf can change it:
knoppix@tty0[knoppix]$ sudo mkdir /mnt/md0 knoppix@tty0[knoppix]$ sudo mount /dev/md0 /mnt/md0 knoppix@tty0[knoppix]$ sudo cp /mnt/md0/etc/raidtab /etc/raidtabold knoppix@tty0[knoppix]$ sudo cp /mnt/md0/etc/raidtab /etc/raidtabnew knoppix@tty0[knoppix]$ sudo umount /dev/md0 knoppix@tty0[knoppix]$ sudo raidstop /dev/md0
Now you have two files, /etc/raidtabold and /etc/raidtabnew . You must modify /etc/raidtabnew to reflect the configuration of the new RAID 5 array you want to create. First, here is raidtabold :
raiddev /dev/md0 raid-level 5 nr-raid-disks 3 nr-spare-disks 0 persistent-superblock 1 parity-algorithm left-symmetric chunk-size 32 device /dev/hda1 raid-disk 0 device /dev/hdb1 raid-disk 1 device /dev/hdc1 raid-disk 2
Edit raidtabnew and add the new drive to the array:
raiddev /dev/md0 raid-level 5 nr-raid-disks 4 nr-spare-disks 0 persistent-superblock 1 parity-algorithm left-symmetric chunk-size 32 device /dev/hda1 raid-disk 0 device /dev/hdb1 raid-disk 1 device /dev/hdc1 raid-disk 2 device /dev/hdd1 raid-disk 3
Notice the increase to the nr-raid-disks variable and the addition of the fourth raid-disk. Once raidtabnew is modified, reconstruct the array with this command:
knoppix@tty0[knoppix]$ sudo raidreconf -o /etc/raidtabold -n /etc/raidtabnew -m /dev/md0
As your array is reconstructed, raidreconf outputs a nice progress bar, which lets you know the completion rate.
Once raidreconf is finished, mount the new /dev/md0 and copy over the new raidtab file that you have created:
knoppix@tty0[knoppix]$ sudo mount /dev/md0 /mnt/md0 knoppix@tty0[knoppix]$ sudo cp /etc/raidtabnew /mnt/md0/etc/raidtab
While the drive is mounted, you might want to run df and confirm that the size of the array has in fact increased. Now you can reboot your machine into your new, larger array.
6.15.1 See Also
|< Day Day Up >|