[Université Paris Diderot, INRIA]

Pierre Letouzey

Emulators: OpenDarwin via pearpc

If you're not coming from there, please check first my main emulation page, and in particular its DISCLAIMER section.

This page describes the emulation of a OpenDarwin PPC system using the PearPC emulator.

PearPC

I'm using PearPC 0.4.0:

apt-get install pearpc
Nota: if you're using 64-bit mode on an AMD64, then pearpc will use a different (and much slower) emulation mode. I advise you to install pearpc in a 32-bits chroot for instance.

For the impatients

You can fetch my ready-to-run OpenDarwin image:

opendarwin-pearpc-0.1.tar size:346Mb
opendarwin-pearpc-0.1.md5
opendarwin-pearpc-0.1.md5.asc PGP sign of MD5

Then do typically:

md5sum -c opendarwin-pearpc-0.1.md5
gpg --recv 9E4A9C9D --keyserver subkeys.pgp.net
gpg --verify opendarwin-pearpc-0.1.md5.asc opendarwin-pearpc-0.1.md5
tar -xf opendarwin-pearpc-0.1.tar
cd opendarwin-pearpc-0.1
cat README
./extract  ##you need qemu-img to be installed (see qemu distr)
./run
And enjoy !

For building the image yourself

Fetch the OpenDarwin iso

wget http://www.opendarwin.org/downloads/7.2.1/OpenDarwin-7.2.1.iso.bz2
md5sum OpenDarwin-7.2.1.iso.bz2   ## should be 1a19bbf9bcec0dec0dfa7d9b19a4840f
bunzip2 OpenDarwin-7.2.1.iso.bz2

Create a sparse image file

For instance for 3Gb:

dd if=/dev/zero of=opendarwin-pearpc.img seek=3220955136 count=1 bs=1
This file seems to occupy 3Gb on disk, but actually takes only a few kb for the moment on clever filesystems (ext2/3 for instance). After the installation, it will take around 1Gb.

Another way is to use qemu-img with RAW format, see qemu distribution. This program can also be used to compress and uncompress raw files without losing their "emptyness".

PearPC configuration

See config file ppc.conf

The official way of using networking in pearpc is via a direct access to tun/tap. Then some setuid-root scripts are supposed to configure the network on-the-fly. I really don't like this approach, both for security and pratical reasons. But you can dupe pearpc and redirect it in fact to VDE (see more on VDE):

mkdir scripts
ln -s /bin/true scripts/ifppc_up.setuid
ln -s /bin/true scripts/ifppc_down.setuid
export VDEALLTAP=/var/run/vde/tap0.ctl
export LD_PRELOAD=/usr/lib/libvdetap.so
Be sure to have both a subdirectory scripts and the two shell variables VDEALLTAP and LD_PRELOAD when you run pearpc.

OpenDarwin Installation

At the location of .img .iso .conf files and scripts dir, run

ppc.real ppc.conf
Nota: ppc.real is a Debian trick, elsewhere it should be ppc directly.

Then follow instructions from http://pearpc.sourceforge.net/installdarwin.html Ok, it's for Darwin, but OpenDarwin is close enough.

If the keyboard becomes weird: Ctrl-Alt-Shift. If the mouse is captured: F12.

When the installation is completed, "withdraw" the cdrom before starting pearpc again: set pci_ide0_slave_installed to 0 in ppc.conf. Normally, you should eventually end on a login prompt...

Post-installation

You probably want to run this once:

ssh-keygen -t rsa1 -f /etc/ssh_host_key
ssh-keygen -t rsa -f /etc/ssh_host_rsa_key
ssh-keygen -t dsa -f /etc/ssh_host_dsa_key
emacs /etc/sshd_config ##and allow PermitRootLogin and PasswordAuthentification

Then after each boot you can configure the network and start sshd for allowing a remote login:

ifconfig en1 192.168.1.2
route add default 192.168.1.1
sshd

I've not found yet a convenient way of saving this configuration. Here is the trick I use:

  • first, download in your virtual machine a dhcp archive, for instance this one. Without wget nor a proper dns configuration yet in the virtual machine, I suggest using scp for the final transfer. Then:
    tar -xf dhcp-3.0.3.tar.gz
    cd dchp-3.0.3 && ./configure && make && make install
    
    Now the manual network configuration can be replaced by a call to dhclient...
  • To run this dhclient and sshd each time, you can add a starting script:
    cd /System/Library/StartupItems/
    mkdir StartMynetwork
    emacs StartMyNetwork/StartMyNetwork
    
    Then edit this file in this way.
    chmod +x StartMyNetwork/StartMyNetwork
    emacs StartMynetwork/StartupParameters.plist
    
    Then edit this file in this way.

I still have a lot of unfinished business with OpenDarwin, but it's already quite usable...

Appendix: Howto do without networking

For information, it's possible to survive without network. For instance you can use the cdrom device for file transfert to the virtual machine:

  • mkisofs -f my.iso my_files_to_transfert
  • start pearpc with this iso as cdrom (cf ppc.conf)
  • inside darwin: mkdir /cdrom && mount -t cd9660 /dev/disk1s0 /cdrom

Even better, it's possible to directly mount the image file under linux:

  • Load HFS+ in linux: sudo modprobe hfsplus
  • sudo mount pearpc-opendarwin.img /mnt/somewhere -t hfsplus -o loop,offset=32768

The offset allows to skip 64 blocks of 512 bytes, in order to reach the interesting partition. Read-write mounting seems possible.