Installing OpenBSD with softraid
In this guide, we will perform a clean install of OpenBSD on two identical disks that are mirrored with softraid (RAID1). This guide is based on the OpenBSD FAQ.
NOTE: RAID1 requires the two partitions to be mirrored to be of the same size. It is possible to use disks of different sizes and models, but the efficiency/performance will not be optimal. We recommend you get two disks of the same size and model.
First, we boot the installer:
Loading /7.5/AMD64/CDBOOT probing: pc0 com0 mem[638K 2046M a20=on] disk: hd0+* hd1+* cd0 >> OpenBSD/amd64 CDBOOT 3.65 boot> cannot open cd0a:/etc/random.seed: No such file or directory booting cd0a:/7.5/amd64/bsd.rd: 4076463+1688576+3891240+0+708608 [109+464016+317541]=0xaa40e8 ... Welcome to the OpenBSD/amd64 7.5 installation program. (I)nstall, (U)pgrade, (A)utoinstall or (S)hell?
Type s to drop to a shell:
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? s #
You will need to create the disk devices in /dev. In this example, we need two disks plus a third to represent the new RAID array, so we run:
# cd /dev # sh MAKEDEV sd0 sd1 sd2
If your installer is a USB drive, don't forget to include another device for that, too.
Next, we initialize the disks with fdisk to boot from MBR:
# fdisk -iy sd0 # fdisk -iy sd1
Create the disklabel partitions for sd0:
# disklabel -E sd0 Label editor (enter '?' for help at any prompt) sd0> a a offset: [64] size: [41942976] * FS type: [4.2BSD] RAID sd0*> w sd0> q No label changes.
Next, copy the partition layout for the second disk:
# disklabel sd0 > layout # disklabel -R sd1 layout # rm layout
We use bioctl(8) to create the RAID1 array:
# bioctl -c 1 -l sd0a,sd1a softraid0 sd2 at scsibus3 targ 1 lun 0: <OPENBSD, SR RAID 1, 006> sd2: 20479MB, 512 bytes/sector, 41942448 sectors softraid0: RAID 1 volume attached as sd2
In this case we used sd0a and sd1a, but you may need to replace
these with your actual partition names. Always use softraid0, regardless of how many RAID arrays or what RAID discipline you use.
-c 1 instructs bioctl to use RAID 1, but RAID 0, RAID 5, and full disk encryption are also available. Check the bioctl(8) man page.
Notice that a new SCSI disk is created, sd2.
Zero out the master boot record and disklabel by clearing the first megabyte with dd?:
WARNING: Double check to ensure you have the right disk! Mistakes with the command below can wipe out an entire disk!
# dd if=/dev/zero of=/dev/rsd2c bs=1m count=1
Confirm the RAID array is set up properly:
# bioctl sd2
Volume Status Size Device
softraid0 0 Online 21474533376 sd2 RAID1
0 Online 21474533376 0:0.0 noencl <sd0a>
1 Online 21474533376 0:1.0 noencl <sd1a>
Now type exit to return to the OpenBSD installer:
# exit
Follow a normal OpenBSD installation, making sure to install the operating system on the RAID1 array (in this example, sd2).
RAID5
WARNING: According to softraid(4), boot support is currently limited to the CRYPTO, RAID 1, and RAID1C disciplines. It is not possible to boot from a RAID5 disk.
Because a RAID5 array cannot be used as a boot disk, we will not use it during installation, but afterwards.
For a RAID5 array, we need a minimum of 3 disks. Here, we use disks sd1, sd2, and sd3. We initialize the disks with fdisk, then replicate the disklabels:
# fdisk -iy sd1 Writing MBR at offset 0. # fdisk -iy sd2 Writing MBR at offset 0. # fdisk -iy sd3 Writing MBR at offset 0. # disklabel -E sd1 Label editor (enter '?' for help at any prompt) sd0> a a offset: [64] size: [41942976] * FS type: [4.2BSD] RAID sd0*> w sd0> q No label changes. # disklabel sd1 > layout # disklabel -R sd2 layout # disklabel -R sd3 layout # rm layout
We set up the RAID5 array with bioctl:
# bioctl -c 5 -l sd1a,sd2a,sd3a softraid0 sd4 at scsibus4 targ 1 lun 0: <OPENBSD, SR RAID 5, 006> sd4: 40959MB, 512 bytes/sector, 83884800 sectors softraid0: RAID 5 volume attached as sd4
Zero out the first megabyte of the RAID array:
# dd if=/dev/zero of=/dev/rsd4c bs=1m count=1 1+0 records in 1+0 records out 1048576 bytes transferred in 0.028 secs (37044791 bytes/sec)
And verify the RAID5 array is online:
# bioctl sd4
Volume Status Size Device
softraid0 0 Online 42949017600 sd4 RAID5
0 Online 21474533376 0:0.0 noencl <sd1a>
1 Online 21474533376 0:1.0 noencl <sd2a>
2 Online 21474533376 0:2.0 noencl <sd3a>
