Installing Ubuntu server with software RAID 1

1
Ubuntu RAID 1 - Step 18 finish partitioning and write changes
Ubuntu RAID 1 - Step 18 finish partitioning and write changes

This guide will show how one can use mdadm to install Ubuntu server on a RAID 1 setup. There are a few minor differences between doing this on 14.04 LTS and older versions that many guides are written for but the process is generally similar. The main reason to use RAID 1 is to provide a level of reliability in a system. With SSDs being both smaller and faster than the large 3.5″ capacities, RAID 1 with fast replacement or a hot spare can significantly decrease the chance of data loss. On the other hand, there are environmental factors (e.g. the now familiar backplane “zap of death”) that can take both drives out simultaneously. This guide will get you setup with md RAID 1 in less than 5 minutes. You do not need to use any special hardware RAID adapters with this guide, onboard SATA will work fine.

Installing Ubuntu server with software RAID 1

For this guide we are using two Samsung 830 256GB SSDs. We keep sets of SSDs available in the lab so these drives can be considered “well used” at this point. The first step is to insert installation media into the machine and boot the machine. One then needs to proceed through the customary installation steps such as selecting a keyboard layout. For this guide we are interested in the partitioning step.

Step 1 in the process is ensuring that your disks are listed. If not, troubleshoot why the disks are not available (e.g. loose cable.) The first step is generally to select the disk you want to partition. One can see that sda (the first disk) has a full 256GB of FREE SPACE. The second disk, sdb had a Windows installation previously. The HP 200GB SLC SAS SSD (sdd) will be a ZIL drive in the future and the four 4TB WD SAS drives are going to be storage disks. We are starting with sda in this example.

Ubuntu RAID 1 - Step 1 Select a Disk
Ubuntu RAID 1 – Step 1 Select a Disk

Select the disk you want to begin with and start partitioning.

Ubuntu RAID 1 - Step 2 Remove Existing Partitions
Ubuntu RAID 1 – Step 2 Remove Existing Partitions

You will now be left with FREE SPACE which we will format into something more usable. Select FREE SPACE and hit <Enter>.

Ubuntu RAID 1 - Step 3 FREE SPACE
Ubuntu RAID 1 – Step 3 FREE SPACE

If you know what you are doing, you can likely do manual partitions without issue. On the other hand, if you just want to get this done quickly, then you can select “Automatically partition the free space” and Ubuntu will automate that process.

Ubuntu RAID 1 - Step 4 Automatically Partition
Ubuntu RAID 1 – Step 4 Automatically Partition

Here we have a standard ext4 primary partition and a swap partition. At this phase you will want to select the primary partition.

Ubuntu RAID 1 - Step 5 Select the partition
Ubuntu RAID 1 – Step 5 Select the partition

Here, one will want to change the “Bootable flag” to on.

Ubuntu RAID 1 - Step 6 Bootable Flag set to on
Ubuntu RAID 1 – Step 6 Bootable Flag set to on

The next step is simply repeating steps 1-6 with the second drive. One can see here that the second disk has ntfs partitions from a previous Windows Server installation.

Ubuntu RAID 1 - Step 7 Repeat steps for second drive
Ubuntu RAID 1 – Step 7 Repeat steps for second drive

Now that both drive are ready, it is time to select Configure Software RAID.

Ubuntu RAID 1 - Step 8 Configure Software RAID
Ubuntu RAID 1 – Step 8 Configure Software RAID

You will be asked to partition disks at this point.

Ubuntu RAID 1 - Step 9 Confirm Partitions
Ubuntu RAID 1 – Step 9 Confirm Partitions

The next step is generally optional but may happen if you are using a drive that previously was tested with data. One may get a warning that there are GPT signatures on the disks. Make sure that you are OK losing the data on the drive, then tell Ubuntu that it is not a GPT partition table. That will allow Ubuntu’s partitioning to continue as close to a stock installation as possible.

Ubuntu RAID 1 - Step 9a GPT from previous installation
Ubuntu RAID 1 – Step 9a GPT from previous installation

Now click Create MD device. MD as the tool tip says stands for “multiple device” so this does say you are going to create “multiple device” device. MD is so commonly used many folks forget what the D stands for.

Ubuntu RAID 1 - Step 10 Create MD Device
Ubuntu RAID 1 – Step 10 Create MD Device

No click on RAID 1. Frankly for a boot drive this is going to be the most common option.

Ubuntu RAID 1 - Step 11 RAID1
Ubuntu RAID 1 – Step 11 RAID1

Next you will need to select the number of devices. Here we have two.

Ubuntu RAID 1 - Step 12 Select Number of Devices
Ubuntu RAID 1 – Step 12 Select Number of Devices

Since we only had two drives in our array and need two for RAID 1 we do not have any spare devices. Spares are nice to haves. In the event a disk fails, the spare would be used to immediately rebuild. That is a huge benefit with SSDs that can handle the higher IOPS and faster transfers as it means healing times are very fast.

Ubuntu RAID 1 - Step 13 Select Number of spare devices
Ubuntu RAID 1 – Step 13 Select Number of spare devices

Next you will need to select the partitions you want to be root and swap. You choose them in pairs. On most drives, these are going to be different sizes so it should be fairly easy t figure out /sda1 goes with /sdb1 and they are the same size.

Ubuntu RAID 1 - Step 14 Select active partitions
Ubuntu RAID 1 – Step 14 Select active partitions

Write changes here.

Ubuntu RAID 1 - Step 15 repeat for swap
Ubuntu RAID 1 – Step 15 repeat for swap

Once this is completed for both the / and swap device you can see the pairs listed as RAID device #0 and #1 below. In this example, SCSI1 and SCSI2 are the physical Samsung 830 256GB drives.

Ubuntu RAID 1 - Step 15a ext4 and swap changes
Ubuntu RAID 1 – Step 15a ext4 and swap changes

With the RAID 1 swap partition setup, we are ready to go.

Ubuntu RAID 1 - Step 15b root and swap changes
Ubuntu RAID 1 – Step 15b root and swap changes

Click finish.

Ubuntu RAID 1 - Step 16 finish
Ubuntu RAID 1 – Step 16 finish

Write changes to disk.

Ubuntu RAID 1 - Step 17 write changes
Ubuntu RAID 1 – Step 17 write changes

Time to write again. Here click “Finish partitioning and write changes to disk.”

Ubuntu RAID 1 - Step 18 finish partitioning and write changes
Ubuntu RAID 1 – Step 18 finish partitioning and write changes

Now that partitioning is done, one can proceed through the rest of the installer as normal.

When you reboot, you can check your disks free space and see the md partition.

Finished Ubuntu install on RAID 1 volume
Finished Ubuntu install on md volume

Hopefully this was an easy enough guide to follow. The total time should take under 5 minutes. For further administration, there are plenty of guides out there on mdadm and use with Ubuntu. Feel free to let us know if there are any questions in the forums.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.