Mac OS X… Running on Linux VM Ware

For those of you who missed Justy’s comment to my post about running The Fordora Core under VM Ware on Mac OS X… Here it is! How to get a (slightly doggy) copy of Mac OS X running under VM Ware on an Intel Linux box!

Thanks Justy!


Originally posted here.

This may not be exactly the best follow up comment but for the lack a another place to post, I’ll put it here. I too have been playing around with virtual machines, in my case VMware under linux and also under windows. However my situation differs due to the fact that the guest OS is OSX!

Well we all know OSX is now shipping on Intel’s x86 architecture, and about time too! Mac users (and I’m not one) have long had no option but to buy over priced hardware with little to no choice. Maybe the move to Intel hardware will open the “hardware market” up for the Mac User, or maybe Steve Jobs has something sinister up his sleve? We can only speculate as to the impact it will have on hardware availability, content management, and ultimately the rights and flexability the end user gets.

So with all this in mind I’ve been curious to see if I could get OSX running on on my x86 P4 supercomputer (initally under VMWare which fakes x86 hardware). After much investigation, trial and error, I finally got it to work. Here’s a installation guide based on my experience:

1. First acquired via bit-torrent (or what ever method) OSX (with SS3 pacth) MacOSX_10.4.6DVDPATCHED_Myz.iso - read below first!

SSE3 is an new set of CPU machine instructions only available on the very latest PC Intel CPU’s and of course on MAC Intel CPU’s. OSX is compiled to use the SSE3 instruction set, so of course if your CPU doesn’t support SSE3 then OSX wont work!……but along came Maxxuss (OSX cracker) who created a binary patch for the OSX kernel. As far as I can tell it simply emulates the missing SSE3 instruction set, rendering
the OSX kernel usable on non-SSE3 compilent CPU’s.

So find out if your CPU is SSE3 compilent, if not you will need a patched OSX kernel, which is what I needed for my Extreme 3.7GHz P4. The file I used was acquired via bit-torrent and was named: MacOSX_10.4.6DVDPATCHED_Myz.iso
From the name you can see that it’s pre-patched, how nice of the publisher :) Otherwise you just need a standard MAC x86 installer.

2. Apon booting the DVD installer, you arrive at the Darwin bootloader (normally hidden when booting on a MAC). Select “custom install”, then you type: -v
which will boot the disk in verbose mode. The boot sequence at this point looks very similar to Linux or BSD (which made me felt at home), heaps of text rolling up the screen and a few errors in relation to hardware detection. If all goes well, you arrive at the installer GUI screen.

3. You will now need to format a disk, the obvious choice is “HFS Plus Case sensitive with journaling” haha! Forget that, it doesn’t work? The install I did was in VMware, whether that impacted the formatting process, I’m not sure. Anyway “HFS Plus Case sensitive” worked, so I ran with that!

4. Continue with the installation GUI and finally it should ask you to reboot.

(Picture of install screen…quite funny)
http://share.brixtonjunkies.com/install.jpg

5. After the smooth install process and rebooting I landed on a boot error at startup: saying “b0 error”. Turns out this simply means the newly installed partition hasn’t been marked as bootable. The error reminded me of when the MBR is currupted in Linux and LILO (an older style Linux boot loader) says: “LI” and then fails to boot! Anyway the simple solution to this was to boot OSX in single user mode (feels a bit like linux again) by booting off the install disk.

To do this:
Select “custom install” and then at the boot prompt type -s
Eventually you will arrive in a root shell (no password required? this is dodgy!)

Then type: fdisk -e /dev/rdisk0 (assuming /dev/rdisk0 is the disk you installed on)

If you then “print” the partition table you should see your new partition, only it wont be marked as bootable (* beside the partition)
You can mark it bootable by using the “flag ” command within fdisk. Mine was partition 1.

Once you have saved the modification to the disk partition you are ready to reboot again!

6. If all went well you should be running through the basic OS setup in a GUI ie: time, date language etc…
Something weird happen on my first boot after the basic setup, the OS crashed and then I rebooted and it crashed again saying something
about the airport driver (which is kind of expected given this machine didn’t have wireless). A boot to single user mode and a
fsck on the disk, then a reboot and system came back up :)

Post Install Notes:
1. After a full install I was able to add journalling to the disk with the basic MAC GUI disk tool.
2. There was only 1024×768 available under display options and my LCD screen was of course 1280×1024. This was quickly fixed by adding 2 lines to the boot loader configuration file /Library/Preferences/SystemConfiguration/com.apple.Boot.plist:

