Ubuntu – How to Create Software RAID 1 in 12.04 Ubuntu Linux – Tutorial
There are several guides for creating software RAID’s on Ubuntu on the internet. Most of them we’ve found to be not very comprehensive or difficult to understand and follow. This is why we’ve created this tutorial as easy to use as we could. Pictures on every step and detailed instructions. In fact, it may be a little to comprehensive, but that’s ok. At least you’ll be confident you created the RAID correctly. If you do have any questions or run into a problem, feel free to leave a comment below and we’ll try to help.
Linux software RAIDs work differently than normal hardware RAID’s. They are partition based, instead of disk based. This means that you must create matching partitions on all disks before creating the RAID. Hardware RAIDs have you add the disks to the RAID and then create the partition.
This tutorial was created while installing Ubuntu 12.04 64 bit Server Edition. It’s intended to be the first in a series of Linux software RAID tutorials. Future tutorials will cover topics such as how to recover from a failed disk.
This server has two 16GB disks installed. We will be creating 2 partitions: a 2GB swap partition and a 14GB root partition. After we are done, the server will stay in operation if one of the two disks fails. Most of the pictures in this tutorial are self-explanatory. The option you need to choose will be highlighted. We will provide comments on the picture if there is any special considerations.
To begin, run the Ubuntu installer. When you get the ‘Partition disks’ menu, choose ‘Manual’:
In this case, the disks are new and there are no partition tables on it. Select each disk to create a partition table:
Select the free space on the first disk to create partitions on it:
The first partition will be 2GB at the beginning of the disk (this will be used for swap space):
You can leave partition settings the default. After the RAID is created, these partitions will be overwritten, so there is no need to configure them here:
Select the remaining free space on the first disk to create the 2nd partition. In this case, we will be using the remaining free space for this partition:
Again, do not worry about configuring the partition here. Leave it at the defaults:
After creating the 2 partitions on the first disk, repeat the process and create identical partitions on the second disk.
You should now see identical partition sizes on both disks. Choose ‘Configure software RAID’ to begin creating the software RAID:
Again, the Linux software RAID is partition based, so we will need to create 2 RAIDs, 1 for each of our set of 2 partitions. Choose ‘Create MD device’ to begin creating the first:
This step can be confusing for some people. Our first RAID will consist of 2 partitions (the 2GB partitions on each of the disks), so choose 2 active devices:
We aren’t using any spare devices in this example:
Only select the 2GB partitions. There should be one on each disk:
You’ll be taken back to the RAID configuration menu. Choose ‘Create MD device’ to begin creating the 2nd RAID:
Choose both of the 14GB partitions (again, there should be one on each disk):
Choose ‘Finish’ to complete the RAID configuration.
Now we partition the 2 RAIDs. You’ll see ‘RAID1 device #0’ and ‘RAID1 device #1’. These are the only to we need to partition.
To configure the swap RAID partition, select the 2GB RAID device listed under ‘RAID1 device #0’:
For ‘Use as’, select ‘swap area’ and then choose ‘Done setting up the partition’:
You will be taken back to the partitioning menu. Select the 2nd RAID device (in this case, it’s the 14GB one) from the menu. You can configure the RAID device with whatever file system you need, but we are going with the default, Ext4. For the ‘Mount point’, make it the root by selecting “/”. Now choose ‘Done setting up the partition’:
Your RAID devices should be partitioned similar to what is listed below. Choose ‘Finish partitioning and write changes to disk’:
Typically, the reason why RAID is implemented is so the operating system will continue to operate in the event of a single disk failure. Choose ‘Yes’ here so you will not see any interruptions when booting with a failed disk:
Almost done! The operating system will continue to install on the RAID you setup:
After the operating system installs, you will be prompted to install GRUB. Choose YES to install it to the Master Boot Record:
As you can see, installing GRUB to the Master Boot Record will install it to both hard disks, (/dev/sda & /dev/sdb).
That’s it! After the install is complete, you should be able to boot into the OS. If you loose a hard disk, the OS will continue to run without interuption.