Previous INDEX Next
Deleting attachments in Thunderbird Sendmail on OpenBSD

Installing and using OpenBSD

Now that OpenBSD 5.0 was out, I figured I would use the scratch disk space on the fourth disk (hd3 in Grub parlance) installed in crimson.

The fourth partition (FreeBSD slice 4) was 140GB in size and unused. Seemed like a good place to experiment with an OpenBSD install. I downloaded install50.iso, which contains all the files needed for a non-network install, from a local mirror and burnt it to a CD.

The install process is pretty simple. When it came to deciding where to install OpenBSD, I chose to edit the partition table on wd3, making partition 3 (using zero index base) as OpenBSD (partition id 166 or x'A6'). I took the auto filesystem layout option and filesets installed just fine. Rebooted at successful completion.

Crimson was booted via Grub, so I interactively booted into the new OpenBSD install using:

  root (hd3,4,a)
  makeactive
  chainloader +1

The OpenBSD bootloader started, but...

  Loading....
  probing: pc0 com0 com1 apm mem[638K 2543M a20=on]
  disk: hd0+* hd1+* hd2* hd3*
  >> OpenBSD/i386 BOOT 3.17
  open(hd3a:/etc/boot.conf): Invalid argument
  boot>
  booting hd3a:/bsd: open hd3a:/bsd: invalid argument
   failed(22). will try /bsd
  booting hd3a:/bsd: open hd3a:/bsd: invalid argument
   failed(22). will try /bsd
  booting hd3a:/bsd: open hd3a:/bsd: invalid argument
   failed(22). will try /bsd
  Turning timeout off.

Hmm... Not what I was expecting. After some googling on the error message, it appeared that OpenBSD did not support booting from outside the first 1024 cylinders. I didn't think operating systems had that problem any more. I wasn't going to move the partitions around to put the OpenBSD partition within the first 1024 cylinders, so I decided to install OpenIndiana on the scratch space instead. The install went without a hitch.

A little while later, I decided to try OpenBSD again, this time re-partitioning hd2, a 160GB drive, so that I could use a partition at the beginning of the disk. At present it was entirely given over to FreeBSD, but there wasn't much data, so it was easy to back up and restore. I used the FreeBSD fdisk program to define two partitions, the first 30GB for OpenBSD, the remainder of disk space in the second partition for FreeBSD disk storage.

I went through the install process again. This time the boot process recognised the existing OpenBSD partition and gave me the option to use it. Nice. Everything went smoothly and I confidently rebooted. But it wouldn't - same error messages as before. Clearly the problem had nothing to do with a 1024 cylinder limit.

The disk setup appeared to fulfill all the pre-requisites for OpenBSD disks: the right signature, no overlapping partitions, OpenBSD partition marked as active:

