Using NetBSD 1.5 with Virtual PC 4

compiled by Paul Hoffman
Last updated April 26, 2001

This page describes how to use NetBSD version 1.5 with Virtual PC version 4 from Connectix. NetBSD is a free, mature, and very stable Unix operating system that is a widely-used alternative to Linux. Virtual PC is a wonderful commercial Macintosh product that allows you to run PC programs unchanged by emulating a full PC on your Mac. Virtual PC comes with Linux support, but not NetBSD support. This site fixes that. (If you are interested in other BSDs, there is a different site that explains how to install OpenBSD on Virtual PC.)

The information on this site assumes you already own Virtual PC version 4, and have a copy of a NetBSD 1.5 CD-ROM. This site does not explain much about how to run either product, only how to get them working together well. This site also doesn't describe how to get earlier versions of either product to work with each other. A different site created by David Hornsby describes how to use NetBSD 1.3.2 with earlier versions of Virtual PC.

Basically, NetBSD 1.5 out of the box works OK with Virtual PC 4. However, there are a few major problems, such as the fact that the Ethernet interface and the floppy drive doesn't work. Thanks to the hard work of Peter Seebach, you can fix this easily by copying a new kernel to your system after installing NetBSD 1.5. Thank you, Peter! Also, the folks at Connectix did a fair amount of work between version 3 and version 4 to make NetBSD work even though NetBSD is not officially supported by them. Further help was provided by Peter A. Eisch, who upgraded the XF86Config file to higher resolution.

Getting the Software

Virtual PC 4 can be bought at any fine purveyor of Macintosh products (my favorite continues to be MacConnection); the current street price is around $75 for the no-Microsoft-OS versions. Virtual PC version 4 seems to run significantly faster than version 3, so users of earlier versions of Virtual PC should probably upgrade. Virtual PC comes in many different flavors (for Win98, for Windows 2000, for Linux, etc.), and all of them work with NetBSD.

NetBSD is free. There are many ways to install NetBSD on a PC, the two fastest and most reliable being:
 - from a CD-ROM
 - over an Ethernet-based network after booting from floppy
