Arch Linux software raid installation guide

OS Used: Arch Linux
First written: June 2008
Last updated: June 2008

This guide starts once the live CD has been booted and you've got a shell prompt.

Set keyboard layout:

[root@archlive ~]# loadkeys uk

 

Load the raid modules

[root@archlive ~]# modprobe raid0
[root@archlive ~]# modprobe raid1
[root@archlive ~]# modprobe raid5

 

partition /dev/sda

[root@archlive ~]# cfdisk /dev/sda
cfdisk (util-linux-ng 2.13.0.1)

                                                 Disk Drive: /dev/sda
                                          Size: 203928109056 bytes, 203.9 GB
                                Heads: 255   Sectors per Track: 63   Cylinders: 24792

      Name             Flags        Part Type      FS Type                    [Label]           Size (MB)
------------------------------------------------------------------------------------------------------------------------
      sda1             Boot         Primary        Linux raid autodetect                        222.09
      sda2                          Primary        Linux raid autodetect                        2048.10
      sda3                          Primary        Linux raid autodetect                        20003.89
      sda4                          Primary        Linux raid autodetect                        181647.09

partition /dev/sdb

[root@archlive ~]# cfdisk /dev/sdb
cfdisk (util-linux-ng 2.13.0.1)

                                                 Disk Drive: /dev/sdb
                                          Size: 203928109056 bytes, 203.9 GB
                                Heads: 255   Sectors per Track: 63   Cylinders: 24792

      Name             Flags        Part Type      FS Type                    [Label]           Size (MB)
------------------------------------------------------------------------------------------------------------------------
      sdb1             Boot         Primary        Linux raid autodetect                        222.09
      sdb2                          Primary        Linux raid autodetect                        2048.10
      sdb3                          Primary        Linux raid autodetect                        20003.89
      sdb4                          Primary        Linux raid autodetect                        181647.09

 

Create the RAID arrays.
(/boot must be RAID1)

[root@archlive ~]# mdadm --create --verbose /dev/md1 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
[root@archlive ~]# mdadm --create --verbose /dev/md2 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
[root@archlive ~]# mdadm --create --verbose /dev/md3 --level=0 --raid-devices=2 /dev/sda3 /dev/sdb3
[root@archlive ~]# mdadm --create --verbose /dev/md4 --level=0 --raid-devices=2 /dev/sda4 /dev/sdb4

 

Format the newly created RAID drives

[root@archlive ~]# mkfs.ext2 /dev/md1
[root@archlive ~]# mkfs.ext3 /dev/md3
[root@archlive ~]# mkreiserfs /dev/md4
[root@archlive ~]# mkswap /dev/md2
[root@archlive ~]# swapon /dev/md2

 

Mount your raid drives for installation

[root@archlive ~]# mount /dev/md3 /mnt
[root@archlive ~]# cd /mnt
[root@archlive mnt]# mkdir home
[root@archlive mnt]# mkdir boot
[root@archlive mnt]# mount /dev/md1 /mnt/boot
[root@archlive mnt]# mount /dev/md4 /mnt/home

 

Continue the setup from the menu.
Skip the disk partitioning and mounting etc. and see below for bootloader.

[root@archlive mnt]# /arch/setup

 

Skip the last step (Installing the bootloader) as we need to do this manually because of our raid arrays.
(Side note: When within the grub shell, "root" refers to the /boot partition. If you do not have a seperate boot partition, then the / partition.)

[root@archlive ~]# grub

We need to install grub to both drives seperately.

Install to sda

grub> device (hd0) /dev/sda
grub> root (hd0,0)
grub> setup (hd0)

Install to sdb

grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> setup (hd0)

 

The last step is to edit grub's menu.lst file to ensure the system is bootable.

# (0) Arch Linux
title  Arch Linux
root    (hd0,0)
kernel /vmlinuz26 root=/dev/md3 ro md=1,/dev/sdb1,/dev/sdc1 md=3,/dev/sdb3,/dev/sdc3 md=4,/dev/sdb4,/dev/sdc4 md=2,/dev/sdb2,/dev/sdc2
initrd /kernel26.img

 

Should your system not boot and you need to boot off the CD again to fix grub, you can easily jump to the last step of the install process by reassembling you raid arrays and then mounting them.

[root@archlive ~]# loadkeys uk
[root@archlive ~]# 
[root@archlive ~]# modprobe raid0
[root@archlive ~]# modprobe raid1
[root@archlive ~]# modprobe raid5
[root@archlive ~]# 
[root@archlive ~]# mdadm --assemble /dev/md1 /dev/sda1 /dev/sdc1
[root@archlive ~]# mdadm --assemble /dev/md2 /dev/sda2 /dev/sdc2
[root@archlive ~]# mdadm --assemble /dev/md3 /dev/sda3 /dev/sdc3
[root@archlive ~]# mdadm --assemble /dev/md4 /dev/sda4 /dev/sdc4
[root@archlive ~]# 
[root@archlive ~]# mount /dev/md3 /mnt
[root@archlive ~]# mount /dev/md1 /mnt/boot
[root@archlive ~]# mount /dev/md4 /mnt/home
[root@archlive ~]#