Graphics Mode
1280×1024x32

(Picture of boot config file)
http://share.brixtonjunkies.com/graphics.jpg

Summary:
————

All in all, for a system that is not designed to “install” on standard Intel PC Hardware, it’s certainly not far off. The following is needed to make the installer more generic:

1. Fix the installer to assume at worst that there will be a blank generic disk.
2. Fix the “marking” of the MBR to point to the newly installed partition and/or give the user the option in the GUI installer.
3. Some MAC components ie: “The Airport” etc may in fact be non-existant on a generic Intel base PC system, hence handle the non-detection
gacefully.

(Picture of non-SSE3 cpu running OSX)
http://share.brixtonjunkies.com/cpu.jpg

That’s it :P
Alchemist

Perl to check Drive Space

Well the server filled up again and as lead developer on he project it was left to me to sort it… so I wrote this Perl script to run under cron to send me an alert when the disk usage goes about 90%.

To use it just run the script with the path to the mount point of the drive you want to check:
./myScript.pl myMount

Here’s the code (obviously replace the prints with however you want to be notified):


#!/usr/bin/perl

use strict;

my $mountPoint = shift;

my $cmd = "df -h | grep " . $mountPoint;
my $result = `$cmd`;
my @lines = split("\\n", $result);

foreach(@lines) {
	if ($_  =~ m/([0-9]{1,3})%/) {
		if ($1 > 90) {
			print "it's getting full in here!\\n";
		} else {
			print "it's all good!\\n";
		}
		exit;
	}
}

print "Couldn't find mount point!\\n";

In other news… that project I was working on still isn’t finished.

HTTP Uploads with cURL and AppleScript

Here is a quick example in AppleScript of how to use the ‘curl’ program to upload a file to a website/cgi. As far as the web server is concerned a user is sending it a file via an html form.

Firstly here is the HTML form that we will be faking an upload from:


<form action="upload.php" method="post">
	<input name="myFile" type="file" />
	<input name="submit" type="submit" id="submit" value="Submit" />
</form>

Now, here’s the curl command we’re going to use to fake the upload:

curl -F "myFile=@/my/file.txt" http://ws.com/upload.php

Notice how the name of the form field that represents the file to be uploaded (’myFile’) is in the curl parameters!

And finally here is the AppleScript code to do the whole thing:


property uploadForm : "http://ws.com/upload.php"

on run
	set x to choose file
	tell me to open (x)
end run

on open theseFiles
	if class of theseFiles is not list then
		set theseFiles to {theseFiles}
	end if

	repeat with i from 1 to count of items of theseFiles
		set posixPathOfThisFile to POSIX path of
			(item i of theseFiles) as string
		my uploadFile(posixPathOfThisFile)
	end repeat
end open

on uploadFile(theFile)
	set theCMD to "curl -F \"myFile=@" & theFile & "\" "
		& uploadForm
	do shell script theCMD
end uploadFile

Domino’s Vs. Pizza Hut: Weekend Development (or Late Night Development part 2)

pizza boxes

While Domino’s is almost certainly the fresher and (probably) the more healthier of the two, does ay one else ever get the feeling that their doe keeps on rising in their stomach? I don’t know why but I do know that after a Domino’s pizza I am always left feeling bloated and slightly sick…

On other news, Late Night Development has become weekend development and carbonated spirits have been replaced with carbonated beverages. When I woke up this morning I had an internal monologue as if I was part of a fly on the wall documentary about the project I am working on and my comments were being played over film of me getting ready to go into work… I have to find new ways to get excited about my work…

Yeah…

Thai, Taurine and Tiredness: Late Night Development

thai take away
Having worked to 10:30 last night only to get back to work at quarter to nine this morning, I again find myself in a room stinking of Thai food and full of developers.

My contribution to this project is largely over… only it has to talk to a Flash app which means that I have to be on call for the Flash Developers who are working the weekend as they are sailing close to the proverbial wind. This means that I can sit here feeling shattered while blogging how shattered I feel… while occasionally adding the odd XML attribute.

All being well I’ll be heading home soon… I’m starting to think in XML tags, which can’t be good.

Oh, and taurine is the active ingredient in Red Bull.

Dilbert FTW

Dilbert Cartoon