Computer Emulators

Basilisk II


Qemu is a powerful computer processor emulator that can be used to emulate x86, Sparc, and PowerPC processors, among others. Its most popular (and well-developed) use is, however, decidedly x86 emulation.

cd /usr/ports/emulators/qemu
make install clean

Optionally, if you want to build qemu with the qemu-accelerator kernel module, which will drastically increase qemu's performance in terms of x86-on-x86 emulation (if not, skip ahead):

make WITH_KQEMU=yes install clean

You will also have to install kqemu:

cd /usr/ports/emulators/kqemu-mod
make install clean

We then need to load the kqemu kernel module:

kldload kqemu.ko

To automatically load the kqemu kernel module every time your system starts up, add the following line to /boot/loader.conf:


Qemu is actually quite easy to use. To create a new virtual hard drive image, as user, type

qemu-img create -f qcow virtual_hard_drive.img 3G

This will create a Qemu formatted virtual hard drive image with a capacity of 3 GB named "virtual_hard_drive.img" in the current directory. Note that the image will not actually take up 3 GB--it will grow as the guest OS needs it.

Now that we have a virtual hard disk image, we have to install a guest OS. I tested this with an old copy of Windows 98 that I had laying around. Insert your install CD, then, assuming it is an ISO9660 CD (most are, unless this is an Apple CD-ROM), mount it:

mount /cdrom

Then start qemu:

qemu -cdrom /dev/acd0 -boot d virtual_hard_drive.img &

I'll explain what we just did. We launched the default qemu system (x86), and told it to use our computer's first CD-ROM drive as the guest OS's CD-ROM drive. You could also specify the path to an .iso image saved on your hard disk, i.e. "~/Win98.iso". "-boot d" tells the emulated system to boot from the CD-ROM drive (or the .iso image we specified). If you do not specify this option, the emulated system will attempt to boot from the virtual hard disk. Finally, we specified the path to our virtual hard disk. Because we executed qemu from the same directory we created our virtual hard disk ("virtual_hard_drive.img") in, we didn't need to specify a path.

This should boot from the CD-ROM, and take us into the Windows 98 installer. I'm not going to go through the steps of installing that OS--I'm assuming you can figure that out for yourself.

Another option you might like is to create a "shared folder" that will show up as a second hard drive in the guest OS, but will remain an ordinary directory on your system.

mkdir qemu_share

Then when we start up qemu, we can tell it to use the shared folder like this:

qemu virtual_hard_drive.img -hdb fat:rw:/home/reinholz/qemu_share &

Please note that you need to specify the full path to the shared folder, as I did in the above example. Also note that I mounted the shared folder with read & write support. Useful for exchanging files between the guest OS and the host system.

Alternatively, you could start up the guest OS with both a shared folder and CD-ROM support:

qemu virtual_hard_drive.img -hdb fat:rw:/home/reinholz/qemu_share -cdrom /dev/acd0 &

For a great variety of further options, "man qemu" and/or visit the Qemu User Guide. It contains a wealth of information and useful options.

Basilisk II

Basilisk II is a 68k Macintosh emulator. It can emulate Mac OS 0.x through Mac OS 8.1 depending on what ROM image you use.

Please note: you will need a ROM image from a Mac IIci or Quadra 900 (or perhaps some other models of similar vintage) in order to boot Mac OS in Basilisk II. Please don't ask me where to get one, because I don't know. Google is your friend.

cd /usr/ports/emulators/basiliskII
make install clean

Now that we've installed Basilisk II, it's time to launch it for the first time. Exit back to your user, then:

BasiliskII &

This will bring up a graphical configuration utility that looks something like this:

This is the "volumes" configuration tab. Click "Add" if you have a preexisting Basilisk II virtual hard disk image, or if you want to add a Macintosh floppy disk image, CD-ROM image (such as an .iso file), your physical CD-ROM drive, or (if you want to be able to share files between the emulated Mac OS system we're going to install and FreeBSD), your physical hard disk (/dev/ad0). If this is your first time running Basilisk II, or you want to create a new virtual hard disk to install Mac OS on, click "Create."

This is what comes up after you choose to "Create" a new virtual hard disk image. Navigate to whatever directory you want to create a new virtual hard disk image in, change the size if you want your virtual hard disk to be more than 40MB in size, and enter a name for your new virtual hard disk image. Then click "OK" to create the image.

We will then be back at this screen. Note that I added my physical hard disk (/dev/ad0) and an old Basilisk II virtual hard disk image that I created 3 or 4 years ago in the Windows 2000 version of Basilisk II.

I found the defaults for "SCSI", "Graphics/Sound", "Keyboard/Mouse", and "Serial/Network" to be quite reasonable. Before we continue, however, we need to change the settings under the "Memory/Misc" tab:

By default, the guest Mac OS system will have 8 MB of RAM. If you want it to have more, you'll want to change this. If you want to run Mac OS 0.x through Mac OS 7.x, choose "Mac IIci (MacOS 7.x)" for the "Mac Model ID". If you want to run Mac OS 8.0 or Mac OS 8.1, choose "Quadra 900 (MacOS 8.x)".

I found the default "CPU Type", "68030", to be quite reasonable.

Very important. We need to teach Basilisk II where our Macintosh ROM image is located. Click "Browse" under the "ROM File" and select your ROM image. (It might be something along the lines of "QUAD650.ROM").

Now we're ready to boot up our emulated Mac OS. If this is your first time running Basilisk II and you do not have a preexisting virtual hard disk image with Mac OS already installed on it, make sure you have your Mac OS boot CD or floppy specified in the "Volumes" tab before continuing. Ready? Click "Start" to launch the guest OS.

(Note: this is my emulated Mac OS 8.1 system). This message is in regard to my FreeBSD filesystem, which I specified under "Volumes". Just click "Cancel" because you obviously don't want to reformat your hard drive as FAT or HFS/HFS+.

Notice that my FreeBSD filesystem shows up as a second hard drive labeled "Unix" in the emulated Mac OS 8.1. Mac OS has read/write access to anything my user does. NOTE that this is a very important example of why you should NEVER run applications as su/root!


PearPC is a PowerPC emulator capable of running Mac OS X. Unfortunately, due to the hardware demands of that OS, it will run very slow on an x86 machine. Now that Apple has released Mac OS X for Intel (AMD64 architecture if I understand correctly), it will probably soon be possible to install the Intel version of Mac OS X in Qemu, which will obviously yield much better performance on x86 hardware. Nevertheless, if you want to install the PowerPC version of Mac OS X in an emulator, either because you want to play with a version of Mac OS X prior to 10.4, the first version to run on Intel processors, or because (like me) the only version of Mac OS X that you legally have a license to is for PowerPC, PearPC is the answer.

First things first, we have to install PearPC:

cd /usr/ports/emulators/pearpc
make WITH_OPTIMIZED_CFLAGS=yes WITH_JITC=yes install clean

Once we've installed PearPC, we need to create a virtual hard disk image for the guest OS. First exit back to your user, then

dd if=/dev/zero of=virtual_hard_disk.img bs=516096 seek=6241 count=0

This will create a 3GB virtual hard disk image to install Mac OS X on, which should be quite adequate for our purposes.

Next, we'll need a copy of Mac OS X. If you already have the copy that came with your Apple computer, this should be easy. Go find the install CD's or DVD. If not, don't ask me where to get a copy because I don't know.

Note: I had difficulty getting PearPC to recognize my Mac OS X install disc, possible due to the inability of FreeBSD to mount an HFS+ CD/DVD-ROM. The solution was to rip the install disc to an .iso file. As root:

cat /dev/acd0 > ~/macosx.iso

Where /dev/acd0 is your first CD/DVD-ROM drive. Note that you will get an error message when the command exits, but the resulting .iso will be usable. Make sure you exit back to your user after executing this command.

Before we can run PearPC, we need to create a config file for it to use:

cp /usr/local/etc/ppccfg.example ~/macosx.ppc

Then, we'll tweak the permissions on this newly created config file a little:

chown reinholz macosx.ppc
chmod u=rw,go=rw macosx.ppc

Now we get to edit our config file:

vi ~/macosx.ppc

First things first. Look for the following section:

pci_ide0_master_installed = 1
pci_ide0_master_image = "test/imgs/linux.img"
#pci_ide0_master_type = "hd"

And change the middle line to this:

pci_ide0_master_image = "/home/reinholz/virtual_hard_disk.img"

Where "/home/reinholz" is the path to your user's home directory, and "virtual_hard_disk.img" is the name of the virtual hard disk image we created for use with PearPC.

Next, find the following section:

pci_ide0_slave_installed = 1
#pci_ide0_slave_image = "e:\"
#pci_ide0_slave_image = "2,0,0"
pci_ide0_slave_image = "/dev/cdrom"
pci_ide0_slave_type = "cdrom"

And change this line:

pci_ide0_slave_image = "/dev/cdrom"

To this (if you want to use your computer's first CD/DVD-ROM drive):


Or, if you want to use an .iso image instead, to this:


Where "/home/reinholz" is the path to your home directory, and "macosx.iso" is the name of your Mac OS X install disc .iso image.

Next find the following line:

prom_driver_graphic = "video.x"

And change it to reflect the path to the driver:

prom_driver_graphic = "/usr/local/share/pearpc/video.x"

Note that if you have Qemu installed, you can use the driver located at "/usr/local/share/qemu/video.x" as well, which will also work with PearPC

(Optionally) if you want to change the amount of memory (RAM) allocated to the guest OS, find the following line:


Uncomment it, and change it according to your needs. Note that this default value is 128MB of RAM. Unless you are getting overflows past 9, you can simply multiply/divide this default hex value as you would any decimal, i.e. half of this default value is 0x4000000, which would be 64MB of RAM. This is the minimum amount of memory you can allocate to PearPC and still expect it to run.

Some common memory values include:

memory_size=0x4000000 (64MB of RAM)
memory_size=0x8000000 (128MB of RAM)
memory_size=0x10000000 (256MB of RAM)
memory_size=0x20000000 (512MB of RAM)

Save your changes and exit. Then, to start PearPC,

ppc ~/macosx.ppc &

Where your config file is located in your home directory and "macosx.ppc" is the name of your config file.