Monday, September 21, 2009

Snow Leopard 64 bit kernel on a MacBook5,1


I was playing around with Snow Leopard today and for no better reason than "It's neat" I decided to try and boot into the 64 bit kernel. Apple has left the default kernel, on non server editions, to default to 32 bit. Many people have complained about this stating it's slower and can't access > 4GB of memory and can't run 64 bit apps correctly etc etc. Well it's all a little bit of FUD. Apple also included the 64 bit kernel ability but defaulted it to 32 mainly to avoid 3rd party software/drivers/kexts that rely on the 32 bit kernel. Windows Vista 64 had similar issues with drivers etc. And while in 32 bit kernel mode applications can still run in 64 bit mode just fine, without any type of 64 to 32 virtualization. So right now there really is no reason, for most, to run in 64 kernel mode other than "It's neat".

If you'd like to try, and have a 64 bit cpu with 64 bit EFI (Core 2 duo / Xeon), simply reboot/turn-on and hold down the '6' and '4' keys. If it works your computer will boot a little bit slower as it makes the switch (if you set it to always boot in 64 bit mode you wont see this delay). You can check wether it worked or not by either checking the kernel process in the Activity Monitor or type
  uname -a
in the terminal. The result will end in 'x86_64' if it worked. Or you can also click the 'Apple' and go to 'About This Mac' and click the 'More Info...' button. From there click the 'Software' group towards the bottom. The line that says '64-bit Kernel and Extensions' should say 'Yes'.







If it didn't work then you may be lucky like me and have a MacBook or Air etc. Apple has black-listed these and deemed it an option only available for the elite Pros (MacBook Pros, MacPros...and XServes). But you can still try it thanks to this guy, Amit Singh. It's been a while since I've had to use a hex-editor for something like this but it was fun :)

0xED, and Hex Fiend are both good...

Basically I followed his post pretty close. Simply made a copy of /usr/standalone/i386/boot.efi (I called it boot64.egi) as   /System/Library/CoreServices/boot64.efi
Then opened it with a hex editor and adjusted the 'black-flag' bit value for my corresponding machine.
(I didn't have to chown the file or chflags as my copy was already set)
Then blessed it with
  sudo bless --folder /System/Library/CoreServices --file /System/Library/CoreServices/boot64.efi
This sets the newly modified .efi to be used during boot.

After that you can now use the '6' + '4' and the '3' + '2' options while booting/restarting.

I also set mine to always load using the 64 bit kernel, again for no better reason than "it's neat-o". This can be done by editing the file
  /Library/Preferences/SystemConfiguration/com.apple.Boot.plist
And change this
  <key>Kernel Flags</key>
  <string></string>

to this
  <key>Kernel Flags</key>
  <string>arch=x86_64</string>


Now Snow Leopard will boot by default with the 64 bit kernel, you can still hold down the '3' + '2' to boot using the 32 bit kernel.


Problems:
I'm running on a pretty fresh install of Snow Leopard and haven't done a whole lot of testing yet. But so far most things run great. 32 bit applications still function fine in their 32 bit modes as well. The only application that hasn't worked so far is VMWare Fusion, but this may change with the next version or so. VirtualBox does indeed work with the 64 bit kernel though so I will be trying that out with Windows 7 in the next few days.

2 comments:

123 123 said...

Nice blog as for me. It would be great to read a bit more concerning that topic.
By the way look at the design I've made myself Companionship in London

javieth said...

I must to say i love the snow, the cold climate, although i´m not a child anymore i remember my happy childhood and all the beutiful time that i spent with all my friends. Now when is snowing i prefer to spend my time with my boyfriend, most of all that he decided to buy viagra, we enjoy all the time.