Software RAID
The RAID software included with current versions of Linux (and Ubuntu) is based on the 'mdadm' driver and works very well, better even than many so-called 'hardware' RAID controllers. This section will guide you through installing Ubuntu Server Edition using two RAID1 partitions on two physical hard drives, one for / and another for swap.
Partitioning
- Select Manual as the partition method.
- 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.
- Select the "FREE SPACE" on the first drive then select "Create a new partition".
- 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.
- Select the "Use as:" line at the top. By default this is "Ext4 journaling file system", change that to "physical volume for RAID" then "Done setting up partition".
- For the / partition once again select "Free Space" on the first drive then "Create a new partition".
- Use the rest of the free space on the drive and choose Continue, then Primary.
- As with the swap partition, select the "Use as:" line at the top, changing it to "physical volume for RAID". Also select the "Bootable flag:" line to change the value to "on". Then choose "Done setting up partition".
- Repeat steps three through eight for the other disk and partitions.
RAID Configuration
- Back in the main "Partition Disks" page, select "Configure Software RAID" at the top.
- Select "yes" to write the changes to disk.
- Choose "Create MD device".
- For this example, select "RAID1", but if you are using a different setup choose the appropriate type (RAID0 RAID1 RAID5).
In order to use RAID5 you need at least three drives. Using RAID0 or RAID1 only two drives are required. - Enter the number of active devices "2", or the amount of hard drives you have, for the array. Then select "Continue".
- Next, enter the number of spare devices "0" by default, then choose "Continue".
- Choose which partitions to use. Generally they will be sda1, sdb1, sdc1, etc. The numbers will usually match and the different letters correspond to different hard drives.
For the swap partition choose sda1 and sdb1. Select "Continue" to go to the next step.
- Repeat steps three through seven for the / partition choosing sda2 and sdb2.
- Once done select "Finish".
Formatting
- Select "#1" under the "RAID1 device #0" partition.
- Choose "Use as:". Then select "swap area", then "Done setting up partition".
- Next, select "#1" under the "RAID1 device #1" partition.
- Choose "Use as:". Then select "Ext4 journaling file system".
- 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".
- Finally, select "Finish partitioning and write changes to disk".
The installation process will then continue normally.
Degraded RAID
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 process 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:
BOOT_DEGRADED=true
The configuration file can be overridden by using a Kernel argument. - Using a Kernel argument will allow the system to boot to a degraded array as well:
- When the server is booting press Shift to open the Grub menu.
- Press e to edit your kernel command options.
- Press the down arrow to highlight the kernel line.
- Add "bootdegraded=true" (without the quotes) to the end of the line.
- Press Ctrl+x to boot the system.
- When the server is booting press Shift to open the Grub menu.
RAID Maintenance
- To view the status of an array, from a terminal prompt enter:
sudo mdadm -D /dev/md0
The -D tells mdadm to display detailed information about the/dev/md0
device. Replace/dev/md0
with the appropriate RAID device.
- To view the status of a disk in an array:
sudo mdadm -E /dev/sda1
The output if very similar to the mdadm -D command, adjust/dev/sda1
for each disk.
- If a disk fails and needs to be removed from an array enter:
sudo mdadm --remove /dev/md0 /dev/sda1
Change/dev/md0
and/dev/sda1
to the appropriate RAID device and disk.
- Similarly, to add a new disk:
sudo mdadm --add /dev/md0 /dev/sda1
The
/proc/mdstat
file also contains useful information about the system's RAID devices: cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5]
[raid4] [raid10]
md0 : active raid1 sda1[0] sdb1[1]
10016384 blocks [2/2] [UU]
unused devices: <none>
watch -n1 cat /proc/mdstat
Press Ctrl+c to stop the watch command. If you do need to replace a faulty drive, after the drive has been replaced and synced, grub will need to be installed. To install grub on the new drive, enter the following:
sudo grub-install /dev/md0
Replace /dev/md0
with the appropriate array device name.sumber : help.ubuntu.com