Sunday 27 February 2011

Another Virtualised OS-X Example

In case this is copied, go to the original site which should be http://philatwarrimoo.blogspot.com/2011/02/another-virtualised-os-x-example.html

To see if my first virtualised OS-X was a fluke, I'll have another go. This will just list the steps I take and there won't be much discussion.

>VBoxManage internalcommands listpartitions -rawdisk /dev/sda
Number Type StartCHS EndCHS Size (MiB) Start (Sect)
1 0xee 1023/254/63 1023/254/63 200 1
2 0xaf 1023/254/63 1023/254/63 119102 409640
4 0x83 1023/254/63 1023/254/63 11444 244330976
3 0xaf 1023/254/63 1023/254/63 23167 343011768

The OS-X partition I want is Number 2: type is 0xaf and the size is about right.

I have found my first fault: I created the vmdk file in VB 3.2.8. Under VB 4.0 the '-register' option is no longer used. VB 4.0 has a '-relative' option for Linux hosts that would make sense to use, but 'relative' and 'register' are too different for it to be a typo.

My source used '-register' so VB 4.0 must be different.

>VBoxManage internalcommands createrawvmdk -filename /home/phil/.VirtualBox/HardDisks/osxpart1.vmdk -rawdisk /dev/sda -partitions 2RAW host disk access VMDK file /home/phil/.VirtualBox/HardDisks/osxpart1.vmdk created successfully.

I should point out that the name of the vmdk file that I used is from the viewpoint of OS-X, not the actual partition number - use your own naming scheme.

The '-register' option adds the new vmdk file to the list of hard disks available - looks like I'll have to register manually somehow.

I added an entry in the VirtualBox.xml file for the new hard disk like this:
I got the UUID from the osxpart1.vmdk.xml file - I used the uuid.image number for the uuid attribute.

That did the trick.

I created a new VM, called it maxosxp1 and VirtualBox automatically selected Mac OS X - nice.

I told it to use the new osxpart1.vmdk file that I just created and left everything else as default for the time being.

I tried to run it, and it didn't work. But I have found that you need to do this to populate the XML or VBOX file to make the next steps easier.

Note: in VB 4.0, the file is now in VirtualBox VMs/(machine name)/(machine name).vbox. It is still an XML file so you can edit it with a text editor - but as before only when VirtualBox is not running.

To make it boot I need to add in the special Apple SMC key.

I added these to the ExtraData section:

<ExtraDataItem name="VBoxInternal2/EfiBootArgs" value=" "/><ExtraDataItem name="VBoxInternal2/EfiGopMode" value="4"/><ExtraDataItem name="VBoxInternal2/SmcDeviceKey" value="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"/>

I then started the VM.

It was slow to boot, but it got there. As it was loading I could see VMWare and VirtualBox kernel extensions loading and I thought that it will not like that - running a VM manager in a VM.

It wanted me to identify my keyboard and that was it.

I logged in, hit (shift)-(right command)-F to enter fullscreen mode.

Apart from being slow and running warm, it looked like I was running OS-X on a PM rather than a VM.

To solves the high CPU load problem, just delete the right kernel extension.
sudo rm -fr /System/Library/Extensions/AppleIntelCPUPowerManagement.kext
I haven't done that yet as I might want to boot into this partition sometime soon to tidy it up.


So, no fluke.

No comments:

Post a Comment

Please use family friendly language.