Darwin VM

Distribution files

  1. Darwin 8.0.1 (corresponding to Mac OS X 10.4) seems to be the latest available full installer image, at least, until the PureDarwin project produces a new one.

  2. More recent versions of packages are available in source form:

Installing

  1. Download and extract installation CD image:

    • Darwin 8.0.1 (was under “Darwin 8.0.1 Installer CD” on old website)

      • MD5: dbd260dda994093a11c31afbe624aa34

      • SHA-256: a26f9f14795fe0687bd647d41b712464c9a61430736fae4aa0fdb89207e1a62a

    • $ gunzip darwinx86-801.iso.gz

  2. Set up QEMU VM:

    • $ qemu-img create -f qcow2 darwin.qcow2 10G

  3. Start VM:

    • $ qemu -net none -drive file=darwin.qcow2,cache=writeback -cdrom darwinx86-801.iso -boot d

    • Other useful qemu options: -m 512 and -enable-kqemu

  4. Installation steps:

    • First boot:

      • Select disk

      • "2" (manual partitioning)

      • "y" (initialize MBR)

      • In fdisk:

        • > auto hfs

        • Ignore the warning

        • > update

        • > write

        • > quit

      • Enter partition name

      • "yes" (clean install)

      • "darwin" (volume name)

      • Continue (reboot)

    • Second boot (make sure to boot from CD again):

      • Select disk

      • "3" (existing partition)

      • Enter partition name

      • "hfs" (HFS+ filesystem)

      • "yes" (clean install)

      • "darwin" (volume name)

      • Wait for installation to complete...

      • Enter root password

      • "darwin" (hostname)

      • "3" (spawn shell)

      • # halt

  5. Configure VM for normal startup:

    • Remove QEMU flags -cdrom darwinx86-801.iso -boot d

Basic configuration

Enable VM networking

SSH access

  1. Change QEMU flags: -net user-net user,hostfwd=tcp:127.0.0.1:10022-:22 (pick any port instead of 10022)

  2. Log in to VM, enable SSH:

    • # service ssh start

  3. Connect to VM with

    • $ ssh -p 10022 root@localhost

  4. Optionally add an alias to host ~/.ssh/config to simplify connecting:

    • Host darwin-vm
      HostName localhost
      Port 10022
      User root
    • Connect to VM with

      • ssh darwin-vm

  5. Install public key to simplify logging in:

    • $ cat .ssh/id_rsa.pub | ssh darwin-vm 'mkdir .ssh; cat >>.ssh/authorized_keys'

  6. Add -nographic to QEMU flags to disable console window, which is no longer required

Some familiar aliases

Timezone

Temporary filesystem

Using a temporary disk image to build software helps keep the main disk image file smaller.

  1. $ qemu-img create -f qcow2 scratch.qcow2 10G

  2. Add QEMU flag: -drive file=scratch.qcow2,cache=writeback and boot

  3. Figure out which disk number corresponds to the scratch drive:

    • # mount

    • # ls /dev/rdisk*

    • It's the one that isn't mounted and doesn't have any partitions (sn-suffixed files)

    • It's usually, but not always, /dev/rdisk1

  4. # newfs_hfs -v scratch /dev/rdisk1

  5. # reboot

  6. Available as /Volumes/scratch on next boot

Notes

  1. The VM sometimes fails to boot with "panic(...): nfs_boot_init failed"; if this happens, restart it.

Updating the system

Kernel (xnu)

Standard library (Libc)

Upgrading GCC

dyld

cctools

gcc