Creating A RAID1 (Software RAID) Setup in Ubuntu Server 9.10

For many, creating a RAID setup may seem like an elusive task. Frankly, its not as I will show you.

Redundant Array of Independent Disks is a method whereby many hard drives are configured to act as one. There are two main types of setup in RAID:-

RAID0 is in favour of performance/speed while RAID1 is in favour of redundancy/reliability. Disks that are to be configured in RAID1 or RAID0 (which are supposed to be 2 in number) are supposed to be identical. There are other RAID setups that involve more hard disks but I won’t get into them here. In Brief, these are the ones i theoretically know of:-

* RAID0+1 – uses RAID0 and RAID1 at the same time with four identical hard disk drives. If one of the hard disk drive fails, the system becomes a RAID0 system.

* RAID10 – uses RAID0 and RAID1 at the same time also with four identical hard disk drives. If one of the hard disk drive fails, the system becomes a RAID1 system.

* RAID5 – this one is actually a RAID0 system that needs at least three identical hard disk drives. It stores parity information to improve the reliability of the disks. In a case whereby three drives are used, the total capacity will be double the size of each hard disk drive. e.g If I use three 750GB hard drives, my total hard disk space will be 1500GB since the rest of the space will be used to store this parity data.

Aaaaaaanayway….

In RAID0, when data is written to the hard disks, it is divided into several chunks whereby each chunk will be saved on a different drive. I won’t get into the intricacies of how RAID divides and distributes the data today. However, the main point is that if a 500KB file is stored and 250KB stored on each hard drive, it takes half the time to store each file since the hard disks are working in parallel therefore meaning MORE SPEED.

RAID1 on the other hand shows the two hard disks as one. By this i mean, like in my case, two 750GB hard drives set up in RAID1 will show as 750GB in your system. This is because, data that is sent to the 750GB RAID Volume is copied to both physical hard drives. This is why RAID1 is also known as mirroring. If one hard drive fails, all the data exists in the other hard drive..alas! REDUNDANCY and RELIABILITY in the flesh!I opted for data redundancy since i was setting up a server.

The next option that comes along the way is which method of RAID setup to use. RAID can either be setup as Hardware RAID or Software RAID. Hardware RAID can only work on machines whose motherboards have so called RAID Controllers. In this case, RAID is set up in the BIOS. The controller makes the OS think there’s only one drive and maintains the drives ‘invisibly’. I opted for Software RAID whereby no controller is needed. In this case, the OS knows about both drives and actively maintains both of them. The truth is, Linux software RAID is ideal for mirroring, and due to kernel disk caching and buffering it can actually be faster than RAID1 on lower end RAID hardware. However, for larger requirements like RAID 5, the CPU can still get bogged down with software RAID.

So… lets set up our two hard disks with Ubuntu Server 9.10 (Karmic Koala).

Follow the installation steps until you get to the Partition disks step, then:

  1. Select Manual as the partition method.
  2. Select the first hard drive, and agree to “Create a new empty partition table on this device?”.

    Repeat this step for each drive you wish to be part of the RAID array.

  3. Select the “FREE SPACE” on the first drive then select “Create a new partition”.
  4. Next, select the Size of the partition. This partition will be the swap partition, and a general rule for swap size is twice that of RAM. Enter the partition size, then choose Primary, then Beginning.
  5. Select the “Use as:” line at the top. By default this is “Ext3 journaling file system”, change that to “physical volume for RAID” then “Done setting up partition”.
  6. For the / partition once again select “Free Space” on the first drive then “Create a new partition”.
  7. Use the rest of the free space on the drive and choose Continue, then Primary.
  8. As with the swap partition, select the “Use as:” line at the top, changing it to “physical volume for RAID” then choose “Done setting up partition”.
  9. Repeat steps three through eight for the other disk and partitions.

There should now be a list of hard drives and RAID devices. The next step is to format and set the mount point for the RAID devices. Treat the RAID device as a local hard drive, format and mount accordingly.

  1. Select the RAID1 device #0 partition.
  2. Choose “Use as:”. Then select “swap area”, then “Done setting up partition”.
  3. Next, select the RAID1 device #1 partition.
  4. Choose “Use as:”. Then select “Ext3 journaling file system”.
  5. Then select the “Mount point” and choose “/ – the root file system”. Change any of the other options as appropriate, then select “Done setting up partition”.
  6. Finally, select “Finish partitioning and write changes to disk”.

If you choose to place the root partition on a RAID array, the installer will then ask if you would like to boot in a degraded state. At some point in the life of the computer a disk failure event may occur. When this happens, using Software RAID, the operating system will place the array into what is known as a degraded state. If the array has become degraded, due to the chance of data corruption, by default Ubuntu Server Edition will boot to initramfs after thirty seconds. Once the initramfs has booted there is a fifteen second prompt giving you the option to go ahead and boot the system, or attempt manual recover. Booting to the initramfs prompt may or may not be the desired behavior, especially if the machine is in a remote location. Booting to a degraded array can be configured several ways:

  • The dpkg-reconfigure utility can be used to configure the default behavior, and during the p rocess you will be queried about additional settings related to the array. Such as monitoring, email alerts, etc. To reconfigure mdadm enter the following:
    sudo dpkg-reconfigure mdadm
  • The dpkg-reconfigure mdadm process will change the /etc/initramfs-tools/conf.d/mdadm configuration file. The file has the advantage of being able to pre-configure the system’s behavior, and can also be manually edited by setting the ‘boot degraded’ option to true (BOOT_DEGRADED=true)

Finish the rest of the install and you’re good to go. For a more detailed and visual example, check out this guy’s detailed setup in Ubuntu Server 8.04. Not much has changed in the setup. CHEERS!

http://kuparinen.org/martti/comp/ubuntu/en/raid.html