Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!

Wednesday, September 15, 2010

Linux Software Raid 1 Setup


This article describes step by step setup of Linux software RAID 1 on Linux Platform. Although this software RAID 1 configuration has been accomplished on Debian ( Ubuntu ) it also can guide you if you are running some other Linux distributions such as RedHat, Fedora , Suse, PCLinux0S etc. For RAID-1 setup we need two or more disks. RAID1 mode creates a exact mirror of all data between two or more disks.

1.1. System Info

  • OS: Debian Etch ( basic installation on /dev/sda)
  • Kernel: Linux raid 2.6.18-5-686 #1 SMP Fri Jun 1 00:47:00 UTC 2007 i686 GNU/Linux
  • Hard Drives: /dev/sda -> 4GB , /dev/sdb -> 5GB

2. The Plan

We start with running linux system Debian Etch and the following partition scheme and hard drives ( sda , sdb ):
raid paritions scheme
raid 1 setup guide

3. Software Installation

There is only 1 package ( + prerequisites ) needed by software raid 1 on debian. This package is mdadm. Simply use apt-get tool to install mdadm package it into your system. You may be asked to answer couple question.

apt-get install mdadm 

4. Configure Kernel Modules

4.1. Load modules at boot time

No we need to make sure that raid kernel modules are loaded at the boot time. To accomplish this task we need to edit /etc/modules files and add couple lines. Open up your favorite text editor or just simply append lines with echo command.

echo raid1 >> /etc/modules echo md >> /etc/modules 

load raid kernel modules at boot time

4.2. Load modules to the Kernel

At this stage if we want to use raid modules we have two options. First one is to reboot our system and the other option is to use modprobe or insmode  to load modules to the Kernel. I find second option easier:

modprobe raid1 

load raid kernel modules
NOTE: if you do not have md module already loaded as shown on the figure above use modprobe to load it:

modprobe md 

There are two ways to confirm that our raid modules are loaded into kernel:

lsmod | grep raid1 
cat /proc/mdstat 

You should have similar output as shown on the figure below:
load raid kernel modules output from a command line
5. Prepare sdb for RAID
6. Setting Up RAID 1 Arrays
6.1. Create RAID 1 Arrays
6.2. Create a filesystem on RAID 1 Arrays
6.3. Edit mdadm.conf file
7. Edit /etc/fstab
8. Configure GRUB boot manager
9. Copy data from sda => sdb
10. Setup boot manager
11. Reboot
12. Add first hard drive ( sda ) to the RAID 1 array
12.1. Change Partition Id with sfdisk
12.2. Add partitions with mdadm to RAID 1 array
12.3. Edit /etc/mdadm/mdadm.conf
13. Finish

No comments: