Gentoo Wiki


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc


What is PearPC

PearPC is a PowerPC emulator for Posix and Windows. PearPC's project page claims that PearPC is capable of running most OS's that run on the PowerPC architecture. As far as I know PearPC is the only PowerPC emulator available. Other MacOS emulators emulate the M68k.

What will you need?

Emerge PearPC

If you don't already have a /etc/portage directory, create one now:

Code: Creating a /etc/portage directory
# mkdir /etc/portage

Now add an entry to the /etc/portage/package.keywords file:

Code: Adding app-emulation/pearpc to /etc/portage/package.keywords
# echo "app-emulation/pearpc ~x86" >> /etc/portage/package.keywords

Edit your /etc/make.conf file and add "jit" to your USE flags. This will enable the x86 JIT "processor" to PearPC (33 times faster).

Now that you have enabled emerge to build PearPC for you, emerge it:

Code: Emerge-ing PearPC
# emerge pearpc

Hopefully that built fine (it did for me).

Setting up your virtual computer

Everything in this section will assume the you have downloaded files into ~/pearpc and that will be the working directory for all your files.

Create a virtual harddrive

Now we will create a harddrive that you can use in your new virtual computer.

We will use the utility "dd" for this operation. dd works by creating a "direct dump" of a file and places it into another. In this case we will use dd to make a direct dump of the "zero" device and have it copy 3 or 6 Gb worth of zeros.

Create a 3Gb virtual HDD:

pearpc$ dd if=/dev/zero of=3gigharddisk.img bs=516096 seek=6241 count=0

Creating a 6Gb virtual HDD:

pearpc$ dd if=/dev/zero of=6gigharddisk.img bs=516096 seek=12482 count=0

You'll notice that in the above examples, we are using "/dev/zero" as the In File "if",
and that we are using 3gigharddisk.img and 6gigharddisk.img as the Out Files "of".
Notice now that the Block Size "bs" that we are using is 516096: this represents the number of bytes to copy over in one chunk.
Finally the seek tells dd to skip this number of blocks in the output file until it starts writing, then the count is how many blocks to copy.

This is a weird convention, but I imagine it's faster than copying and writing that many blocks: faster to allocate and not use than to initialize 3 or 6gb worth of data.

Aquiring your OS

In this step you unfortunatly have few choices. Mandrake is a free choice, but it probably won't work; besides there is little point to emulating linux in linux unless you are developing cross platform software and need a test bed. Darwin is a free choice and you can download the Darwin 7.0.1 Install CD. Mac OS X is a non-free choice, and if I had a copy, or the money to get one, I would ;)

Setting-Up your installation Medium

PearPC is capable of reading a CD Image from any file. With the Darwin example you must gunzip the file you downloaded.

Code: gunzip darwin-701.iso.gz
pearpc$ gunzip darwin-701.iso.gz

Note that you might need to use a iso instead of a CD. If you need to you can create an iso from any CD in your cd drive:

Code: Creating a iso from a CD
pearpc$ cp /dev/cdrom ./cdimage.iso

This command takes advantage of the fact that all devices are files in Posix.

Configuring PearPC

Copy the example configuration file from /usr/share/doc/pearpc-0.3.1/ppccfg.example

Code: Copy the pearpc example config
pearpc$ cp /usr/share/doc/pearpc-0.3.1/ppccfg.example ./darwin.config

In this case I will be finishing the installation using Darwin.

Edit the IDE device section of the darwin.config file. This can be found by this header:

File: darwin.config
#	PCI IDE Config
#	Drive type will be set according to file extension:
#		.img: Harddisk (filesize must be multiple of 516096)
#		.iso: CD-Rom
#	Or you can override this by specifying the type via
#	pci_ide0_master_type / pci_ide0_slave_type

darwin.config: (Harddrive image)

pci_ide0_master_installed = 1
pci_ide0_master_image = "/home/hpux/pearpc/3gigharddisk.img"
pci_ide0_master_type = "hd"

darwin.config: (CD Image)

pci_ide0_slave_installed = 1
pci_ide0_slave_image = "/home/hpux/pearpc/darwin-701.iso"
pci_ide0_slave_type = "cdrom"

Running Darwin

Trying it out

Maybe it just works!

Code: Giving it a try
pearpc$ ppc darwin.config

If everything went well a window will pop up with an apple image:

If everything goes really well darwin will boot:

Partitioning your virtual harddrive

If you got this far then type in "shell" to drop into a shell:

Code: Dropping into a Shell
The following devices are available for installation:
1. EIN GEBUSCH! @ disk0 (3.0 GB)
Enter 'shell' to drop into a shell
Which device would you like to install Darwin onto? shell

Now run 'pdisk' to partition the harddisk:

Code: Run pdisk to partition the harddisk
sh-2.05b# pdisk

We need to edit the device map of the virtual drive:

Code: edit the harddisk map
Top level command (? for help): e
Name of device: /dev/disk0

Now that we have specified the drive we need to specify geometry.
Hit 'i' and enter each time to confirm the default values.
Now, hit 'p' to print the current partition map. Remember the value for the "Apple_Free Extra" partition length Type "C" to create a partition in the free space. Keep the value of "64" for the start partition, then use the number you remembered as the length of the new partition. Name this partition "Darwin" and specify "Apple_HFS" as the type. Finally type in "w" to commit the changes to the partition table. and "q" twice to exit.

Reboot Darwin

Code: Reboot Darwin
sh-2.05b# reboot

Now, if your window closed and didn't re-open then you need to re-start PearPC

Code: Re-Start PearPC
$ ppc darwin.config

This time when it asks which device you want to install darwin onto...

Code: Select your newly created partition as a target
The following devices are available for installation:
1. EIN GEBUSCH! @ disk0 (3.0 GB)
Enter 'shell' to drop into a shell
Which device would you like to install Darwin onto? 1
Which partition would you like to install into:
0) /dev/disk0s4 Apple_HFS Max_OS_X
Your choice: 0
WARNING: answering yes here will destroy all data on the partition
Would you like to do a clean install? (yes/no) yes

Now you will find that you need to wait a while :) When that operation completes it'll ask you if you want to reboot, do so. The PPC window will close.

Now we need to "remove" the CD from your virtual CD-ROM.

pci_ide0_slave_installed = 1
pci_ide0_slave_image = "/home/hpux/pearpc/darwin-701.iso"
pci_ide0_slave_type = "cdrom"


pci_ide0_slave_installed = 0
pci_ide0_slave_image = "/home/hpux/pearpc/darwin-701.iso"
pci_ide0_slave_type = "cdrom"

Now, restart your darwin "computer" and login. There is a root user and no password.

Installing OS X (10.3)

Partitioning your virtual drive

The OS X partitioner has been know to create unbootable partitions, but because it's a virtual drive there really is no loss, so give it a try!

If that doesn't work use the instructions in the darwin section to partition your disk.

Capture a CD Image from an OS X disk

NOTE: It is highly recommended that you compile your kernel with HFS file system support. Secondary to this, you may want to emerge hfsutils (masked) and hfsplusutils (if you want to actually see the contents of the discs).

dd if=/dev/cdrom of=./OSX_disk.iso

This (after a while) will give you an image of the OS X disk on your harddrive.

Now, edit the config file in the same way as we did in the darwin section, except this time you'll use the image of the OS X cd rather than the darwin image.

Start PearPC in the usual way:

Code: Start PearPC for OS X
pearpc$ ppc osx.config

If things go well you will be able to enjoy the OS X installer...

<< Work in progress... Stay Tuned. >>

Configuring Networking

Have tun as a kernel module. Your .config needs:-


As root (if you just added tun you'll have to rebuild your kernel)

modprobe tun
echo tun >> /etc/modules.autoload.d/kernel-2.6
cd /usr/share/pearpc-0.3.1

NB: version will change

In ifppc_up change:-


to addresses that won't conflict with your network.

Set the execute permissions of the start-up scripts so that users can execute them - or not if you only want root.

chmod u+sx,go+x ifppc_up.setuid
chmod u+sx,go+x ifppc_down.setuid
chmod a+rw /dev/net/tun

As your normal user:-

cd ~/pearpc

Edit darwin.config and set:-

pci_rtl8139_installed = 1

Create a symbolic link to the script directory:-

ln -s /usr/share/pearpc-0.3.1 scripts

And then run your emulated mac

ppc darwin.config

On your host machine you should be able to run

/sbin/ifconfig ppc

Then on the emulated machine

Need to set PPC_* from ifppc_up (see above)

ifconfig en1 $PPC_CLIENT_IP netmask $PPC_NETMASK up

You should be able to ping the host.

Retrieved from ""

Last modified: Fri, 05 Sep 2008 10:57:00 +0000 Hits: 27,680