Friday, November 9, 2007

Software Raid in Slackware

As my first article, I wanted to discuss Slackware's configuration of software raid. For my example I'm going to use a RAID-1 (Mirror) configuration. The advantage I can see of Software RAID over Hardware RAID is the fact you can raid partitions instead of entire hard drives. Since your drive has swap information typically on it, this means you are mirroring swap space with the Hardware RAID setup. This also means that when you do a Software RAID configuration, you are doubling the capacity of your swap between the two drives where hardware would simply mirror the swap.

First you need to set up what drives are going to be used in the mirror. In my example, I'm going to be using sda and sdb as my mirrored drives. Change this as you deem fit.

Take the amount of RAM in your system, double it, and that's my usual rule of thumb on how large to make the swap space.

cfdisk /dev/sda

Delete all current partitions (obviously, this erases all data!) and create a new primary partition with the size of (Max space - (Your RAM size)). Ex. with 1 gig of ram you would do a 499gigabyte partition on a 500gigabyte drive. Create a second primary partition with the remaining space (1gig). Now select the first partition and go to Type. You want to change it to FD. You also want to make it BOOTABLE. Now select the second partition and go to Type and press enter a bunch until you return to main screen again. This will set it to Linux Swap.

now that you have the first drive set up, you want the second drive to 1:1 image it, right? You could follow all the steps above, but it's just easier to do this command:

sfdisk -d /dev/sda | sfdisk /dev/sdb

This will make an exact copy of the partition setup of sda and place it on sdb. You can now run cfdisk /dev/sdb and verify that they indeed match.

Now set up a md device.
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1

Run "setup" to get Slackware going. When asked for swap drives, make sure both /dev/sda2 and /dev/sdb2 are highlighted (They should be by default). Also make sure you select /dev/md0 when asked what partition to install, NOT /dev/sda1 or /dev/sdb1, they would defeat the point of mirroring.

When doing LILO also make sure your device is configured as /dev/md0 and not /dev/sda1 or /dev/sdb1

No comments: