OpenBSD Advanced Installation: GPT UEFI Mirror
Mirror Mirror On The Wall
Important OpenBSD systems should be installed onto a pair of mirrored disks so that malfunction of a single disk won't shut down services and cause data loss. OpenBSD FAQ has section about Installing to a Mirror which covers both MBR and GPT partitioning schemes. Seasoned admins familiar with OpenBSD's way of naming devices and tools such as fdisk and disklabel will find everything they need regarding mirrored setup there. This article adds a bit more information about installing OpenBSD to a mirror in newcomer friendly format.
Assuming we have sd0 and sd1 (SSDs), as well as sd2 (OpenBSD USB install media), we boot as usual and choose (S)hell when prompted.
We will manually create required disk devices for softraid setup, one for each device we currently have, and additional one for softraid device:
cd /dev
sh MAKEDEV sd0 sd1 sd2 sd3
Create GPT scheme on both our SSDs:
fdisk -gy -b 532480 sd0
fdisk -gy -b 532480 sd1
Invoke command-driven label editor to operate on first of two SSDs:
disklabel -E sd0
Create single partition of RAID FS type which spans whole disk:
sd0> a a
offset: [532544]
size: [33021855] *
FS type: [4.2BSD] RAID
sd0*> w
sd0> q
Dump layout of sd0 to a file named layout, restore it to sd1, and remove file:
disklabel sd0 > layout
disklabel -R sd1 layout
rm layout
Create mirror from newly created partitions on both SSDs:
bioctl -c 1 -l sd0a,sd1a softraid0
Notice output of above command - identifier of newly created device will be used as root disk later
sd3 at scsibus2 targ 1 lun 0: <OPENBSD, SR RAID 1, 006>
sd3: 16123MB, 512 bytes/sector, 33021327 sectors
softraid0: RAID 1 volume attached as sd3
OpenBSD FAQ warns that vew device probably has a lot of garbage where master boot record and disklabel are expected, so zeroing the first chunk of it is highly recommended.
Be very careful not to specify inappropriate device in command below.
dd if=/dev/zero of=/dev/rsd3c bs=1m count=1
Type install to restart the installer:
install
Answer prompts as in standard install and choose appropriate device as root disk when asked:
Which disk is the root disk? ('?' for details) [sd0] sd3
Partition as in standard install, continue to the end of the install as usual and choose reboot when prompted.
Make sure to remove USB install media beforehand
After reboot check status of RAID volume (root or appropriate doas privileges are needed):
bioctl sd2
Volume Status Size Device
softraid0 0 Online 16906919424 sd2 RAID1
0 Online 16906919424 0:0.0 noencl <sd0a>
1 Online 16906919424 0:1.0 noencl <sd1a>
Notice RAID volume changed from sd3 to sd2 due to USB install media being removed
Confirm partitions are mounted from RAID volume:
# df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/sd2a 988M 106M 833M 12% /
/dev/sd2d 3.9G 18.0K 3.7G 1% /home
/dev/sd2e 989M 10.0K 940M 1% /tmp
/dev/sd2f 1.9G 1.3G 569M 70% /usr
/dev/sd2g 989M 288M 652M 31% /usr/X11R6
/dev/sd2h 989M 220K 940M 1% /usr/local
/dev/sd2j 989M 7.9M 932M 1% /var
Here's transcript of terminal session: