Installing OpenBSD/amd64 5.1 using softraid
OpenBSD 5.1 added support for placing the root partition on a softraid(4) volume for the amd64, i386 & sparc64 architectures. You can boot the system from the softraid RAID1 volume on amd64 ONLY. Other architectures still require the kernel to be located on a non-softraid device. This article details my experience installing OpenBSD 5.1 on amd64 to take advantage of these new features.
General Notes on this transcript:
- I was installing to two identical 320GB SATA disks, so my install targets were sd0 & sd1.
- The bold text represents keyboard input.
Creating the softraid volume is a manual process that must be done before running the installer. Boot the install disk and choose to drop to a shell when asked:
(I)nstall, (U)pgrade or (S)hell? s
By default, only the sd0 devices will exist. We will need to create device nodes for the second disk (sd1) and what will eventually be the RAID volume (sd2).
# cd /dev && sh /dev/MAKEDEV sd1 sd2
Initialize the MBR partitions. I’m using the entire disks for OpenBSD.
# fdisk -iy sd0
Writing MBR at offset 0.
# fdisk -iy sd1
Writing MBR at offset 0.
Now we need to create the BSD disk labels. Since I’m installing amd64 I don’t really need a separate partition for the kernel, but I’m going to create one anyway in case I discover a compelling reason to use this in the future.
# disklabel -E sd0
Label editor (enter '?' for help at any prompt
> a a
offset: [64]
size: [2097152] 100m
Rounding size to cylinder (16065 sectors): 208781
FS type: [4.2BSD]
Rounding size to bsize (32 sectors): 208768
> a d
offset: [208832]
size: [624928513]
FS type: [4.2BSD] RAID
> q
Write new label?: [y] y
# cd /tmp && disklabel sd0 > disklabel.txt
# disklabel -R sd1 disklabel.txt
Ok, so that’s the disk labels. Now we can construct the RAID volume. Everyone always says it’s a best practice to zero the start of the volume, so I’ll do that, too.
# bioctl -c 1 -l /dev/sd0d,/dev/sd1d softraid0
sd2 at scsibus2 targ 1 lun 0: <OPENBSD, SR RAID 1, 005> SCSI2 0/direct fixed
sd2: 305140MB, 512 bytes/sector, 624927985 sectors
softraid0: SR RAID 1 volume attached as sd2
# dd if=/dev/zero of=/dev/rsd2c bs=1m count=1
1+0 records in
1+0 records out
1048576 bytes transferred in 0.012 secs (80914885 bytes/sec)
That’s all there is to creating a RAID volume. At this point we can exit the shell and install as normal.
# exit
(I)nstall, (U)pgrade or (S)hell? i
Continue with the install as normal up until the disk setup section. I would heartily recommend using DUIDs for /etc/fstab in case device numbers change. I’m planning on adding more disks to this host, and I’m not sure if the softraid will assemble to sd2 after that happens.
Available disks are: sd0 sd1 sd2.
Which one is the root disk? (or ‘done’) [sd0] sd2
Use DUIDs rather than device names in fstab? [yes]
MBR has invalid signature; not showing it.
Use (W)hole disk or (E)dit the MBR? [whole]
Setting OpenBSD MBR partition to whole sd2...done.
I’m a big fan of the automatic filesystem layout. How great is that.
Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout? [a] A
From here just continue through the setup as normal. Some closing thoughts:
- Unlike previous versions of softraid on OpenBSD, you won’t need to set up a daily altroot sync. Obviously.
- On amd64, you won’t have to worry about using installboot to update the boot blocks after an upgrade. This is because installboot now has enough intelligence to examine softraid configuration and determine the physical disks which should receive the boot blocks. Sweet.
References:
- Originally based on jpiasetz’s OpenBSD 4.6 install guide.
- Inspiration from Jonathan Perkin’s Installing OpenBSD with softraid.
- Not the same, but still very cool is undeadly’s Provisioning Root on Softraid
Updated 2011/10/08: Corrected typo in installboot command. Updated 2012/06/18: Major rewrite for OpenBSD 5.1 and root-on-softraid.