How to install openSUSE on software RAID

From openSUSE

Contents

This article explains how to install openSUSE 10.3 with software RAID. Advantages to Software RAID is that it is a flexible (You only need a spare hard disk) and cheap way to add fault tolerance and redundancy to your SUSE installation. The disadvantage is that it is rather processor intensive unlike hardware RAID. The upside is that you can use different sized disks and even mix and match SCSI, IDE and SATA disks!


If you want to install the kind of RAID that is supported by some motherboards, just enable RAID in your BIOS and install as usual.
NOTE: BIOS-RAID is only supported by openSUSE 10.2 or later. Earlier versions of SUSE DO NOT support BIOS-RAID.


RAID 0, RAID 1 or RAID 5?

With RAID 0 total space of your RAID will be equal to all your hard disks combined. But you have no redundancy! If just one Disk fails all data is forever lost... Adding more disks will only increase storage space and make your system able to write to disk faster. If speed is your motivation to use RAID you will probably be better off with Hardware RAID or even BIOS-RAID. RAID 0 requires a minimum of 2 physical hard disks.

With RAID 1 total space of your RAID will be equal to the smallest hard disk. Adding more disks will increase chances against data loss, but it will not increase your storage space. RAID 1 requires a minimum of 2 physical hard disks.

With RAID 5 total space of your RAID will be equal to all your hard disks combined minus one. Adding more disks will increase storage space. But if two disks fails, at the same time, all data is lost. RAID 5 requires a minimum of 3 physical hard disks.

In this howto we will look at how to setup RAID 1 with two 200GB hard disks.

Make sure that you have the physical disks connected to different controllers.
In layman's terms this means that each disk must be on it's own cable or connector. If disks share one cable, both disk can easily be rendered useless even if just one of them stops working.

Installation Summary

Start the regular install procedure, but when SUSE suggest a partitioning scheme, stop and choose partitioning. Choose "Make self defined setup", and "Self defined setup (for advanced users)" again.

In this example we will use the following partition scheme:

  • /boot 100 MB
  • /swap 1GB
  • / 10 GB
  • /home (the rest of the hard disk)

Created the partitions on both hard disks (hda + hdb) as above (sizes optimized for two 200 GB disks). Chose "Create Custom Partition Setup". The following window will show you a blank partition setup(provided that you are installing on new hardware. If not just delete whatever is there. (Note: this will destroy all data on your hard disk)

Press the button "Create", choose "primary", but instead of ext3 as file system choose 0xFD Linux RAID, from the drop down list, for all 8 partitions (2 * 4.). That is for 4 partitions on each disk).

After you have created these partitions with identical sizes on both drives, press the button called RAID. Select which setup of RAID you want. You can choose between RAID 0 , 1 and 5.

  • For /swap we chose RAID 1
  • For /boot we have to choose RAID 1(only allows RAID 1)
  • For / we chose Raid 1 (or 0 depending on whether you want speed and more disk space or stability)
  • For /home we chose RAID 1 (or 0 depending on whether you want speed and more disk space or stability)

If in doubt just read the information in the sidebar in YAST as you install.

Important! If you choose RAID 0 for either / (root partition) or /swap you will discover that if one of the disks fails you won't be able to boot your system. And you will be forced to replace the failed disk and partition it like the failed disk. If on the other hand you choose RAID 1 for everything you will be able to boot as long as one disk is still alive.


After this you can install SUSE as you usually do.

Detailed Installation walk through

Image:RaidYast2-000.jpg

Start the installation as usual


Image:RaidYast2-001.jpg

Choose language Summary


Image:RaidYast2-002.jpg

Choose desktop environment


Image:RaidYast2-003.jpg

Click on the dropdown-button in the middle, on the lower part of the screen called "Change...". Choose "partitioning"


Image:RaidYast2-004.jpg

Choose "Create custom partition setup"


Image:RaidYast2-006.jpg

Choose "Custum Partitioning (For experts)"


Image:RaidYast2-007.jpg

Here you can see one of the two 200 GB disk already formatted with linux RAID. Now let's look at how we partition the other disk and setup the RAID.

To continue click the "Create button".


Image:RaidYast2-008.jpg

Choose hard disk you want to partition


Image:RaidYast2-009.jpg

Choose "Primary Partition"


Image:RaidYast2-010.jpg

You will get a window that looks like this.


Image:RaidYast2-012.jpg

Change it to look like this.

In this example we will use the following partition scheme:

   * One with 100 MB (for /boot)
   * One with 1GB (for /swap)
   * One with 10 GB (for / )
   * One with the rest of the hard disk (for /home)

To get the correct amount assigned use the following syntax: +XXXYY where XXX is the numeric value and YY is the denomination(MB or GB) E.G: +100MB for /boot, +1GB for /swap and so on.


Image:RaidYast2-013.jpg

Your result should look something like this.

Make a raid device by clicking the "RAID..." button.


Image:RaidYast2-014.jpg

Choose RAID 1


Image:RaidYast2-015.jpg

Add the two disks that are to belong to this RAID device, by clicking on them in the list and then clicking the "Add" button.


Image:RaidYast2-017.jpg

Choose swap filesystem for swap and ext3 for the others.


