Ads are created by, and assumed to be the property of, Google.

Aleph 0 Computing: Dual-booting OpenBSD and Windows XP

This page is no longer being updated. Please visit Aleph 0 Computing for information on current projects.

The OpenBSD FAQ contains some rudimentary information on multibooting, in fact enough that I was able to install both OpenBSD 3.6 (I haven't yet attempted with more recent versions) and Windows XP on my Dell Inspiron 1100 laptop. The information in the FAQ is repeated and somewhat expanded upon here; some idiosyncracies still remained after following the instructions there.

I'll generally assume you're starting from scratch here. I have no recent experience with hard disk “re-partitioners” like Partition Magic, FIPS, or GNU Parted. Try them if you like, but I most certainly find it easier (and safer) to just back up my important files and reformat the disk.

Personally, I chose to use a minimum amount of space for Windows and the rest for OpenBSD. That minimum seems to be around 4 GB (a number which has likely continued to rise for newer versions) for Windows, its updates, Microsoft Office or OpenOffice.org, Firefox, and miscellaneous smaller utilities, along with the swap file. Sure, there are probably ways to make that size smaller, but I'd prefer to spend my time with just a basic Windows install, not significantly tweaked or changed, for those few times I have to use it.

Installing Windows XP

Install Windows first. Boot the CD, wait, and repartition your drive to have an empty primary partition. Depending on your needs, I'd suggest using a FAT partition instead of NTFS, just because OpenBSD can read and write small files from and to it more reliably (see the Warning in mount_ntfs(8) for more information). FAT is generally considered less secure and slower, though, and Windows won't make a FAT partition larger than 32 GB. However, as I mentioned, a 4 GB one seems to do fine. Make sure to leave space on the drive for at least the OpenBSD root filesystem; Windows's boot manager can only boot from the primary hard disk.

The rest of the Windows installation shouldn't significantly differ from a normal installation. Click, wait, configure, repeat. You might as well go ahead and do all the updating and application installing; no need to waste time installing OpenBSD if you end up messing up and needing to start over.

Installing OpenBSD

When you're ready to install OpenBSD, follow the general installation instructions, with only a couple of caveats. First, when asked if you want to use the entire hard disk for OpenBSD, be sure to say no! (It's actually the default.) This will take you to OpenBSD's fdisk(8), and you can add a partition for OpenBSD. Personally, I just started on the cylinder after the Windows partition and went to the end of the disk.

Next disklabel(8) will run to finish preparing the OpenBSD partition. Most importantly, don't delete the Windows partition that's already labelled; on my machine (and on most), it's partition i. Add your OpenBSD filesystems around it, and go on to naming the mountpoints.

Again, the rest of installation shouldn't really depend on this being a dual-boot machine. Finish up, and we'll make a few more changes before we're done.

Using the Windows XP boot manager

This is really just as described in the FAQ. To boot into OpenBSD, use the CD again, but at the boot> prompt, enter boot hd0a:/bsd. Login as root. Enter dd if=/dev/rwd0a of=openbsd.pbr bs=512 count=1, changing rwd0a to rsd0a if you boot from a SCSI hard disk. If you formatted your Windows XP partition as FAT, mount that partition and copy the file over. If you chose NTFS, use a network or writable media to transfer the file.

Finally, remove the OpenBSD boot CD, and reboot into Windows. Open the Start Menu, right-click on My Computer, and choose “Properties”. Click on the “Advanced” tab, click the “Settings” button under “Startup Recovery”, and under “System Startup” click “Edit”. Add C:\openbsd.pbr="OpenBSD" to the end of the file, and save it. Reboot, and you should have a simple dual-boot menu.

Local time hardware clock

Next, there's no way to tell Windows XP that the computer's hardware clock is set to anything other than local time. That is, the time that's displayed in the “system tray” is the same time that's saved in the internals of the computer. However, OpenBSD assumes that the hardware clock time is Universal time, or UTC (also known as GMT). Therefore, we need to tell OpenBSD that's not actually the case.

We do this by configuring the OpenBSD kernel to offset the hardware clock time by some amount. This doesn't actually require a kernel recompile; since OpenBSD 2.6 the config(8) tool allows changes to be made to an already-compiled kernel. First, identify the offset from UTC; I live in Los Angeles, so we're 8 hours behind UTC during the winter (that is, Pacific Standard Time). That's 480 minutes. Therefore, we will set an offset of 480 minutes. If you're ahead of UTC, like, say, Budapest, the offset will be negative.

Then, as root, enter config -e -f /bsd. At the prompt, enter timezone 480, substituting whatever number is appropriate. If you're currently under daylight saving time (during the summer), use timezone 480 1. Enter quit, reboot, and you're all set.