[OpenBSDsupport]

OpenBSD Dualboot Walkthrough


OpenBSD Dualboot Walkthrough (updated! Now supports Win95 - WinXP inclusive)
updated 20051011 by Scott Francis 
(pretend you see the 2-clause BSD license here)
============================

From Lame to Game
(or, how to turn your stock Windows computer into an OpenBSD/Windows dualboot
machine without losing any data, in an hour or two)


!!!!!!!!!!!!!!!!!!!! ATTENTION !!!!!!!!!!!!!!!!!!!!!!!
!! ANYTHING THAT INVOLVES MODIFYING PARTITIONS 
!! AND FILESYSTEMS HAS THE POTENTIAL TO IRREVOCABLY
!! DESTROY EVERY BIT OF DATA ON THE DISK(S)!
!! I AM /NOT/ RESPONSIBLE FOR ANY DATA LOSS DUE TO
!! FOLLOWING (OR FAILING TO COMPLETELY FOLLOW) THIS
!! WALKTHROUGH.
!!
!! BACK UP YOUR DATA BEFORE YOU ATTEMPT THE FOLLOWING!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

********** NOTE FOR NTFS SYSTEMS ************



The following links should be useful if you're trying to do a
dualboot setup with OpenBSD and an NT-based OS:

* http://www.openbsd.org/faq/faq4.html#4.4
* http://nomoa.com/bsd/dualboot.htm
* The man pages mentioned in this document can be read online at
  http://www.openbsd.org/cgi-bin/man.cgi

If you're using an NT-based OS (NT, 2k, XP) you're most likely running NTFS as
your filesystem instead of FAT{16,32}. If so, FIPS will NOT work for you. It
will not resize/split NTFS partitions. I do not currently know of a free
software tool to do this [have received some suggestions to the contrary; see
below]. Partition Magic does a good job, and is well worth the purchase
price, IMO (at least until a free tool is available to non-destructively
resize NTFS filesystems).


KMartin(at)lansystems(dot)com(dot)au suggests BootIt Next Generation
[http://www.bootitng.com/bootitng.html] for resizing NTFS partitions (and
doing other disk management thing). Click the button for "BootIt Next
Generation" from the download section on the left.

szaka(at)sienet(dot)hu notes that there is a Linux-based tool that can resize
NTFS partitions - see http://mlf.linux.rulez.org/mlf/ezaz/ntfsresize.html for
more details. This software is Linux-only, so to use it you'd need to create a
Linux boot floppy, copy the ntfsresize binary to another floppy, boot to
Linux (from the boot floppy you created) and resize your NTFS partition from
the command line. Not as user-friendly, but if you're experienced, this could
save you some money.

And of course, I've just remembered that Mandrake Linux
[http://www.linux-mandrake.com] uses DiskDrake (sp?) and can
non-destructively resize NTFS partitions during installation. Of all the
Linux flavors I've used, Mandrake has consistently had the most friendly
installation process. (Wait a sec, this is supposed to be a tutorial
advocating OpenBSD, not Linux! :) well, a good tool deserves a mention, even
if it isn't in line with the focus of the topic at hand ...)


If you're using NTFS, you will need to shrink your primary Windows partition
with Partition Magic. I suggest moving the _start_ of the partition up from
the beginning of the disk to about 7GB into the disk (although with newer
systems, the bootable area may be the first 32GB or 128GB instead of the first
8GB; I haven't tried this, and suggest just allocating the first 8GB of your
primary hard disk to OpenBSD. It's enough space, and will save you potential
headaches).
NOTE: the ENTIRE root partition MUST be within the computer's BIOS (or boot
ROM) addressable space. I _STRONGLY_ suggest you read
http://www.openbsd.org/faq/faq14.html#LargeDrive
before you resize your NTFS partition!

Once you have resized your NTFS partition, select your new unallocated space
(the first 7GB of the disk in my case) and create a new primary partition in
this space. Do not format it; just create a primary partition. Then
right-click on the new partition, go down to 'Advanced ->' and click 'Hide
partition'. After you've finished these operations (PartitionMagic will
require at least one reboot), boot from your OpenBSD boot floppy or CD-ROM,
select '(I)nstall', when asked if you wish to use the entire disk for OpenBSD,
select 'no', and in fdisk, type 'edit 1' and change the label of your
unallocated partition to 'A6'. (The allocated NTFS partition will be
partition 0; the unallocated space should be partition 1.) Make sure that
partition 0 is flagged 'active' (look for an asterisk beside it) before you
exit fdisk! Otherwise you won't boot the Windows partition when you reboot.

(Much of the following is taken directly from
http://www.openbsd.org/faq/faq4.html#Multibooting, mainly the section on
NT/2000/XP NTLDR. Please read it as well.)

Proceed with the rest of the installation (see numbers 6 - 8 below for
details). When you're done installing, pop in a USB key or floppy, mount it
(for a USB key, I do "mount_msdos /dev/sd0i /mnt"; for a floppy, it's
"mount_msdos /dev/fd0a /mnt") and do the following to grab your OpenBSD
primary boot record:
# dd if=/dev/rwd0a of=/mnt/openbsd.pbr bs=512 count=1
Now reboot the machine into Windows, and copy the openbsd.pbr file you just
created to C:\openbsd.pbr in Windows. If you don't have a floppy or USB key
available to tranfer your openbsd.pbr with, you can copy it to another
machine on your network, reboot into Windows, and copy it back.

Now that you have your OpenBSD primary boot record available from within
Windows, you need to modify NTLDR to add OpenBSD as an OS option during boot.
Right-click on 'My Computer', select 'Properties', click the 'Advanced' tab,
click the 'Settings' button next to 'Startup and recovery', then click the
'Edit' button. Notepad will come up, and add a line at the bottom that says:

C:\openbsd.pbr "OpenBSD"

then close notepad and save changes. You now have a system that will
dual-boot OpenBSD and Windows {XP|NT|2000}! Congratulations. For package
installation and other post-OS install details, please start with number 9
below and continue to the end.






The following instructions assume a current version of OpenBSD (3.7 as of
May 2005) and Win95/98/ME on x86 hardware. For NT-based systems, see the
notes above (section ). Please also read the documentation included with
FIPS and XOSL very carefully.



Before you begin, boot into Windows and:

* Get FIPS - http://www.igd.fhg.de/~aschaefe/fips/
* Get XOSL - http://www.ranish.com/part/xosl.htm (thanks to
jjhartley-at-att-dot-net for the URL update)
* Get an OpenBSD boot image (I use floppyC34.fs for better laptop hardware
support) from:
ftp://ftp.openbsd.org/pub/OpenBSD/3.7/i386/floppyC34.fs
* run scandisk, thorough
* run defrag

1. Get FIPS and follow the instructions in fips.doc for installation.
Basically, 'format a:/s' to make a bootable floppy, copy the fips files to it,
run scandisk (thorough), run defrag, and reboot with the floppy.

2. Run FIPS - take a look at how much space you're currently using on your
Windows partition. Be sure you leave enough free space for any other stuff
you may want to place there. Reallocate the rest of the space to a new
partition.

3. Reboot, and get XOSL. Unzip the archive onto a floppy. Read through the
manual a time or two, then reboot into DOS mode. Run XOSL - you can follow all
the defaults if you like. I chose 1024x768 resolution, but this can be changed
at any time in the 'Preferences' menu of XOSL itself, while it's running.
There's no reason not to include Ranish Partition Manager and Smart Boot
Manager as well. They may prove useful, and don't cause any harm.

4. Reboot again. Tweak your XOSL settings to your liking. Be sure you go into
the 'settings' tab and click 'Add' to add your existing Windows partition as
bootable. Boot back into Windows. Grab an OpenBSD boot floppy image (I use
floppyC34.fs) from ftp://ftp.openbsd.org/pub/OpenBSD/3.7/i386/ and write the
image to a floppy (rawrite.exe works for Win95/98/ME; for NT/2k/XP use
ntrw.exe - these tools are available at
ftp://ftp.openbsd.org/pub/OpenBSD/3.7/tools/; if you have a UNIX box
around, use dd(1)).

