Friday, February 29, 2008

Setting up the RAID Array

Start by installing mdadm. Open a terminal and type:

sudo apt-get install mdadm

Once this is installed, run 'cfdisk' in the terminal to setup partitions on the RAID disks. For each hard drive that will be included in the RAID array (NOT the disk with the OS already installed), use the following partition settings:

*NOTE* each disk must have the same partition size

- use 1 primary partition, entire size of disk
- Type: 'FD' - Linux RAID autodetect

At this point you're ready to create the array.

Use the following command to create the array, which will be called /dev/md0. (replacing the number of raid-devices with the number of disks you're using and the list of hard drives at the end with your disks)

sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

This will start a 'syncing' process that you can monitor with the following command:

cat /proc/mdstat

Stop at this point! Keep running the above command periodically until resyncing is complete. It usually gives you an estimated time left. Once the resync is complete, continue...

Now you need to format the array. Run the following command to format /dev/md0:

sudo mkfs.ext3 /dev/md0

Once this is done, you need to create the config file.

Run the following command to create this file:


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

You're almost there, the next step is to create a mount point for the RAID array. This is the physical location you will access your array and can be located almost anywhere. I made mine at /mnt/raid/.

First create a directory for the mount point:

sudo mkdir /mnt/raid/

Next you need to edit the fstab file to ensure the array will be mounted automatically on boot. To edit the file, run either:

sudo vi /etc/fstab
or
sudo gedit /etc/fstab

I would recommend the latter if you're not familiar with vi editing.

Insert the following line into the fstab file: (replacing my mount point with the one you used)

/dev/md0 /mnt/raid/ ext3 defaults 1 2

You should also comment out any lines referring to any of the drives that make up the array.

Now you just need to mount the new RAID array. Run:

sudo mount /dev/md0 /mnt/raid/

And you're done! The RAID is now setup and available at the mount point (/mnt/raid/ or whatever mount point you used) When you navigate to this directory (I setup a shortcut to it on my desktop), you'll notice the available space in the window status bar. I ended up with 1.37 TB's of space available in my RAID-5 array, which doesn't include the disk space available on the disk containing Ubuntu.


Continued: Setting up Elisa Media Center

No comments: