OpenBSD Software RAID Administration: Installing OpenBSD
- Introduction
- Overview
- Installing OpenBSD
- Dealing with a Failed Component
- Upgrading OpenBSD
- Caveats
- References
Installing OpenBSD
Boot the OpenBSD install media and proceed to install on drive wd0.
Create the following disklabels:
- wd0a, type 4.2BSD, mount point /
- wd0e, type RAID, mount point none
The wd0a label is meant for booting the system and can be used as a sort of rescue disk in an emergency. Since the RAIDframe driver is built into the OpenBSD kernel, the kernel needs to be bootstrapped in order to bring up the RAID volume. Because of this, the kernel can't be located on the RAID volume itself; it must live on a non-RAIDed filesystem. That filesystem is located on wd0a (and later on we'll see also wd1a). This filesystem should be large enough to store and build the kernel sources; somewhere in the area of 1GB should suffice.
The wd0e label is the one that'll be used for the RAID volume. The type is set to RAID so that auto-configure can be enabled (and hence it can be booted from). Generally, the size of this label should occupy the remainder of the free space on the drive. This disklabel will contain the operating system, software packages, user data, etc, so at a minimum it must be large enough to hold all that data.
Install a minimal system onto wd0a by choosing only the bsd, baseXX.tgz, etcXX.tgz, and manXX.tgz disksets. These disksets will only be used to boot the system and for use during OS upgrades. The disksets for the "live" system will be installed later on.
Finish the install by choosing the appropriate values for your network devices, timezone, etc. The first boot filesystem is now ready. Reboot the system as instructed.
When the system comes up, login and create the RAIDframe config file, /etc/raid0.conf (note that the "0" here indicates the RAID set number, not the RAID level being used). For help with the file format, please refer to the raidctl(8) manpage.
It's now time to prepare the second physical drive and make it identical to the first drive. Create the OpenBSD partition using:
# fdisk -i wd1
Copy the disklabel from wd0 to wd1 and put a filesystem on wd1a:
# disklabel wd0 > /tmp/disklabel.wd0
# disklabel -Rr wd1 /tmp/disklabel.wd0
# newfs wd1a
Now copy the contents of the first boot filesystem to the second boot filesystem. When that's done, edit the fstab file on the second boot filesystem such that it points to wd1 and not wd0.
# mount /dev/wd1a /mnt
# cd /
# pax -r -w -pe -v .profile .cshrc altroot bin boot bsd etc home \
root sbin stand tmp usr var /mnt
# mkdir /mnt/dev /mnt/mnt
# cp /dev/MAKEDEV /mnt/dev
# cd /mnt/dev && ./MAKEDEV all
# vi /mnt/etc/fstab
Lastly, install the boot blocks onto wd1.
# cp /usr/mdec/boot /mnt/boot
# /usr/mdec/installboot -v /mnt/boot /usr/mdec/biosboot wd1
Now each physical drive is a replica of the other. Each has a filesystem that is bootable as well as a disklabel that will become a component of the RAID set.
It's now necessary to compile a kernel with RAIDframe support. As per the raid(4) manpage, the following options are needed in the kernel config file:
pseudo-device raid 4
option RAID_AUTOCONFIG
Add these two lines to the GENERIC kernel config file and build the kernel. Copy the new kernel to /bsd and to /mnt/bsd (wd1a should still be mounted under /mnt). Reboot the system with the new kernel. The RAID set can now be initialized and activated.
# raidctl -C /etc/raid0.conf raid0
# raidctl -I serial_num raid0
# raidctl -vi raid0
Now that the RAID set is active, it needs to have disklabels created on it and a filesystem laid down, just like a regular physical disk. At a minimum, the following disklabels should be created:
- raid0a, type 4.2BSD - This will contain the root filesystem and will be mounted as /.
- raid0b, type swap - This is the swap filesystem. It's important to remember that even the swap space must exist on a RAID set or you could be seriously compromising the availability of your system.
Further labels can be created for /usr, /tmp, etc, if desired.
# disklabel -E raid0
create labels as necessary
# newfs raid0a
newfs other labels as necessary
For this example we'll assume the following labels have been created:
- raid0a: /
- raid0b: swap
- raid0d: /usr
- raid0e: /home
- raid0f: /var
- raid0g: /tmp
The RAID set must now be populated. After first mounting all the filesystems within the RAID set, extract the wanted disksets onto the RAID set. Note that baseXX.tgz and etcXX.tgz are required.
# cd /
# mount /dev/raid0a mnt
# mkdir mnt/usr && mount /dev/raid0d mnt/usr
# mkdir mnt/home && mount /dev/raid0e mnt/home
# mkdir mnt/var && mount /dev/raid0f mnt/var
# mkdir mnt/tmp && mount /dev/raid0g mnt/tmp
# cp /bsd /mnt
# tar zxvpf baseXX.tgz -C /mnt
# tar zxvpf etcXX.tgz -C /mnt
... more disksets as necessary ...
Now tidy it up by copying the config files from the boot filesystem and creating all the devices. At this point it's also crucial to update /mnt/etc/fstab to reflect the disklabels that exist on raid0.
# cd /
# pax -r -w -pe -v etc /mnt
# cd /mnt/dev && ./MAKEDEV all
# vi /mnt/etc/fstab
The final step is to mark the RAID volume as being both auto-configurable and eligible to contain the root file system. This step will cause the kernel to load the root filesystem (i.e., /) from raid0a instead of wd0a. NOTE: From this point onwards the kernel will automatically configure the RAID set and mount raid0a as the root filesystem.
# raidctl -A root raid0
At this point the system can be rebooted. It should come up with all filesystems mounted on the raid0 device.
# mount
/dev/raid0a on / type ffs (local)
/dev/raid0d on /usr type ffs (local)
/dev/raid0e on /home type ffs (local)
/dev/raid0f on /var type ffs (local)
/dev/raid0g on /tmp type ffs (local)
Disclaimer
I make no guarantees about the accuracy or fitness of information within this article. The information within is accurate and true to the best of my knowledge. I will not be held responsible for data loss or system downtime.