(Use your nearest mirror, and substitute 3.7 for whatever current release
you're running. Also substitute i386 for whatever architecture you're on, but
if you're not on i386, this page probably doesn't help you much anyway.)

5. Boot from the floppy, and begin the installation process. When asked if
you want to use the ENTIRE disk for OpenBSD, type no. You'll be dropped into
fdisk, where you should see something like this:
----
Disk: wd0       geometry: 1099/255/63 [17655435 Sectors]
Offset: 0       Signature: 0xAA55
         Starting       Ending       LBA Info:
 #: id    C   H  S -    C   H  S [       start:      size   ]
------------------------------------------------------------------------
*0: 0C    0   1  1 -  509 254 63 [          63:     8193087 ] Win95 FAT32L
 1: 0C  510   0  1 - 1098 254 63 [     8193150:     9462285 ] unused
 2: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
 3: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
----

(Note: the description on partition 1 may vary, but if you have followed the
directions so far, partition 1 _will_ be the new partition you created with
FIPS in step 1 above.)

You want to change the partition ID of partition 1 (the partition you just
created) to A6, for OpenBSD. To do this, type 'edit 1' and then 'A6'. Then
type 'write' and 'quit'.

6. It's now time to divide up the OpenBSD partition using disklabel, which
the install process will drop you into next. Type 'p g' to see the existing
disklabel in GB. Slice c is a special slice that cannot be deleted; it
represents the entire partition. Delete any existing slices by typing 'd a'
to delete slice a, for instance. You now will create your OpenBSD
filesystems. When I did this, I had about 4.5 GB to work with, and did the
following:
----
#        size   offset    fstype   [fsize bsize   cpg]
  a:   511938  8193150    4.2BSD     1024  8192    16   # (Cyl. 8128*- 8635)
  b:   512064  8705088      swap                        # (Cyl. 8636 - 9143)
  c: 17660160        0    unused        0     0         # (Cyl.    0 - 17519)
  d:   512064  9217152    4.2BSD     1024  8192    16   # (Cyl. 9144 - 9651)
  e:  1024128  9729216    4.2BSD     1024  8192    16   # (Cyl. 9652 - 10667)
  f:  1024128 10753344    4.2BSD     1024  8192    16   # (Cyl. 10668 - 11683)
  g:  2097648 11777472    4.2BSD     1024  8192    16   # (Cyl. 11684 - 13764)
  h:  3780315 13875120    4.2BSD     1024  8192    16   # (Cyl. 13765 - 17515*)
  i:  8193087       63     MSDOS                        # (Cyl.    0*- 8128*)
----

Slice c is the whole disk; slice b is my swap space (250MB). Slice a is the
root partition / at 250MB; slice d is /tmp, which I gave 250MB; slice e is
/home, at 1GB; slice f is /var, at 1GB; slice g is /usr/local (on a separate
partition to take advantage of flags like nosuid/nodev; you could just have a
single filesytem for /usr that contains them both) at 1GB; slice h is /usr,
which gets all the remaining space (about 1.8GB). Since /usr contains both
/usr/src and /usr/ports (the source and ports trees), you'll need most of
that space, especially if you're ever building from source later on.