Unfortunately, the Ethernet drivers on the installation floppies and CD-ROM for NetBSD 1.5 do not work with Virtual PC version 4. Thus, the only reasonable way to install a working NetBSD 1.5 is to install from CD-ROM, and then copy a new, better kernel onto your system. NetBSD 1.5 CD-ROMs can be bought many places; see the NetBSD CD-ROM list for information, or simply borrow a NetBSD 1.5 CD-ROM from a friend (that's both legal and friendly!).

Steps for Installation

The following steps assume that you have already installed Virtual PC 4 and understand how to run it (which is surprisingly easy, given how well it works). If you are unfamiliar with NetBSD, there is a ton of good information about it on the NetBSD web site. If you have never used a Unix system before, the steps below may be daunting or impossible to follow.
  1. Download the file VPC-NetBSD15.sit, which is a Virtual PC disk image that contains a better NetBSD kernel and other helpful files. The download is about 1 megabyte, and it expands to about 2.5 megabytes. Unstuff the file, and move the expanded file to the directory where you usually store your Virtual PC drive images.
  2. Start Virtual PC.
  3. Give the Window->Virtual Disk Assistant command. That command has a series of steps.
    1. You want to create a new drive.
    2. You want to create a hard drive image.
    3. Select a location and name for the image, probably where you keep your other Virtual PC drives.
    4. Select Linux for the operating system (even though you aren't going to use Linux).
    5. Select "Advanced Options", choose Fixed Space Drive Image, and select a capacity. 1 gigabyte can work for a basic installation and a reasonable amount of data, and 2 gigabytes is quite roomy even for a full installation with X Windows. Don't bother to zero the drive; it just wastes time. Note that you don't have to create a fixed space drive image; others have used a variable-size image with no problems. Making it a fixed-size image seems prudent because Connectix is much more focused on making the varible-sized images work with Windows-based operating systems.
  4. Create a new virtual PC. This also leads to a series of steps:
    1. Name this virtual PC.
    2. Choose "guide me".
    3. Give NetBSD as much memory as you feel comfortable with. 64 megabytes is probably plenty.
    4. You want to select a current drive for the boot system.
    5. Specify the drive you just created in the previous step.
    6. You want to add a secondary drive.
    7. Specify the drive that you downloaded from this site in the first step.
    8. NetBSD 1.5 has not been tested with the modem in Virtual PC, so you probably want to not select it.
    9. You probably don't want to try to sync your Palm with NetBSD.
    10. Select "Done".
  5. Insert your NetBSD 1.5 CD-ROM in your CD-ROM drive and make sure you can see it on your Mac desktop.
  6. In Virtual PC, select your new virtual PC and start it up. Because the hard drive image doesn't have an operating system on it, Virtual PC should attempt to boot off the CD-ROM. If it does not, be sure that Virtual PC thinks that there is a CD-ROM in the drive.
  7. The NetBSD 1.5 CD-ROM boots into NetBSD. Lots of messages about hardware (or, in the case of Virtual PC, pseudo-hardware!) zoom by. After a few fits and stops, the NetBSD installer starts, and you see:
    +***********************************************+
    * NetBSD-1.5 Install System                     *
    *                                               *
    * a: Install NetBSD to hard disk                *
    * b: Upgrade NetBSD on a hard disk              *
    * c: Re-install sets or install additional sets *
    * d: Reboot the computer                        *
    * e: Utility menu                               *
    * x: Exit Install System                        *
    +***********************************************+
    
    In the installer, you can use the arrow keys on the keyboard or letters.
  8. You are asked if you want to continue; you do.
  9. You see something like:
    I have found the following disks: wd0 wd1            
                                                         
    On which disk do you want to install NetBSD?  [wd0]: 
                                                         
                                    wd0: no disk label   
    
    You might not see the "wd0: no disk label" notice; that's OK. If the first line does not list both wd0 (the new drive you created) and wd1 (the small drive you downloaded), stop immediately. Otherwise, enter "wd0" and press Return.
  10. You are shown some unintelligible numbers that describe your hard drive. Select "a: This is the correct geometry".
  11. You can share NetBSD with another OS on the drive image, but do so at your own risk. Instead, choose "b: Use the entire disk".
  12. You are asked:
    Your disk currently has a non-NetBSD partition.  Do you really want to
    overwrite that partition with NetBSD?                                 
    
    Answer yes, you really want to do that.
  13. Here you get to make a decision about how must space you want to fill on your hard drive with NetBSD. Plain NetBSD takes up about 350 megabytes; NetBSD with some X stuff (although not including popular X desktops such as KDE and GNOME) takes up about 450 megabytes. Virtual PC 4 runs X Windows fairly well (see below), and if you think you might want to install X in the future and have enough room, go ahead and install it now.
  14. You are presented with a partition table that will make almost no sense unless you have set up a Unix system before. The installer program usually makes very good guesses, so simply choose "b: Partitions are ok ".
  15. You can pick a name for your disk, but the name is inconsequential; feel free to use the default of "mydisk".
  16. You are warned that continuing will wipe out the contents of your hard drive; yes, you want to continue.
  17. You see a screen that has something like the following at the top:
         Status: Running                                                       
        Command: /sbin/newfs /dev/rwd0e                                        
                                                                               
    ---------------------------------------------------------------------------
    /dev/rwd0e:     3362688 sectors in 3336 cylinders of 16 tracks, 63 sectors 
            1641.9MB in 209 cyl groups (16 c/g, 7.88MB/g, 1984 i/g)            
    super-block backups (for fsck -b #) at:                                    
    
    Lots of numbers get displayed, Depending on the size of your drive and the speed of your system, this may take a while.
  18. When the disk preparation is done, the installer says "The next step is to fetch and unpack the distribution filesets. Press return to proceed.". Press Return, of course.
  19. You can choose a full or custom installation. If you choose "custom", you'll get to pick with sets of binaries to install. However, unless you are really tight on space, simply choose the full installation. The NetBSD folks don't install much fluff in the basic installation.
  20. There is no need to watch all the names during installation; they go by very fast anyways.
  21. You will be installing from CD-ROM.
  22. The default choices for CD-ROM installation are:
     device:         cd0 directory:  /i386/binary/sets 
    
    You can continue with these settings.
  23. Your CD-ROM and hard drive will access a lot as all of the files for the installation are loaded on your hard drive. Across the top of your screen, you will see:
         Status: Running                                       
        Command: pax -zrpe -f /mnt2//i386/binary/sets/base.tgz 
    
    (with different names for the last bit of the second line). Feel free to walk away for a bit.
  24. The installer tells you that it was successful; press Return.
  25. The installer makes device files, which takes a while. When it is done, press Return.
  26. Pick your time zone. Note that NetBSD assumes that the system clock (that is, the Mac's clock) is set for GMT, which it is not. You can deal with this either by chooing GMT from the time zone list (which means that programs that look at the time zone will think you are in the GMT time zone) or you can set the correct time zone and then keep adjusting the NetBSD clock. Neither is a good option, but you have to pick one. Press x then Return after you have chosen your option.
  27. You want to pick a root password now.
  28. You should now be back at the original installation menu. You don't want to reboot your computer quite yet; first, want to remove the CD-ROM. In Virtual PC, choose the Control->Eject CD command, and take the CD from the drive. Now you can select "d: Reboot your computer".
  29. The rebooting process looks like the initial booting process, except that much of the text is in green. When the computer is booted, you see:
    NetBSD/i386 (Amnesiac) (ttyE0) 
                                   
    login:                         
    
    Enter "root" (without the quotes, of course). When prompted, enter the root password.
  30. You now have a C-shell prompt. Enter the command "mount /dev/wd1e /mnt" to mount the small drive image you downloaded.
  31. You can verify the contents of the drive with "ls -l /mnt". You will see that there are three files:
    -rw-r--r--   1 root  wheel     5138 Jan 23 10:03 XF86Config         
    -rw-r--r--   1 root  wheel     4591 Jan  6 12:45 low-res.XF86Config 
    -rwxr-xr-x   1 root  wheel  2329634 Jan  6 10:21 netbsd             
    -rw-r--r--   1 root  wheel    42616 Jan  6 10:22 vpc-patch-03       
    
  32. Make a backup copy of your current kernel with the command "cp /netbsd /netbsd.original"
  33. Copy the new kernel to your main system with "cp /mnt/netbsd /netbsd".
  34. If you're planning on using X Windows, give the command "cp /mnt/XF86Config /etc" to copy the X configuration file to your main drive.
  35. If you think you might want to rebuild the kernel yourself at some point in the future, give the "cp /mnt/vpc-patch-03 ." command to copy the patch file to your home directory.
  36. Reboot with the "reboot" command. This will start with the new kernel.

Networking

By default, Virtual PC assumes that you have a DHCP server to give you an IP address. However, some folks want or need to have a fixed IP address.

Using DHCP addresses

To get NetBSD to get an address from your local DHCP server, edit the /etc/rc.conf file. Add the line
dhclient=YES
auto_ifconfig=NO
to the end of that file, then reboot.

Using a fixed IP address

To get NetBSD to use an assigned address (which must be different than the IP address used by your Mac!), you have to tell NetBSD the address and the interface to use. The patched kernel uses the tlp0 driver for the Ethernet. In the /etc/rc.conf file, add the following lines:
dhclient=NO
auto_ifconfig=YES
Create the file /etc/ifconfig.tlp0 that has one line:
inet 40.50.60.70 netmask 255.255.255.0
where "40.50.60.70" is your IP address. Create the file /etc/mygate that has a single line that contains the IP address of your Internet gateway. Create the file /etc/myname that has the host name of this machine in it. Reboot, and you should be on the net.

X Windows

Virtual PC emulates an S3 screen driver. To run X Windows, copy the XF86Config file from the drive image you downloaded into /etc. If you run startx now, you will get a tiny screen with really, really big pixels. Instead, install the XF86Setup package and run that setup program. There, you can specify the screen driver (S3) and the resolution you desire. Virtual PC works just fine in 1024x768 full-screen mode on a PowerBook. (If you are not familiar with the NetBSD package system, you should be! See the pkgsrc manual for more information.)

Note that resolutions over 1024x768 are currently not working correctly due to a quirk of the clock chip emulation; they work in Windows, but you have to use the BIOS to change modes, and XF86 just tries to make the chip do the work directly. There is no problem using 1024x768 with 256 colors, but it does not work with more colors than that.

Also note that the XF86Config file is specifically designed for 1024x768 adapters. If you have an 800x600 adapter (such as for the iBook), you need to modify the XF86Config file. Near the bottom of the file, there is a section that has a bunch of entries like:

Subsection "Display"
	Depth 32
	Modes "1024x768"
EndSubsection
Edit them to say "800x600" instead.

Patching the Kernel

If you don't already know how to build a kernel, you probably don't want to spend your time on something that is more arcane than rebuilding a car's engine. If you already know how to patch a kernel, patching the NetBSD kernel is easy, and you want to apply the patches for Virtual PC before you create a new kernel.

To get the kernel source tree, mount the CD-ROM on /mnt (using "mount -t cd9660 /dev/cd0a /mnt"). Unpack the kernel source with "cd /; tar -xzf /mnt/source/sets/syssrc.tgz"; this will take quite some time.

When the source is unpacked, you can apply the patch you copied into your home directory above with "cd /usr/src/sys; patch <~/vpc-patch-03". This patches a wide variety of files and creates a VPC configuration.

The following steps are all you need to build a new kernel.

  1. cd /usr/src/sys/arch/i386/conf
  2. (muck with the VPC configuration if you dare)
  3. config VPC
  4. cd ../compile/VPC
  5. make depend
  6. make
  7. cp /netbsd /netbsd.works.ok
  8. cp netbsd /
  9. reboot

Known Problems Remaining

The following is a list of the problems that are know to exist with the setup described above.

If you encounter other problems, or want to help solve the ones above, please contact Paul Hoffman.