Archive for January, 2011

If you have a triple boot mac mini with OS X, Windows and Linux it might be useful to run OS X inside VirtualBox when Linux or Windows is running.

VirtualBox officially supports OS X Server as guest vm and runs as well other OS X versions as guest. – If Linux runs on a second (external) hard disk the first harddisk can be assigned to a virtualbox vm as raw device. And OS X should boot as guest (of type OS X server). However booting a vm with EFI instead of BIOS is still work in progress. With virtualbox 3.2.12:

  • limited screen resolutions
    (VBoxManage setextradata "VM name" VBoxInternal2/EfiGopMode N, N=0,1,2...4)
  • only first ide hard disk is bootable
  • overrides installed boot manager, e.g. rEFIt; and settings done by OS X start volume utility are completely ignored (missing virtualized hardware)
  • sometimes crashes in libata (ide disk access); maybe not related to efi boot

EFI boot can be disabled in system settings of the guest vm. But then you need a BIOS bootloader for the OS X kernel like Chameleon which seems to be a very active project.

  • chameleon could be installed to the disk containing OS X – but I prefer an unmodified disk
  • so chameleon should boot from cdrom

There are many cdrom iso images with chameleon online, but none met my needs:

  • boot leopard and snow leopard
  • boot from apple hardware but inside virtualbox
  • do not use hackintosh kext patches, except disabling native apple power management with Disabler.kext (else the guest uses 100% cpu)
  • screen resolution of guest vm be be selected in boot menu

The chameleon boot loader (2.0 RC4 r684) has lots of usage setups. But many of them are only documented by their source code.

  • the stage 2 loader of chameleon, boot, is in multiboot format
  • it can be chain loaded by syslinux mboot.c32
  • mboot.c in chameleon source reveals 3 command line arguments:
    biosdev=80 (or 81 for second hard disk, …)
    partno=2 (for second partition)
    timeout=5 (autostart after 5 seconds)
  • multi boot “kernels” may have “modules” (=initial ramdisk in case of linux kernel); chameleon uses a dmg image whith boot parameters and kext kernel modules
    – dmg format: compressed, with mbr partition, hfs+ filesystem in partition 1
    – /Extra/com.apple.Boot.plist defines boot parameters
    – /Extra/Extensions/ contains kext modules
  • isolinux.cfg example:
    kernel /mboot.c32
    append biosdev=80 timeout=1 partno=2 /boot --- /p800x600.dmg
  • com.apple.Boot.plist entry for Display resolution
    <key>Graphics Mode</key>
    <string>1280x1024x32</string>
  • com.apple.Boot.plist entry for verbose mode
    <key>Kernel Flags</key>
    <string>-v</string>
  • the dmg image can be opened inside OS X

Based on this information osxboot.iso is a bootable cdrom image with

  • boot menu (syslinux based) to choose between
    800×600, 1024×768, 1280×1024
    and, if set as custom resoltions in virtualbox guest vm,
    1400×1050, 1440×900, 1920×1050, 1920×1200
    (VBoxManage setextradata "vmname" CustomVideoMode1 1920x1200x32)
  • boot menu to select silent or verbose boot
    (chameleon allows to add other flags)
  • default boot from second partition of first hard disk
    (which can be edited during boot)
  • OS X 10.5, leopard, or OS X 10.6, snow leopard, on apple hardware, running as virtualbox guest:
    – only kext module Disabler.kext (part of chameleon distribution) is loaded (allows cpu sleep mode for vm guest)
    – leopard runs only inside a 64 bit version of virtualbox (tested with linux)
  • EFI has to be disabled in the system properties of the virtualbox guest
  • Seems to run stable if the hard disk inside the vm is attached to the virtual SATA hard disk controller
    (to access raw devices Use Host I/O Cache must be enabled for the SATA controller!)

The chameleon boot loader has been patched to set display resolution and verbosity as multiboot arguments:

  • resx=800 (defines horizontal resolution)
  • resy=600 (defines vertical resolution)
  • verbosity=0 / verbosity=1 (sets verbosity: -v flag)

Google, howto isolinux, should give answers how a bootable isolinux cdrom image can be created.

Known bug: “About this Mac” system information crashes.

Software used for this article: SPBLinux 2.4 live cd

In case you want to access usb attached storage media from a virtual machine (vm) running inside virtualbox there are 3 choices:

  1. Make the usb connection available to the vm.
  2. Make a shared folder to access data on the usb storage device.
  3. Give the vm direct access to the usb disk.

Using a shared folder has the advantage that configuration is straight forward (menu Device/Shared folder …). But

  • the host must handle the filesystem used on the usb storage device
  • the guest must have guest additions installed
  • performance is a bottleneck

Usb inside guest also has performance drawbacks.

So it is worth to fiddle with the command line to get direct access to disk partitions.

  • ls /dev/disk*
  • this displays all disk partions seen by OSX
  • in case finder displays the partition to be used by the vm (that is, OSX has automatically mounted this partition) you have to deactivate this partition with the OSX disk utility program
  • VBoxManage internalcommands createrawvmdk -filename yourpath/newdisk1.vmdk -rawdisk /dev/disk1
  • this creates a vmdk file which can be opened by virtualbox disk manager; this file gives access to disk1
    Use host I/o-Cache has to be enabled for the controller of this disk!

If the vm cannot be started because of disk access error the partitions of disk1 have to be deactivated again with the hard disk utility program.

The system disk /dev/disk0 would need root access rights; other disks can be accessed as user.