To add new slices, just type 'a' to add a slice. You'll be prompted for size,
filesystem type, offset, mount point, etc. You'll be safe with the default
options for most of these by just hitting enter (mount point being the
exception, you'll want to tell the system where to mount each slice). When
prompted for size, you can enter size in many units; I prefer to use MB or
GB. To enter a slice of 750 MB, just type '750M'. For a 2GB slice, type '2G'.

When done, type 'w' to write the new label, and 'q' to quit, saving changes.
Now it's time to install the OS.

7. Follow the instructions for the rest of the install. If OpenBSD recognizes
your network card, you can install from an Internet mirror or from a local
copy. If OpenBSD recognizes your CDROM drive, you can install from there. If
you have a machine with neither a built-in CDROM, nor a network card that's
supported, you can install from a separate partition on the disk. This is
what I did with my VAIO PCG-SR17: Boot to Windows. Plug in your PCMCIA DVD or
CD drive. Insert the OpenBSD disk that contains the i386 tree (typically disk
1). Create a folder to contain the i386 tree, and be sure you have enough
space (several hundred MB). Use the DOS program 'xcopy' to copy the contents
of the i386 directory on the CD to your Windows folder. Do 'xcopy /?' for the
options to this program. Now, when you get to the installation file sets part
of the OpenBSD install, you can choose the local disk option and pull the
files off the same drive. If you disklabeled as I did above, your Windows
partition (C:) will probably be /dev/wd0i.

8. When you're done installing (I typically type 'all' when prompted for what
file sets to choose), halt the system, then reboot. You can now go into XOSL
and select 'setup' and add your new OpenBSD OS. Boot into it, and we are
ready to complete setup of your new operating system.

9. Now login as root and type 'adduser'. You'll be prompted to make some
choices about settings for future adduser runs; you can choose the default on
all of them. Add a new user for yourself, and when asked if you wish to add
the user to any other groups, type 'wheel' (this will enable the new user to
su to root if necessary). When done, type 'visudo' to edit /etc/sudoers -
sudo is an essential tool for system administration. See sudo(8) for more
information. Scroll down to the section that says:

----
# Uncomment to allow people in group wheel to run all commands
#%wheel  ALL=(ALL)       ALL
----

and uncomment the second line. Logout, and log back in as your new user.

10. Now do 'sudo xf86cfg', do any tweaks necessary, exit out and save your
XF86Config. From there on out, it's personal preference. I like to enable
apmd (for laptops) and xdm in /etc/rc.conf. I also install the following
packages (package versions may have changed; check the FTP site first):

There are two ways to install software from the ports(7) system (ports are
commonly-used third-party software packages modified to install smoothly into
OpenBSD) - you can either build from source, or you can install pre-compiled
binary packages. The maintainers of the ports tree consider the binary
packages to be the ultimate goal of their work, so unless you have a very
good reason to build from source, I suggest using the packages available from
your local mirror. The ports system will automagically fetch dependencies and
do cryptographic checks along the way to make sure everything is kosher, and
you'll save a lot of time and wear on your machine compared to compiling it
yourself. Somebody already went to the work of compiling and testing the
ports for you; take advantage of their effort!

