By popular demand, Software RAID mirrors in OpenBSD, using RAIDframe.
For software RAID, OpenBSD has RAIDframe, softraid(4) (but only in 4.2) and ccd(4) (the concatenated disks driver - part of the GENERIC kernel, suppors a mirroring feature and a "striping" effect, but has limitations).
I should warn you that RAIDframe has quite a few problems. It doesn't seem to be properly maintained, code quality is down, it can be quite slow, the configuration process is a PITA and quite low level (as you can probably see), it makes upgrades a difficult and you'd get the same kind of downtime from a backup / restore process (dump/restore). Still, if you're up for it, read the raid(4) manpage, and give it a shot.
The new softraid(4) mirroring is simpler, but it's far from complete or tested as of OpenBSD 4.2.
Step 1. Installing OpenBSD:
The installation is pretty straight forward. You only need to pay attention to the disk labeling part. Create a 512M /, a small swap (128m is fine) and give the rest (a d) to RAID (type RAID in the FS type). Make sure you install compiling tools (comp).
Step 2. Install and boot a RAIDframe kernel
The problem is OpenBSD doesn't ship a RAIDframe enabled kernel by default (in GENERIC or otherwise). And you can't enabled it via config(8) either. So you'll have to build yourself a custom kernel and enable RAIDframe. Read 5.7 - Building a custom kernel of the FAQ for that. Once built, you can use that on all your machines, so it's a good idea to use GENERIC as a template for your RAIDframe kernel. Just uncomment the "pseudo-device raid" and "option RAID_AUTOCONFIG" lines and you're set.
You can use this as an excuse to move to OpenBSD-stable. See http://www.openbsd.org/stable.html - just copy GENERIC to GENERICRAID and edit / config that.
Also remember to turn on SoftUpdates (softdep in /etc/fstab), or it will take forever ;-).
Technically, you could do this on another machine. Once the kernel is built, you can use it to master your own media kits for use in future installations.
Step 3. Configure the mirror disk
You need to clone the disklabel from disk wd0 (or whatever your first disk is) and initialize the second disk (fdisk -i).
# disklabel wd0 > disklabel0
# fdisk -i wd1
# disklabel -R -r wd1 disklabel0
Step 4. Configure the RAID array:
See raidctl(8) and raid(4) for this step. Just setup your /etc/raid0.conf.
An example for a mirror:
# cat /etc/raid0.conf
START array
1 2 0
START disks
/dev/wd0d
/dev/wd1d
START layout
128 1 1 1
START queue
fifo 100
Step 5. Clone the disk
See http://unixsadm.blogspot.com/2007/08/cloning-disk-in-openbsd.html
Step 6. Enable the RAID
# raidctl -C /etc/raid0.conf raid0
# raidctl -I 100 raid0
# raidctl -iv raid0
Step 6. Disklabel and newfs the RAID disk:
# disklabel -E raid0
# newfs /dev/rraid0a
(Newfs created disklabels)
Step 7. Copy the installed OpenBSD on your RAID array:
You should use dump / restore for this process.
# mount /dev/raid0a /mnt
# cd /mnt
# mkdir usr
# mount /dev/raid0d /mnt/home
# dump -0f - / | restore -rf -
(make sure you create mount points and mount all the disk labels you've created).
Step 8. Activate the RAID config:
# raidctl -A root raid0
Remember to edit /etc/fstab to reflect these changes. You should have at least the / line similar to:
/dev/raid0a / ffs rw 1 1
Step 9. Reboot, enjoy, check status:
# raidctl -s raid0
Read the raidctl(8) manpage for details.
0 comments:
Post a Comment