Choosing the right RAID (Redundant Array of Independent Disks) level for your storage array is essential to ensuring that your server meets your speed and redundancy needs. Knowing the different RAID options will let you make an informed decision about how you should store your data. In this article, we will go over the most common types of RAID, their use cases, and how to configure software RAID on Ubuntu 18.04.
RAID is a storage virtualization technology that combines multiple disks and puts them into an array. These arrays differ depending on the RAID level that is used. Some are more focused on redundancy, others are focused on faster read/write times, and others still are focused on availability. Let's take a look at each of the commonly used RAID types and why you would want to choose them.
Note: If you are using disks of different sizes in a RAID, each disk will default to the capacity of the disk with the least amount of storage space.
RAID 0 breaks a file into blocks which are then written to each disk (first block to the first disk, second block to the second disk, and so on). If there is data remaining after the last disk, the next block is written to the first disk and the cycle continues until all blocks are saved. This means that, when utilizing RAID 0, there is no redundancy. Data is stored in a segmented fashion on both disks for any given file so losing one disk is sufficient to lose all of the data stored on the array. RAID 0 is ideal for nonessential environments where speed is preferred such as testing environments or housing photos/videos that the user is comfortable losing in the event of disk failure.
RAID 1 mirrors data across all disks in its array, meaning each block of data is written to each disk. This gives you complete redundancy with your data as long as one of your disks is still functioning. The drawback is that mirrored data means you will only ever have the storage capacity of the smallest disk in the array since the same data is copied onto each disk.
RAID 5 stripes data across the disks like RAID 0 but also uses an algorithmic calculation known as a parity function for redundancy. With RAID 5, you need a minimum of three disks for the algorithm to be able to rebuild the data when a drive fails. It has advantages over RAID 1, as you get access to more storage from the disks due to the striping. The amount of disks available for RAID 5 is the number of disks used minus one, so if you are using four disks you will have three disks worth of data available. Only one drive may fail in a RAID 5 setup.
RAID 6, much like RAID 5, uses an algorithmic calculation known as a parity function for redundancy. Unlike RAID 5, RAID 6 uses two parity bits know as double parity. RAID 6 requires a minimum of four disks for the algorithm to work. It gains the fault tolerance of being able to lose two disks, though it loses a little bit of read speed in comparison to RAID 5.
RAID 10 is a combination of RAID 1 and RAID 0. It has the redundancy benefit of RAID 1 with the speed benefit of RAID 0. RAID 10 is also known as a stripe of mirrors since the data is striped across the entire array, but within the subarray, the data is mirrored. The amount of disks available for RAID 10 is the number of disks in the array divided by two. One drive may fail per subarray in a RAID 10 setup. However, this only guarantees you redundancy for a single-drive failure, regardless of the total number of disks in the array.
Let's take a look at some comparisons of RAID levels.
|4x read and write
|4x read and 2x write
1 per subarray
Note: Calculations for the speed gain column are based on using the minimum number of disks allowable for the RAID level.
To get to the "Partition disks" page, go through the installation process of Ubuntu 18.04, choosing the appropriate language, country, keyboard layout, a primary network interface, a hostname, username, password, and time zone.
When you get to the "Partition disks" page, select Manual.
From this new page, we are able to see all of our hard disks and begin creating our partition tables.
Select a hard disk to create a partition table and click <Yes>. After creating the partition table, your new disk should look like "SCSI1" in the example below.
Note: We are using disk space recommendations from Canonical, to see all the disk space recommendations for the Ubuntu distribution from Canonical, please consult Ubuntu's documentation.
Select the FREE SPACE under the disk that has a partition table and select Create a new partition. From here, we are going to create our EFI (Extensible Firmware Interface) system partition using 250 MB. Select <Continue> to proceed. On the following page, select Beginning for the location of the new partition.
On the new page, name your partition EFI and select the Use as: option and change it to EFI System Partition. On the next page select Done setting up the partition.
Now let's set up the swap area partition. Select the FREE SPACE now located under the EFI partition and select Create a new partition.
Note: Swap space or swap area is used when RAM is completely utilized. Swap space should not be considered a replacement for more RAM as it is accessed from the hard disk and thus much slower.
We will make our swap area partition size greater than the amount of RAM on our server. Because this partition will be utilized on all of our drives we will be using 3 GB's (3 GB x 6 disks = 18 GB's), select <Continue> to proceed. On the following page select Beginning for the location of the new partition.
On the new page, name your partition SWAP and select the Use as: option and change it to swap area. On the next page select Done setting up the partition.
Select the FREE SPACE located under the swap partition. Select Create a new partition on the new page. On the following page, we will type in max to utilize the rest of the space on the disk for our root partition. Click <Continue> to proceed.
On the following page, name your partition root, "Use as:" Ext4 journaling file system and change the "Mount point:" to /. Once completed, select Done setting up the partition.
When configured correctly, your first disk should look like SCSI1.
Configuring Software RAID
Now that we have all of our disks ready for our RAID, let's configure it. Select Configure software RAID on the "Partition disks" page.
A new screen will pop up asking if you are sure you want to write changes to your storage devices and configure RAID. Select <YES> to continue. After the partitions are done formatting, select Create MD device.
The first RAID we are going to configure is RAID 1 for our swap space. Select the software RAID device type: RAID1.
Note: While it is not necessary to configure RAID 1 for swap space it's highly recommended for the read performance boost.
On the next page, type in the number of disks that will utilize this RAID and select <Continue>. In our example, we have six disks.
The next pop-up will ask if you have any spare devices for the array. For our setup, we will not have any spare devices. Type in 0 and select the <Continue> option.
On the next page, select every device labeled swap by pressing
Space for our RAID. After all of the partitions have been selected, select the <Continue> option to proceed.
We are now ready to set up our RAID for our root partitions.
Note: In our example, we will be using RAID 5. If you wish to use a different RAID option, simply substitute your RAID option wherever the article states RAID5.
Again, select Create MD device. On the next page, select RAID5 for our root partition. On the following page, type in the number of devices for your RAID and select <Continue>, in our example, we have six disks. The next pop-up will ask if you have any spare devices for the array. For our setup, we will not have any spare devices. Type in 0 and select the <Continue> option.
On the "RAID5 array" page, select all of the ext4 options. Once completed, select the <Continue>option to proceed.
We have completed setting up our RAID. Select the Finish option to get back to the "Overview" page.
Now that we have our RAID configured, we need to tell the device what to do with the partition. Let's start by selecting our swap space under the RAID1 device.
On the new page, highlight the Use as: do not use option and select it. Partition the disk as swap area.
On the next page, select Done setting up the partition. Now we are ready to select our RAID5 partition. Select the ext4 file system located under the RAID5 array.
On the new page select the Use as: do not use option. For "How to use this partition:" select Ext4 journaling file system. Change the "Mount point:" to / - the root file system. When complete, select Done setting up the partition.
Congratulations! You have successfully completed setting up your disks in a RAID format. Scroll down to the bottom of the page and select Finish partitioning and write changes to disk to finish installing Ubuntu 18.04.
Confirming RAID Configuration
Once logged into your server, type the following:
If you correctly configured your RAID in RAID 5 you should see a similar output. If you configured a different type of RAID make sure that your RAID type points to the mount point
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 7.3T 0 disk ├─sda1 8:1 0 237M 0 part /boot/efi ├─sda2 8:2 0 2.9G 0 part │ └─md0 9:0 0 2.9G 0 raid1 [SWAP] └─sda3 8:3 0 7.3T 0 part └─md1 9:1 0 36.4T 0 raid5 / sdb 8:16 0 7.3T 0 disk ├─sdb1 8:17 0 237M 0 part ├─sdb2 8:18 0 2.9G 0 part │ └─md0 9:0 0 2.9G 0 raid1 [SWAP] └─sdb3 8:19 0 7.3T 0 part └─md1 9:1 0 36.4T 0 raid5 / sdc 8:32 0 7.3T 0 disk ├─sdc1 8:33 0 237M 0 part ├─sdc2 8:34 0 2.9G 0 part │ └─md0 9:0 0 2.9G 0 raid1 [SWAP] └─sdc3 8:35 0 7.3T 0 part └─md1 9:1 0 36.4T 0 raid5 / ...
Having the right speed, redundancy, and disk availability for your business is essential for any big or small enterprise. Having read this article, you should now have a solid understanding of the differences between the different RAID levels and how to configure software RAID in Ubuntu 18.04.