Odd Red Dog

Setting up OpenBSD 5 with /home on two disparate RAID1 drives

21 April 2014

For a cheap basement computer experiment, I had 3 hard drives of different sizes/brands and I wanted to try out OpenBSD with the following disk setup:

  • /dev/sd0 and /dev/sd1
    • 1 Tb and 500 Gb, respectively. I wanted those to be used in a RAID1 for /home.
  • /dev/sd2
    • 250 Gb disk to host the OS

There are already a few good articles on how you can install the whole OpenBSD OS onto a RAID array. One of them can be found over at Olivier's Blog.

In my case, I only wanted the /home partition to be on the array and, moreover, I wanted to do RAID1 with two drives of different sizes. Go Figure...

Booting the OS install media

  • Boot from the install media
  • At the first prompt asking to (I)nstall, (U)pgrade or (S)hell, choose S and drop to a shell.

At this point, you'll need to manually create the RAID array and put a partition on it so that the installer can then use it later.

Creating the partitions

Start by running MAKEDEV so that sd1 is usable

# cd /dev
# sh MAKEDEV sd1

Then initialize the partitions, on both drives

# fdisk -iy sd0
# fdisk -iy sd1

Now create the new partitions. I started from the smallest drive so that I could exactly replicate its size onto the bigger drive.

# disklabel -E sd1
  • First enter a a. This will add a new partition called a on the drive.
  • Answer the default values for offset and size.
  • Note down the value for size since we'll be needing it later.
  • The last prompt is asking for the file system type (FS type). Do not use the default, instead type raid.
  • Once this is done, you can quit and save the partition by typing q.

Now a matching partition has to be created on the other, bigger, drive, sd0:

# disklabel -E sd0

Follow the same instructions as for sd1, but rather than using the default size enter the exact value that was returned for the smaller drive.

Creating the softraid partition

This will create the raid1 partition.

# bioctl -c 1 -l sd0a,sd1a softraid0

The new raid1 device, on my system, was accessible under sd3.

Back in the OS installer

Hit ^D (CTRL-D) in order to get back to the OS installer.

Follow the procedure as usual but when asked about which drive to install/partition, first choose sd2 with a fully automatic partition layout (let the installer create it for you).

Once this is done, delete the pre-created /home partition from sd2. In my case I reallocated the newly free space to another partition.

You can then move onto the next disk and choose sd3. After that simply create a partition manually (using similar disklabel commands) and mount it onto /home.

VoilĂ ! Well, you can then move on with the installation of the system and figure it out from there.

Getting the status of the array and testing a failure

$ sudo bioctl sd3


$ sudo bioctl softraid0

Will both return the status of the array. For example, here it is showing a recovery (the array is getting rebuilt):

$ sudo bioctl softraid0
Volume      Status               Size Device  
softraid0 0 Rebuild      500104946176 sd3     RAID1 3% done 
          0 Rebuild      500104946176 0:0.0   noencl <sd0a>
          1 Online       500104946176 0:1.0   noencl <sd1a> 

I had previously shutdown and rebooted the system with one of the drives disconnected. After that I shut it down again, reconnected the drive (sd0) then rebooted.

The array rebuild had not started automatically after that last reboot. In the end I got it to rebuild using:

$ sudo bioctl -R /dev/sd0a sd3

Oh, and the manual is your friend.