Difference between revisions of "Software RAID"
Acecydoxose (talk | contribs) |
m (Reverted edits by Acecydoxose (Talk) to last revision by Mithran) |
||
Line 1: | Line 1: | ||
Linux is capable of setting up software RAID Linear, 0, 1, 4, or 5 arrays via the mdadm command. Doing this requires two or more similar size Linux raid autodetect partitions to be worthwhile (technically you can use the mdadm command on a single partition, but it wouldn't be much of an array then). | Linux is capable of setting up software RAID Linear, 0, 1, 4, or 5 arrays via the mdadm command. Doing this requires two or more similar size Linux raid autodetect partitions to be worthwhile (technically you can use the mdadm command on a single partition, but it wouldn't be much of an array then). | ||
− | + | =Partitioning Your Drives= | |
I would recommend using drives that are all the same size and giving them each a single partition unless you just wish to use the Linear function of mdadm. If you are ready for a more complicated arrangement, you probably don't need this section of the guide anyway. | I would recommend using drives that are all the same size and giving them each a single partition unless you just wish to use the Linear function of mdadm. If you are ready for a more complicated arrangement, you probably don't need this section of the guide anyway. | ||
Line 17: | Line 17: | ||
When you are at the prompt again, simply type w and hit enter to save your changes. Repeat this process for each additional drive you wish to include in your raid. You may want to reboot after you've finished partitioning all your drives to make sure the kernel has acknowledged all the changes and doesn't cause any trouble in the next step. | When you are at the prompt again, simply type w and hit enter to save your changes. Repeat this process for each additional drive you wish to include in your raid. You may want to reboot after you've finished partitioning all your drives to make sure the kernel has acknowledged all the changes and doesn't cause any trouble in the next step. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=Creating Your Array= | =Creating Your Array= |
Latest revision as of 02:03, 18 November 2010
Linux is capable of setting up software RAID Linear, 0, 1, 4, or 5 arrays via the mdadm command. Doing this requires two or more similar size Linux raid autodetect partitions to be worthwhile (technically you can use the mdadm command on a single partition, but it wouldn't be much of an array then).
Partitioning Your Drives
I would recommend using drives that are all the same size and giving them each a single partition unless you just wish to use the Linear function of mdadm. If you are ready for a more complicated arrangement, you probably don't need this section of the guide anyway.
Run fdisk as root on the first drive you wish to use in your array (you can type in fdisk -l to get device name and size information if you aren't sure what the drives you wish to use are called). In my case, that looked like this:
$ fdisk /dev/sdb
That will bring up this prompt
Command (m for help):
Type n and hit enter to create a new partition on your drive. You'll be asked for partition type (choose primary), partition number (choose 1), and starting and ending sector (hit enter for the default, which is the entire drive).
Once you have given fdisk all the parameters it asks for, you should arrive back at the Command prompt. Type t and hit enter to define the type of the partition. We want Linux raid auto, which is hex code fd as of this writing.
When you are at the prompt again, simply type w and hit enter to save your changes. Repeat this process for each additional drive you wish to include in your raid. You may want to reboot after you've finished partitioning all your drives to make sure the kernel has acknowledged all the changes and doesn't cause any trouble in the next step.
Creating Your Array
Once you have your drives partitioned, it's time to create a RAID array. In my case, I wanted to create a mirrored RAID array from two partitions, /dev/sdb1, and /dev/sdc1. That can be accomplished with this command:
mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
/dev/md0 is the name of the new device that will be created to identify the array as a whole. The number after --level= defines the type of RAID array to be set up, 1 for mirroring, 0 for striping, and so on. --raid-devices=2 is the total number partitions that the array will be built from.
Once your array has been created, you can type 'cat /proc/mdstat' to check on it's status. At first, you should see a progress report displaying what percentage of the array building has been completed. Once that is through, the command should display something like this:
Personalities : [raid1] md0 : active raid1 sdb1[0] sdc1[1]
156290752 blocks [2/2] [UU]
unused devices: <none>
Then you're ready to put a file system on it (a simple 'mkfs -t ext3 /dev/md0' in my case), and perhaps mount the array as your HDA's default path for shares as talked about in the article on Adding a Second Hard Drive to your HDA.
This mdadm guide and the people of #fedora on freenode were very helpful to me in collecting this information.