Repository 32bit  Forum
Repository 64bit  Wiki

How to build a SATA Raid Software using Slackware Linux

Da Slacky.eu.


Indice

Introduction

date: 24/12/2005 - Xmas present for the OpenSource Community By Lorenzo Allori <lallori AT medici DOT org> released under GNU Free Documentation License gnu.org.

After surfing the internet trying to find a good software raid how-to with no success, I decided to write my own. Slackware linux does not support a GUI to create a raid software on first installation but you can manage easily. In fact, default install kernels (bare.i, sata.i) are raid software enabled.

This document is intended for building a software RAID 1 using /dev/md with sata hard drives. You can use it for IDE drives too, you only need to use /dev/hdx instead of /dev/sdx. You can use this document to build RAID 0 or RAID 5 but refer to another manual on how to write /etc/raidtab cause it will be different from the one we are using here, but all the procedure is quite similar..

What you need before starting

  • time needed: 30 minutes (first time), 10 minutes (when you know what you are doing)
  • two identical SATA drives
  • at least Slackware Linux 8.1 - Kernel 2.4 CD (tested on Slackware 10.2)

Partitioning

WARNING: If you have a common software raid included in your motherboard disable it (it seems to be an hardware raid controller but it is not).

Boot your system from the CD using sata.i kernel and choose your keyboard. Launch cfdisk /dev/sda and partition the disk as you want. Your disk will be seen as scsi discs and named /dev/sda and /dev/sdb.

cfdisk 2.12p
Disk Drive: /dev/sda
Size: 163928604672 bytes, 163.9 GB
Heads: 255 Sectors per Track: 63 Cylinders: 19929
Name Flags Part Type FS Type [Label] Size (MB)
------------------------------------------------------------------------------
sda1 Primary Linux raid autodetect 1998.75
sda2 Primary Linux raid autodetect 20003.89
sda3 Primary Linux raid autodetect 100002.96
sda4 Primary Linux raid autodetect 41907.81
Unusable 8.23

Remember that to set the FS Type to Linux raid autodetect your have to select type FD (under the TYPE section).

Do the same thing for /dev/sdb (the partitioning must be the same).

cfdisk 2.12p
Disk Drive: /dev/sdb
Size: 163928604672 bytes, 163.9 GB
Heads: 255 Sectors per Track: 63 Cylinders: 19929
Name Flags Part Type FS Type [Label] Size (MB)
------------------------------------------------------------------------------
sdb1 Primary Linux raid autodetect 1998.75
sdb2 Primary Linux raid autodetect 20003.89
sdb3 Primary Linux raid autodetect 100002.96
sdb4 Primary Linux raid autodetect 41907.81
Unusable 8.23

/etc/raidtab and creating RAID 1.

To create the raid array for you need to create the file /etc/raidtab

#vi /etc/raidtab

put into the file

raiddev /dev/md0
raid-level 1
nr-raid-disks 2
nr-spare-disks 0
persistent-superblock 1
device /dev/sda1
raid-disk 0
device /dev/sdb1
raid-disk 1
chunk-size 32

save and exit the file

HINT: persistent-superblock set to 1 is an option that allows mkraid to write a superblock that contains the raid software information even if you do not have an /etc/raidtab file on your hard drive and allows you to reboot the machine and install slackware later even if you format all the partitions (but if you delete them with fdisk or such a program).

Create the RAID 1 array for the swap partition

Assuming that you are using /dev/md0 as your swap partion we are now creating the mirror for /dev/sda1 and /dev/sdb1.

#mkraid /dev/md0

it should not give you errors, if it does control your /etc/raidtab something could be missing.

#mkswap /dev/md0

#swapon -a

WARNING: The slackware setup program will not allow you to use this partition as a swap partion. You should install Slackware saying you are installing it without one and then after booting the system the first time you should edit /etc/fstab inserting a line like this a the top of the file:

/dev/md0 swap swap defaults 0 0

each term must be spaced with tab so /dev/md0 ---->TAB swap --->TAB etc.

Create the RAID 1 array for the / partition

Assuming that you are using /dev/md1 as your / partion are now creating the mirror for /dev/sda2 and /dev/sdb2.

#vi /etc/raidtab

change the file created before into:

raiddev /dev/md1
raid-level 1
nr-raid-disks 2
nr-spare-disks 0
persistent-superblock 1
device /dev/sda2
raid-disk 0
device /dev/sdb2
raid-disk 1
chunk-size 32

Then create the array:

#mkraid /dev/md1

it should not give you errors, if it does control your /etc/raidtab something could be missing.

KEEP IN MIND YOUR ROOT PARTITION IS /dev/md1 (or what you are using).

Create the RAID 1 array for the home partition

Assuming that you are using /dev/md2 as your /home partion are now creating the mirror for /dev/sda3 and /dev/sdb3.

#vi /etc/raidtab

change the file created before into:

raiddev /dev/md2
raid-level 1
nr-raid-disks 2
nr-spare-disks 0
persistent-superblock 1
device /dev/sda3
raid-disk 0
device /dev/sdb3
raid-disk 1
chunk-size 32

Then create the array:

#mkraid /dev/md2

it should not give you errors, if it does control your /etc/raidtab something could be missing.

Create the RAID 1 array for the var partition

Assuming that you are using /dev/md3 as your /var partion are now creating the mirror for /dev/sda4 and /dev/sdb4.

#vi /etc/raidtab

change the file created before into:

raiddev /dev/md3
raid-level 1
nr-raid-disks 2
nr-spare-disks 0
persistent-superblock 1
device /dev/sda4
raid-disk 0
device /dev/sdb4
raid-disk 1
chunk-size 32

Then create the array:

#mkraid /dev/md3

it should not give you errors, if it does control your /etc/raidtab something could be missing.

Finishing and rebooting the system

Now just take a look to your RAID setup:

#cat /proc/mdstat


Personalities : [linear] [raid0] [raid1] [raid5]
read_ahead 1024 sectors
md0 : active raid1 sdb1[1] sda1[0]
1951744 blocks [2/2] [UU]

md1 : active raid1 sdb2[1] sda2[0]
19534976 blocks [2/2] [UU]
resync=DELAYED
md2 : active raid1 sdb3[1] sda3[0]
97659008 blocks [2/2] [UU]
[==============>......] resync = 70.0% (68438144/97659008) finish=10.2min speed=47649K/sec
md3 : active raid1 sdb4[1] sda4[0]
40925504 blocks [2/2] [UU]

You must be having a similar thing.

Wait all the partitions to finish resyncing and reboot the server.

Hints

Start your setup and remember to aswer yes when is says that you do not have a swap partition. You will setup it later as eplained here.

Remember that when you will have to choose the / partition do not pick up /dev/md0 but /dev/md1.

Remember to choose the sata.i kernel when you are asked which kernel to install.

Strumenti personali
Namespace

Varianti