Image:RaidYast2-018.jpg

You should now have set up your first RAID Device. Repeat until you have made all the RAID devices you need (4 in total if you are following this example)


Image:RaidYast2-025.jpg

In the end your partition setup should look like this. Now you can continue with your installation as usual by clicking accept.

Monitoring your RAID

The easiest way to monitor your RAID after it is set up is to install RAID-Monitor! RAID-Monitor is a tray application that will notify you of any errors on your RAID. It is a GUI frontend to mdadm. You can see how to install Raid Monitor at this site: http://raid-monitor.mihosoft.eu You need to install Qt and cmake before you install RAID-Monitor.

You can also choose to use the mdadm program directly through the command line. And even make it email you a notice of any errors in your RAID. The simplest way of using mdadm is to write "cat /proc/mdstat" in a console.

You will then get a message looking something like this:

     Personalities : [raid1] [raid0] [raid5] [raid4] [linear]
     md0 : active raid1 hdb2[0] hdd2[1]
     194306048 blocks [2/2] [UU]
     unused devices: <none>

If a disk has failed it will be marked by an (F) after the drive volume in the second line of output. In addition, after the number of blocks you can read how many of the total disks in the array are working e.g.: [1/2]

A failed disk could look something like this:

     Personalities : [raid1] [raid0] [raid5] [raid4] [linear]
     md0 : active raid1 hdb2[0] hdd2[1](F)
     194306048 blocks [1/2] [UU]
     unused devices: <none>
Note that both the letter F and the fact that it says [1/2] or [2/1] shows that there is something wrong with your RAID! - And that action should be taken to prevent data loss!

You can let SUSE monitor your disks by enabling the SMART Disk Monitoring Daemon (smartd) Status notification is given through "powesavenotify". Start YAST runlevel editor and check the smartd service. (YAST - System - System services runlevel) How this works or even if it works is unknown to me.

Reconstruction

If a device fails and you want to replace it do the following:

Reconstructing in this manner will not work for RAID 0. If you have set up RAID 0 you'll have to boot from the install DVD and use it to partition your new disk. And then reinstall your RAID without overwriting your /home RAID partition. But of course if you have installed your /home partition on a RAID 0 you would by now have lost everything... :-(
   - Power down the system
   - Replace the failed disk (remembering to check that the new disk is as big as the one it is replacing.)
   - Boot as usual and start YAST. Go to system and partitioning.
   - Partition new disk as old
   - If you have used the DVD to partition your drive you must first power down the system and start it again.
   - From the command line switch to root
   - - Write su, press enter and then write your password (for security reasons you won't see anything while typing your password), and then press enter again
   - Run this command: mdadm /dev/mdX --add /dev/sdXX. 
   - - Replace 'X' with the RAID device that the partition belongs to and replace XX with the partition identifier.

Here is a real life example of what a reconstruction looks like:

raidbox-multi:/home/yourusername # mdadm /dev/md0 --add /dev/sda1
mdadm: re-added /dev/sda1

raidbox-multi:/home/yourusername # mdadm /dev/md1 --add /dev/sda2
mdadm: re-added /dev/sda2

raidbox-multi:/home/yourusername # mdadm /dev/md2 --add /dev/sda3
mdadm: re-added /dev/sda3

raidbox-multi:/home/yourusername # mdadm /dev/md3 --add /dev/sda4
mdadm: re-added /dev/sda4
   - - This integrates the partition automatically into the RAID device and it will start to reconstruct it.
   - - Repeat for each RAID device (Eg: for md0, md1,md2 and md3 As seen in the example above.)
   - Type "exit" and then hit the enter-key to exit ROOT mode in the terminal
   - Type "cat /proc/mdstat". To see how far the automatic reconstruction has progressed. 

You can continue working while reconstruction progresses.

SuseWiki Alternative Drive Rebuild Instructions

Backup

Remember, RAID is no substitute for good backups. No amount of redundancy in your RAID configuration is going to let you recover week or month old data, nor will a RAID survive fires, earthquakes, or other disasters.

It is imperative that you protect your data, not just with RAID, but with regular good backups. One excellent system for such backups, is the Amanda backup system.


Maintenance

It is recommended to run a check/repair disk once a week to find and/or repair any sector errors any drive in the array may have. This will help to eliminate issues when a rebuild is needed. Install add on Kadmin for an easy to use event management utility,

The following will check the disk for errors. It will report any errors found.

     echo check >/sys/block/mdX/md/sync_action

Where X = the RAID device you want to check. Now you won't be able to check the md0(or whichever device is your swap)

The following will check and repair any errors on the disk.

     echo repair >/sys/block/mdX/md/sync_action

Where X = the RAID device you want to check. Now you won't be able to check the md0(or whichever device is your swap)

To make it easier for yourself you can set up a cronjob to automate the job of checking the RAID. See under links to learn how you use Cron.

Internal links

Packaging/SUSE Package Conventions/Cron Jobs


External Links

http://raid-monitor.mihosoft.eu A tray applet that monitors your RAID

The definitive guide to Software RAID on linux

Additional Crontab Info on the Novel Website

linuxmafia Chapter 8 Automating tasks: the system never sleeps

Raid to do list

Amanda Backup software