Skip to content

Instantly share code, notes, and snippets.

@dsendkowski
Created January 9, 2020 10:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dsendkowski/47ccbe31932dd5a2910de6d16cf8470b to your computer and use it in GitHub Desktop.
Save dsendkowski/47ccbe31932dd5a2910de6d16cf8470b to your computer and use it in GitHub Desktop.
OpenBSD: create encrypted device over RAID1

We have two disks sd0 and sd1. First, we need to prepare our disks.

$ doas fdisk -iyg sd0
$ doas fdisk -iyg sd1

Then, create RAID partitions:

$ printf "a\n\n\n\nRAID\nw\nq\n" | doas disklabel -E sd0
$ printf "a\n\n\n\nRAID\nw\nq\n" | doas disklabel -E sd1

Next, create RAID:

$ doas bioctl -c 1 -l sd0a,sd1a softraid0

A new disk will be created sd2. Again, initialize this new disk:

$ doas fdisk -iyg sd2
$ printf "a\n\n\n\nRAID\nw\nq\n" | doas disklabel -E sd2

Next, make an encrypted device:

$ doas bioctl -c C -l /dev/sd2a softraid0

Another disk sd3 is created. Let's initialize it:

$ doas fdisk -iyg sd3
$ printf "a\n\n\n\n\nw\nq\n" | doas disklabel -E sd3

and make a new file system on it:

$ doas newfs /dev/rsd3a

Now, we can mount our encrypted device:

$ doas mount /dev/sd3a /data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment