JSP - Johnson's Server Project
FIREWALL - Add a Raid Drive


GOAL I want 2 disks in a mirror (RAID level 1)

Initially, one of the disks had some bad sectors. I had to create 2 RAID 1 arrays (on either side of the bad sectors), then combine these into one RAID 0 array

Since then, I replaced that drive and redid the array into a single RAID 1 array
Re-installing OpenBSDIf you are re-installing OpenBSD, all that is needed is:
Rebuild the Kernel for Raid support (described below)
Reboot - during the boot process you will see:
raid0 : pairty status : DIRTY
raid0 : Initiating re-write of parity
i.e. the raid drive has been successfully rebuilt with it's original data
mkdir /pub (create the directories(s) originally mapped to by the RAID array)
edit fstab to automatically mount the raid drive (described below)
reboot
At this point, the files originally on the raid disks are available for use
Support for RAID is not found in OpenBSD GENERIC, so it must be compiled into your kernel. First copy the Kernel Source into /usr/src :
# cd /
# mkdir cdrom
# mount_cd9660 /dev/cd0c /cdrom
# cd /usr/src
# tar -xzpvf /cdrom/src.tar.gz
# tar -xzpvf /cdrom/sys.tar.gz (This is needed if you did not purchase the CD from OPENBSD - On their CD, the src.tar.gz includes sys.tar.gz)
Then modify the installation parameters :
# cd /sys/arch/i386/conf    (/sys is a symbolic link to /usr/src/sys/ )
# cp GENERIC MYINSTALL
# vi MYINSTALL
uncomment the line
pseudo-device   raid    4   # RAIDframe disk device ( specifies the number of RAIDframe drivers to configure)
also add
option RAID_AUTOCONFIG (turns on component auto-detection of RAID sets)
option RAIDDEBUG (sends debug info to the console)

You may want to add the ppp modem support at this time (modem support)

save it (:w :q)
# config MYINSTALL
# cd ../compile/MYINSTALL
# make

Now save the original kernel and overwrite with your new kernel
# cp /bsd /bsd.old
# cp /sys/arch/i386/compile/MYINSTALL/bsd   /bsd
Reboot and you will have a kernel with RAID
Do a surface scan of the disks to be used. Note that in OpenBSD a bad sector is a bad sector. The Seagate site contains a nice piece of surface test software (it creates 2 boot floppies and is thereby operating system independent). Run this program, print out the test report and note any bad sectors
for each drive,
fdisk and disklabel
fdisk -i wd1
disklabel -E wd1 (don't set the cylinder parameters directly, use a size and let disklabel calculate the proper cylinder)
In this case I ended up with:
c 312581808 0 unused 0-310100
d 144913041 63 RAID 0*-143762
e 73400544 144913104 bad 143763-216580
f 94263057 218313648 RAID 216581-310095*

Actually this was too much lost disk space so I purchased a replacement that was free of bad sectors.
c 312581808 0 unused 0-310100
d 312576642 63 RAID 0*-310095*
  Repeat this for wd2 making sure that the disklabel is identical
Originally there would have been 2 RAID 1 arrays and 1 RAID 0 array merging the 2 RAID 1 arrays, we would have needed to build 3 RAID configuration files.

Instead we will build one file :
/root/raid0.conf
START array
# numRow numCol numSpare
1 2 0

START disks
/dev/wd1d
/dev/wd2d

START layout
# sectPerSU SUsPerParityUnit SUsPerReconUnit RAID_level_1
128 1 1 1

START queue
fifo 100
Configure and Initialize this # raidctl -C raid0.conf raid0 (use -C only for initial configurations)
Initialize the component label
# raidctl -I 112341 raid0 (112341 is the serial number for the raid set)
Initialize the RAID set
# raidctl -iv raid0 (i to initialize, v provides a running progress update)
Crate a disklabel for the RAID set: # disklabel -E raid0
add label d as a BSD partition
c 312576512 0 unused 0-305250*
d 312575872 128 4.2BSD 0*-305249
Create the file system: # newfs /dev/rraid0d
To test, mount the file system:
copy something to it
then unmount it and see that copied file doesn't appear
#cd /
#mkdir pub
# mount /dev/raid0d /pub
#cp /etc/fstab /pub/
#ls /pub
#umount /pub
#ls /pub
To manually regain the RAID array after reboot Use: # raidctl -c raid0.conf raid0 to re-configure the RAID set the next time it is needed
Setup to automatically configure the RAID array on reboot #raidctl -A yes raid0
(If this is after a reboot, you will need to enter
#raidctl -c raid0.conf raid0 )
Setup to automatically mount the RAID array on reboot edit fstab
add the line
/dev/raid0d /pub ffs rw 1 1
Reboot,
then make the drive sharable
cd /
chmod 4777 /pub
To check status of the array #raidctl -s raid0
This will list the status of each drive in the array and the parity status
To recover a failed drive after it has been replaced assuming the failed drive was /dev/wd2d
#raidctl -R /dev/wd2d raid0
If the root drive is rebuilt Recompile the Kernel as described above
After reboot you should see:
raid0 : parity staus = DIRTY
raid0 : Initiating re-write of parity

This rewrite will take a long time and the server will NOT be available until it completes