Softwre RAID in Slackware

This guide will show you how to setup a software RAID system in Slacware using mdadm. It's a good idea to sit down and figure out what disks you want in the array and keep track of them. If you have a lot of drives it can be easy to nix a drive you were intending too. Also, I will be assuming in this tutorial that you have four disks (/dev/sdb /dev/sdc /dev/sde and /dev/sdf) that are going into a RAID5 array, please adjust things where needed.

1.) If you have a custom kernel make sure that md is compiled in or is a module that is loaded on boot.

2.) Next you're going to want to use fdisk (or your favorite partition tool) to make your partitions on your disks. For example, bring up fdisk /dev/sdb, hit n to create a new partiton, call it partition 1, hit enter twice to use the entire disk, next hit t to specify the partition type (you'll want to use fd for Linux RAID autodetect). When that’s done type w at the fdisk prompt to write the partition table to disk. Repeat this for each disk you wish to add to the array.

3.) After that is complete it's time to construct the array, at the bash prompt type:

mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sde1 /dev/sdf1

4.) That might take a few minutes, depending on the size of your disks. Next it's time to put a file system on our new array, to do so type:

mkfs.ext3 /dev/md0

5.) After the file system has been created the mdadm.conf needs to be written to do this pass the following command:

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

Your new RAID array is now ready to mount and use. These same steps will work on other distributions. However they'll probably have some shiny GUI tool for you to use.

One other bit of tuning that you might want to do is set the percent of the drive reserved from 5% (default for EXT3 on most distros) to 1% to free up more space. This is the amount of space reserved so that you can still login incase the root FS becomes full. If this isn’t going to be mounted to root or var you can safely turn it down to 1%.

tune2fs /dev/md0 -r 1