Installing OpenBSD with softraid

Dec 15, 2011 · openbsd, softraid

[ Note that I am in the process of migrating these blog posts from Wordpress, and as such it may contain incorrect formatting, missing links, etc. My old site is available at http://www-old.perkin.org.uk/ so if you find something obviously broken please let me know. Thanks! ]

This is more of a log for me than anything else, but perhaps someone will find this useful.

OpenBSD includes a software RAID implementation which supports booting in newer snapshots, and I was itching to install the latest version and use it as my file server, which has 4 750GB disks. There is a small bit of preparation work to do prior to installing, which is the bulk of this entry, most of which is based on this undeadly.org article.

Grab latest amd64 snapshot, boot it, drop into (S)hell mode and set up the disks:

#!/bin/sh

cd /dev
sh MAKEDEV sd1 sd2 sd3 sd4 sd5
for disk in 0 1 2 3
do
  # Clear beginning of disks..
  dd if=/dev/zero of=/dev/rsd${disk}c bs=1m count=10

  # ..and initialise new partition table
  fdisk -iy sd${disk}

  #
  # Create BSD disklabel:
  #
  # - 128m partitions at start to hold kernels for booting
  # - 4g spare raid on each disk for testing
  # - rest raid for main OS and data
  #   - OS and /home on first two mirrored disks
  #   - /store on second two mirrored disks
  #
  print "a a\n\n128m\n\na d\n\n4g\nraid\na e\n\n\nraid\nw\nq\n" \
    | disklabel -E sd${disk}

  # Clear beginning of raid partitions
  dd if=/dev/zero of=/dev/rsd${disk}d bs=1m count=10
  dd if=/dev/zero of=/dev/rsd${disk}e bs=1m count=10
done

# Create RAID1 mirrors
bioctl -c 1 -l sd0e,sd1e softraid0
bioctl -c 1 -l sd2e,sd3e softraid0

# Exit shell and start the (I)nstall
exit

As for the install, go with the sensible defaults, other than:

When it comes to disk selection, choose sd4 as the root disk, and use the following layout:

# partition  size  mount
  sd4a       1G    /
  sd4b       8G    swap
  sd4d       1G    /tmp
  sd4e       8G    /var
  sd4f       16G   /usr
  sd4h       rest  /home

then initialise sd5 with:

# partition  size  mount
  sd5a       2G    /altroot
  sd5d       8G    /scratch
  sd5e       rest  /store

Install the full OS, set the correct timezone, then before rebooting initialize the boot partitions and copy the kernels to them. Doing this on all of them means we can boot from any disk.

#!/bin/sh

for disk in 0 1 2 3
do
  newfs sd${disk}a
  mount /dev/sd${disk}a /mnt2
  cp /mnt/bsd* /mnt2
  umount /mnt2
done
eject cd0a
reboot

Job done.


All blog posts

Feb 20, 2012 » New blog design
Jan 11, 2012 » Set up anonymous FTP upload on Oracle Linux
Jan 09, 2012 » Kickstart Oracle Linux in VirtualBox
Jan 09, 2012 » Kickstart Oracle Linux from Ubuntu
Dec 22, 2011 » Last day at MySQL
Dec 15, 2011 » Installing OpenBSD with softraid
Sep 21, 2011 » Create VirtualBox VM from the command line
Sep 14, 2011 » Creating chroots for fun and MySQL testing
Jun 30, 2011 » Graphing memory usage during an MTR run
Jun 29, 2011 » Fix input box keybindings in Firefox
Jun 24, 2011 » How to lose weight
Jun 23, 2011 » How to fix stdio buffering
Jun 13, 2011 » Serving multiple DNS search domains in IOS DHCP
Jun 13, 2011 » Fix Firefox URL double click behaviour
Apr 20, 2011 » SSH via HTTP proxy in OSX
Nov 09, 2010 » How to build MySQL releases
Apr 29, 2010 » 'apt-get' and 5,000 packages for Solaris10/x86
Sep 16, 2009 » ZFS+NFS vs OSX
Sep 12, 2009 » pkgsrc on Solaris
Dec 09, 2008 » Jumpstart from OSX