Disk: wd2       geometry: 19457/255/63 [312581808 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
*0: A6      0   1   1 -   3916  59  63 [          63:    62914257 ] OpenBSD
 1: A5   3916  60   1 -  19457  64  63 [    62914320:   249666480 ] FreeBSD
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused

I tried a variety of ways to redo the partitioning, using the OpenBSD fdisk during the boot process, but nothing made any difference. For some reason, the boot process refused to believe an OpenBSD partition existed (that little asterisk after hd2 is the clue).

Finally, I decided to zero out the MBR, since I had heard this was occasionally required to fix weird behaviour such as this. I used dd from FreeBSD:

  dd if=/dev/zero of=/dev/ad2 bs=512 count=1

I performed yet another reinstall. Fdisk told me the disk had an invalid MBR (as expected). I used the reinit command to obtain a clean in-memory MBR and then edited it back to the partition setup shown above. Ok, rebooted. The first thing I noticed was the the asterisk after hd2 had disappeared; looking good. And it booted perfectly.

Later...

Actually much, much later. After an install of OpenBSD 5.8 on the system, over the top of DragonflyBSD, the same issue occured. This time I didn't want to zero out the MBR of hd2, as there were other partitions on the disk I didn't want to clobber. Comparing the probe messages with other, successfully booting OpenBSd instances, I noticed that all the good ones showed the probed hard drives with a trailing +.

  Loading....
  probing: pc0 com0 com1 apm mem[638K 2543M a20=on]
  disk: hd0+

The + indicates that the BIOS reports the drive supports LBA. In the BIOS of this machine all the drives were set to AUTO, so why why did hd2 not show a +? No idea, but I could force LBA mode on in the BIOS. On reboot, the OpenBSD partition was recognised. If I get some time, I might dig around in the code to see if I can find out what is going on.

Setting up OpenBSD

Now I had a bootable OpenBSD system, I could begin the process of setting it up. First impressions where that OpenBSD was pretty lean compared to FreeBSD. Compare the OpenBSD disk usage to FreeBSD:

OpenBSD df -h

Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/wd2a     1005M   39.5M    915M     4%    /
/dev/wd2l     11.8G    1.3G    9.9G    12%    /home
/dev/wd2d      1.9G    6.0K    1.8G     0%    /tmp
/dev/wd2f      2.0G    365M    1.5G    19%    /usr
/dev/wd2g     1005M    166M    789M    17%    /usr/X11R6
/dev/wd2h      4.2G    417M    3.6G    10%    /usr/local
/dev/wd2k      2.0G    2.0K    1.9G     0%    /usr/obj
/dev/wd2j      1.4G    801M    595M    57%    /usr/src
/dev/wd2e      3.0G    6.5M    2.9G     0%    /var

FreeBSD df -h

Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ad0s1a    989M    379M    531M    42%    /
devfs          1.0K    1.0K      0B   100%    /dev
/dev/ad0s1g     19G    2.2G     16G    12%    /home
/dev/ad0s1h     44G    2.6G     38G     7%    /rep
/dev/ad0s1e    496M    1.5M    455M     0%    /tmp
/dev/ad0s1d    5.8G    3.2G    2.2G    59%    /usr
/dev/ad0s1f    989M     32M    878M     4%    /var
procfs         4.0K    4.0K      0B   100%    /proc
devfs          1.0K    1.0K      0B   100%    /var/named/dev

Admittedly, the FreeBSD root partition has two kernels on it, but even so, the disparity in disk usage between the two OS's is striking. It's a bit like being back in FreeBSD 4.11.

Packages are added using the pkg_add command. One has to specify a mirror as the download target, either on the command line or via the PKG_PATH environment variable. I set PKG_PATH to:

  PKG_PATH=http://www.mirrorservice.org/pub/OpenBSD/5.0/packages/i386/

pkg_add supports an -i switch, which prompts you to choose between packages if there is an ambiguity in the name. This was a nice feature, which I used when installing the following packages:

  python
  py-libxml
  emacs
  rsync
  gmake
  chromium

which left me with this lot installed:

  ORBit2-2.14.19p0    high-performance CORBA Object Request Broker
  atk-2.0.1           accessibility toolkit used by gtk+
  bzip2-1.0.6         block-sorting file compressor, unencumbered
  cairo-1.10.2p1      vector graphics library
  chromium-12.0.742.122 Chromium browser
  cups-1.4.7p0        Common Unix Printing System
  dbus-1.4.12v0       message bus system
  dbus-glib-0.94v0    glib bindings for dbus message system
  desktop-file-utils-0.18p0 utilities for dot.desktop entries
  emacs-23.3p2        GNU editor: extensible, customizable, self-documenting
  gamin-0.1.10p12     gamin file monitoring server
  gconf2-2.32.4       configuration database system for GNOME
  gdk-pixbuf-2.23.5   graphic library for GTK+2
  gettext-0.18.1p0    GNU gettext
  glib2-2.28.8p1      general-purpose utility library
  gmake-3.82          GNU make
  gnome-icon-theme-2.30.3p3 base icon theme for GNOME
  gtk+2-2.24.5p0      multi-platform graphical toolkit
  gtk+2-cups-2.24.5   gtk+2 CUPS print backend
  hicolor-icon-theme-0.12p1 fallback theme of the icon theme specification
  jasper-1.900.1p1    reference implementation of JPEG-2000
  jpeg-8c             IJG's JPEG compression utilities
  libIDL-0.8.14       IDL parsing library
  libcroco-0.6.2p1    generic CSS parsing library for GNOME project
  libexecinfo-1.1p2   clone of backtrace facility found in the GNU libc
  libgamin-0.1.10p4   file and directory monitoring system
  libgcrypt-1.4.6p1   crypto library based on code used in GnuPG
  libgpg-error-1.10   error codes for GnuPG related software
  libiconv-1.13p2     character set conversion library
  libogg-1.2.2        Ogg bitstream library
  librsvg-2.34.0p2    SAX-based render library for SVG files
  libungif-4.1.4p1    tools and library routines for working with GIF images
  libusb-0.1.12p4     USB access library
  libvpx-0.9.6        Google VP8 video codec
  libxml-2.7.8p2      XML parsing library
  libxslt-1.1.26p2    XSLT C Library for GNOME
  nspr-4.8.7          Netscape Portable Runtime
  nss-3.12.9          libraries to support development of security-enabled apps
  pango-1.28.4p2      library for layout and rendering of text
  pcre-8.12p0         perl-compatible regular expression library
  png-1.5.4           library for manipulating PNG images
  py-libxml-2.7.8p2   Python bindings for libxml
  python-2.7.1p9      interpreted object-oriented programming language
  rsync-3.0.8p0       mirroring/synchronization over low bandwidth links
  shared-mime-info-0.90 shared mime database for desktops
  speex-1.2rc1p0      patent-free speech codec
  sqlite3-3.7.5       embedded SQL implementation
  tiff-3.9.5          tools and library routines for working with TIFF images
  xdg-utils-1.0.2p12  utilities to assist desktop integration tasks

OpenBSD includes apache (based on 1.3), which by default is chrooted into /var/www. Since I need python for the websites, I turned the default off by adding the following to /etc/rc.conf.local:

  # use -u to disable chroot, see httpd(8)
  httpd_flags="-u"    # for normal use: "" (or "-DSSL" after reading ssl(8))

and edited the /var/www/conf/httd.conf file to use my normal file locations.

OpenBSD uses the ksh (based on pdksh) as the default shell, so to ensure that my web site Makefile scripts worked properly, I had to explictly export the shell PWD environment variable, otherwise it was not visible to gmake. The .profile contains:

  # $OpenBSD: dot.profile,v 1.4 2005/02/16 06:56:57 matthieu Exp $
  #
  # sh/ksh initialization

  PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/
  local/sbin:/usr/games:.
  export PATH HOME TERM

  ENV=./.kshrc; export ENV

while ~/.kshrc contains:

# Interactive ksh initialisation script: mpw

# invoke standard ksh interactive shell initialisation
. /etc/ksh.kshrc

# set prompt
PS1="[\u@\h:\w]$ "

# use GNU make by preference
alias make=gmake

# export PWD for access by gmake for building web sites
export PWD

Now I have a functioning web server, based on OpenBSD.

Another nice feature: in test building the btree library, warnings about unsafe functions are displayed:

/tmp//ccwkPynO.o(.text+0x61): In function `strsave':
: warning: strcpy() is almost always misused, please use strlcpy()
./lib/libbt.a(butil.o)(.text+0x1d): In function `itostr':
: warning: sprintf() is often misused, please use snprintf()
cc -pedantic-errors -Wall -Wno-long-long  -I./inc  -DREADLINE -o kcp ./src-main/kcp.c -L./lib -lbt -lreadline -lcurses
./lib/libbt.a(btcrtr.o)(.text+0x1dc): In function `btcrtr':
: warning: strcpy() is almost always misused, please use strlcpy()
./lib/libbt.a(butil.o)(.text+0x1d): In function `itostr':
: warning: sprintf() is often misused, please use snprintf()
cc -pedantic-errors -Wall -Wno-long-long  -I./inc  -DREADLINE -o bigt ./src-main/bigt.c -L./lib -lbt -lreadline -lcurses
./lib/libbt.a(btcrt.o)(.text+0xcb): In function `btcrt':
: warning: strcpy() is almost always misused, please use strlcpy()
/tmp//cckiblFP.o(.text+0x2b5): In function `main':
: warning: sprintf() is often misused, please use snprintf()
cc -pedantic-errors -Wall -Wno-long-long  -I./inc  -DREADLINE -o bigtdel ./src-main/bigtdel.c -L./lib -lbt -lreadline -lcurses
./lib/libbt.a(btopn.o)(.text+0xbf): In function `btopn':
: warning: strcpy() is almost always misused, please use strlcpy()
/tmp//cc6At5T1.o(.text+0x1f1): In function `main':
: warning: sprintf() is often misused, please use snprintf()

A little bit of work to do before the next release, I think.

Running an NFS server

In order to run an NFS server on OpenBSD, the following lines need to be added to /etc/rc.conf.local:

  portmap=YES
  nfs_server=YES
  nfsd_flags="-tun 4"

The NFS exported file systems are, as usual, listed in /etc/exports:

  #       $OpenBSD: exports,v 1.2 2002/05/31 08:15:44 pjanzen Exp $
  #
  # NFS exports Database
  # See exports(5) for more information.  Be very careful:  misconfiguration
  # of this file can result in your filesystems being readable by the world.
  # NB export line needs newline at end or mountd won't start
  /home/mark -network=192.168.0.0 -mask=255.255.255.0

I tested the setup by starting the daemons manually, as specified in the FAQ:

  # /usr/sbin/portmap
  # echo -n >/var/db/mountdtab
  # /sbin/mountd
  # /sbin/nfsd -tun 4

Yep, I could mount the exported filesystem on another machine. However, when I rebooted, mountd and nfsd would not start. This turned out to be caused by a missing newline character on the single line with the exported filesystem in /etc/exports. The rc_pre check that mountd uses, validates that /etc/exports has something useful in it by counting the non-comment lines by wc -l. wc counts lines by counting newline characters, so that's why mountd did not start.

Previous INDEX Next
Deleting attachments in Thunderbird Sendmail on OpenBSD