(There are a very few ports in the tree that will not be available as binary
packages (gkrellmbgchg comes to mind); for these few, you will need to use
the ports tree and build from source. There aren't many of these.)

To use the ports tree, see the following example:
$ cd /usr/ports
(say I want to install the Enlightenment window manager)
$ make search key=enlightenment | less
(some output here; the first entry is likely to be what I'm looking for)
$ cd /usr/ports/x11/enlightenment
$ sudo make install

To install from pre-compiled packages, try this:
$ export PKG_PATH=ftp://ftp.usa.openbsd.org/pub/OpenBSD/3.7/packages/i386/
$ sudo pkg_add -v ${PKG_PATH}enlightenment-0.16.5.tgz

Some other ports I install are waimea, bash-2.05b-static, zsh, Eterm, gaim,
XMMS, and gkrellm. They're all available in the ports tree, or as
pre-compiled packages on your local FTP mirror.

(If any of the above leaves you with questions, you should check out the many
excellent man pages available regarding packages/ports on OpenBSD. ports(7)
and pkg_add(1) are two good places to start, and you should also take a look
at the official ports webpage - http://www.openbsd.org/ports.html)

10a. There are a number of other highly useful packages/ports that I use all
the time. My /var/db/pkg (see the man page for pkg_add(1)) looks like this
(you may or may not want all this stuff installed; I use most of it at one
time or another):
----
[sfrancis@allanon:~]$ ls /var/db/pkg
ImageMagick-5.2.9          gtk+-1.2.10p1              nmap-3.00
abcde-2.0.3                hping-2.0.0rc1             openmotif-2.1.30.5
aterm-0.4.2                http_load-20020104         pcre-3.9
autoconf-2.52p0            id3ed-1.10.4               png-1.2.5p1
bash-2.05b-static          imlib-1.9.14               procmail-3.22
blackbox-0.65.0            ispell-3.2.06              qt2-3.2
bzip2-1.0.2                jbigkit-1.2                rsync-2.5.6
cdparanoia-3.a9.8          jpeg-6b                    rxvt-2.6.4
colorls-3.2                lame-3.93.1                screen-3.9.13
curl-7.10.3p1              lcms-1.08                  silc-client-0.9.11
enlightenment-0.16.5       libao-0.8.3                sing-1.1p1
esound-0.2.28              libaudiofile-0.2.3         sirc-2.211
eterm-0.8.10               libghttp-1.0.9             stunnel-4.04
ethereal-0.9.11            libiconv-1.8               t1lib-1.3.1
fetchmail-6.2.0            libmng-1.0.4               tiff-3.5.7
fnlib-0.5                  libnet-1.0.2a              transfig-3.2.3d
freetype-1.3.1             libogg-1.0                 unzip-5.50
gaim-0.59.8-esd            libungif-4.1.0b1           vorbis-tools-1.0
gdk-pixbuf-0.21.0p1        libvorbis-1.0              waimea-0.4.0
gettext-0.10.40p1          libxml-2.4.28              wampager-0.9.1
ghostscript-7.05           libxml1-1.8.17             wget-1.7p1
gkrellm-1.2.13p1           metaauto-0.1               xmms-1.2.7
gle-3.0.4                  mpeg_lib-1.3.1             xmms-esd-1.2.7
glib-1.2.10                mpg123-0.59r-esd           xmms-mp3-1.2.7
glut-3.7                   mplayer-0.90rc4            xmms-vorbis-1.2.7
gmake-3.80                 mutt-1.5.4i                xpdf-2.01
gnupg-1.2.1                netpbm-9.24                xscreensaver-4.06
----

10b. You probably want to create your ~/.xinitrc (I then do 'ln -s ~/.xinitrc
~/.xsession'; I don't remember why at this point, but sometime in the past I
decided this was a good idea. YMMV.). I'm currently running waimea; check the
main page  for a tarball containing my waimea
config and other useful bits. Kudos to insane for turning me on to
waimea and giving me his config (witchblade!), and kudos to
http://hoopajoo.net/projects/bgcycler.html for having just exactly what I
needed! (Even though gkrellmbgchg came along later and made it unnecessary,
it's still a nice piece of work!)

----
[sfrancis@allanon:~]$ cat .xinitrc
#!/bin/sh

# set local font dir (system install required missing 'chkfontpath')
xset +fp $HOME/.fonts
# this may be necessary as well if I have a locale conflict
# export LC=C
# export LC_ALL=C

# faster repeat rate, slower delay
xset r rate 350 50

# start xscreensaver in daemon mode; reads from ~/.xscreensaver
xscreensaver >~/logs/xscreensaver 2>&1 &

# not needed in E
wampager &

sleep 1

# start gkrellm - TASTY!
gkrellm -w &

sleep 1

# start background cycler
~/bin/bgcycler -t 1800 -vsre ~/graphics/db/1600 > ~/logs/bgcycler 2>&1 &

# choose a wm
# if I don't explicitly set this stuff, waimea ignores it *shrug*
exec waimea --rcfile=~/.waimearc\
 --menufile=~/.waimea/menu\
 --stylefile=~/.waimea/styles/witchblade
#exec blackbox
#exec enlightenment
----

11. And that's pretty much it - you now have a dual boot laptop with OpenBSD
and a full fledged GUI interface available, with a graphical browser, and all
kinds of cool stuff. And your original Windows setup is still available,
unchanged, with somewhat less free space. :)

12. Got questions? Email me  - if I can answer
them, I'll post the answers here. I plan to have skeleton config files
available in a tarball at some point (.xinitrc, .waimea/, .enlightenment/,
.Eterm/, bgcycler, etc.) UPDATE: such a tarball is available! See the main
OpenBSD page .