OpenBSD RAID, Part 1

I figured since I have a little bit of time this morning being lost in a sea of parentheses, I might as well write up the first part in a two part series about my OpenBSD RAID box. If anything, just so I remember how to do it when I buuild my RAIDbox upgrade.

So lets start by describing the system:

  • OpenBSD 4.1
  • Transmetta 1.2 GHz Syntax Board
  • 512 MB of RAM
  • Maxtor 40 GB HD
  • Maxtor 160 GB HD
  • Two (2) Seagate 250 GB HDs
  • Cheap PCI -> IDE 2 Port controller

As you can see, nothing special. But the problem is the 40 GB and 160 GB drive are over 3 years old now. Which makes them a prime candidate for the MTBF gods to strike with a vengeance.

Although I would rather have hardware raid because it allows multiple OSes read your partition, I heard good things about OpenBSD’s (origionally from NetBSD) RAIDFrame.

In an effort to save time. I am going to make the assumption that you can install OpenBSD by yourself. This is a straight forward process that is detailed out in OpenBSD’s online guides. The great thing about OpenBSD is no rock is left unturned when it comes to documentation: be it in the code, on the web or in the man pages. I installed my operating system on the Maxtor 40GB drive.

The first thing that must be done with a new installation is to recompile the kernel to allow software raid. I am told it is not in the kernel because of a 500 KB increase in your kernel file. Which is undesirable if you don’t need RAID. So get the source:

# cd /usr

# export CVSROOT=anoncvs@anoncvs1.usa.openbsd.org:/cvs

# cvs -d$CVSROOT checkout -P src

This gets everything, and takes a bit. Once it is done you want to go into the src and make the appropriate changes.

# cd sys/arch/i386/conf

# vi GENERIC

uncomment this line to include RAID:

pseudo-device raid 4

Add this line underneath

option RAID_AUTOCONFIG

# config GENERIC

now compile

# cd ../compile/GENERIC

# make depend

# make

Backup your current kernel

# mv /bsd /bsd.old

Install your new kernel:

# mv bsd /bsd

reboot for the kernel to take effect

# reboot

That’s the hard part. Now after the reboot it’s time to set up the drives. Now my two drives were the 250 GB Seagates. Their mount point was at wd2 and wd3. So make corrections to your system if you are following this as a tutorial.

This makes sure the drives are the same

# disklabel wd2 > disklabel.wd3

# fdisk -i wd3

# disklabel -R -r wd3 disklabel.wd3

#vi /etc/raid0.conf

START array

# rows (must be 1), columns, spare disks

1 2 0

START disks

/dev/wd2a

/dev/wd3a

START layout

# sectPerSU SUsPerParityUnit SUsPerReconUnit RAID_level

128 1 1 1

START queue

# queue mode, outstanding request count

fifo 100

Now its time to set up the RAID disks using raidctl (8). The parity on my system took 6 hours, which I thought sucked. But it is straight forward.

# raidctl -C /etc/raid0.conf raid0
# raidctl -I 100 raid0

# raidctl -iv raid0

Once this is done you are ready to set up the disks. Since I wasn’t installing OpenBSD on the raid drive and I was only using it for storage I created one large partition. This is easy with disklabel (8) and construct the file system with newfs (8)

# disklabel -E raid0Initial label editor (enter ‘?’ for help at any prompt)

> a a

offset: [0]

size: [#########] (hit enter for full drive)

FS type: [4.2BSD]

# newfs /dev/raid0a

The last thing that needs to be done is to initialize RAID when openbsd starts up.

# raidctl -A root raid0
#vi /etc/fstab


### software raid

/dev/raid0a /pub_raid ffs rw,nodev,nosuid 1 2

NOTE: Do NOT enable soft updates for your RAID drive. If you disk ever crashes you will have no clue what was backed up and what wasn’t. Synchronous updates are the only ones you want.

Anytime you want to see if things are optimal run:

#raidctl -s raid0
raid0 Components:

/dev/wd2a: optimal

/dev/wd3a: optimal

No spares.

Parity status: clean

Reconstruction is 100% complete.

Parity Re-write is 100% complete.

Copyback is 100% complete.

That’s it! Move your data and enjoy have a little bit more data safety. Next time I will write about how to back up your laptops automatically and maybe touch on encrypted partitions.


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply

OpenID

Anonymous