Knowledge: Getting Familiar With Kexts and Your Hackintosh

This entry is part 1 of 3 in the series Kext Knowledge

The following was all written by FreeBurma one of our very knowledgeable commenters and someone I’ve been working with to bring you guys a perfect retail install which will be unveiled in the coming month. It will be important to know all of this stuff if you would like to persue the Boot-132 method because it is not for the inexperienced user. With that said I would highly recommend reading this series to get in touch with your inner geek and for nothing more for some knowledge on what you are doing. Although the reading may seem daunting FreeBurma has actually done an excellent job of making a very complex concept easy to understand. Happy Readings!

Please comment on if any of these if they helped you and on what you would like to read more of!

It’s incredible that we can have the “it just works” simplicity of MAC OS X on our Dell laptops.  Inspiron 1525 guides like the ones found here make every effort to provide an approachable, non-intimidating, method for installation and maintenance.  Other sources of information, like certain famous forums and wikis can be frustrating at best and send all but the most persistent running for the nearest Windows or Ubuntu disc.

It is impossible to list all of the software that make a Hackintosh possible and the developers who put tremendous time and effort into them.  The boot loaders, drivers, bios emulators, utilities and the rest are improving all the time, getting us closer to the ultimate goal of a clean, vanilla, updatable and easy install.

Unavoidably, these tools and guides can obscure what is going on; what is removed, replace or copied; leaving the user with an incomplete understanding of what has been installed, removed, or modified.  When things go wrong users don’t have the ability to recover and continue from a known working configuration.  Additionally, distributions such as iPC install modified software and add components without the user being directly aware of what’s been changed from a generic system and leave your system littered with .orig folders.  To get the most from your system, enjoy stress free updates, and keep things running smoothly you need some skills and the willingness to take on tasks that Apple never intended to be part of the customer experience.

When installing MAC OS X on any non-apple hardware the addition, replacement and removal of Kernel extensions is unavoidable and missteps are the source of much pain for all concerned.  The goal of this informational guide is to provide some foundational background knowledge and the skills to be able to backup and install kernel extensions in a way that moves beyond the press the buttons in this order approach.

This will be too simple and incomplete for some and bewilderedly complex for others.  If you’re an experienced Hackintosh builder, please forgive the simplifications  and feel free to comment so as to help others.  If your system is working fine and you don’t want to change a thing, well then, carry on, we’ll be here if you need us.  The ability to use the terminal and basic shell commands (cd, ls, cp, mv, and the like) is assumed.

If you are really curious and want more information than is appropriate for this site, the apple developers connection has in-depth information covering all of this material and much, much more.

Extensions, the nickel tour

The MAC OS X operating system provides the ability to dynamically load pieces of code into the kernel.  This allows the OS to support a wide range of hardware such as different video chips or networking devices without having to have a custom compiled kernel for each possible configuration or a big bloated kernel with everything for everyone built in.  In MAC OS X these are called kernel extensions or Kexts.  You can think of them as drivers, but they also provide functionality beyond what a driver traditionally does.

Extensions run as part of the kernel (known as kernel or supervisor mode) and as such do not have the restrictions imposed on non-kernel mode code.  A kernel extension can do anything including reaping havoc, stopping your system from booting, or cause frequent kernel panics.  Bad things can happen if you’re not careful!

When installing extensions, you should consider were it came from, what it is intended to do or fix, and what you are going to do if it breaks your system.  Think in terms of the carpenters adage: “measure twice, cut once” and consider your back-out plan (see below).

Structure

Extensions, at the highest level are special folders known as bundles.  The finder sees these as a single entity.  To have a look inside right click and select  ‘Show Package Contents”.

All extensions must have a property list and most have a binary and other resources. They generally looks like this:

SomeExtension.kext
|
-> Contents

|

-> MacOS

|

| ->  Kext Binary

|

-> Resources

|

| -> Resource files (often in folders by language)

|

-> PlugIns

|

| -> (Other, nested extensions)

|

-> property list (info.plist)

Not every extension has all of these things and some have other items, this gives you a general idea of what’s inside.

The property list, among other information, importantly contains the official name (bundle identifier) and version information for the extension.  This is important as newer versions will override older ones with the same official name.

Official names look like this com.apple.iokit.IOHDAFamily.  The name of the bundle is not relevant.

Extensions that have only a property list and no executable code are sometimes called Legacy Extensions or Injectors in Hackintosh speak.

Extensions can be grouped together in a nested series of bundles.  For example: if you are looking at a ‘vanilla’ 10.5.7 installation and you are asked to find the AppleYukon2.kext, were would you find that?  If you look in ‘/System/Library/Extensions’ you’re not going to see it there.  So were is it?  It’s in the PlugIn folder inside IONetworkingFamily.kext.

Locations

Extensions most often reside in two (three for us Hackintosh folks) potential locations:

/Extra/Extensions – this is a Hackintosh specific location and the Chameleon boot loader will look at and load these extensions first, overriding extensions in other locations.

/System/Library/Extensions – this is the ‘system’ location and all of the normal apple and third party provided extensions reside here.

/Library/Extensions – this, rarely used location is used for application specific extensions.  Most common for the Hackintosh user; some CPU temperature and speed monitoring utilities will place an extension in this location.

The Extensions Archive

MAC OS X can load extensions from an extension archive (often also called the extensions cache) which is always named Extensions.mkext.  This is one part of why MAC OS X boots quickly even if the boot cache is invalid (see next section).

The archive resides just “outside” the respective extensions folder; for example:

‘/System/Library/Extensions.mkext’ is for ‘/System/Library/Extensions’

‘/Extra/Extensions.mkext’ is for ‘/Extra/Extensions’

The archive contains the extensions required to provide basic hardware functions from the corresponding Extensions folder.

The system will always try to keep the ‘/System/LIbrary/Extensions.mkext’ archive up-to-date (the kextd is responsible for this, incase you wanted to know).  If you add an extension, it will update the cache immediately and automatically.  In other words, if the last modified time-date stamp on the extensions folder is more recent than the archive, the system will update.  This automatic update doesn’t work with ‘/Extra/Extensions’.

The Boot Cache

When the system first boots it tries to load the kernel from a pre-linked version of the kernel in the folder ‘/System/Library/Caches/com.apple.kernelcaches’.  This pre-linked version is the kernel with all the extensions needed to support your setup all ready baked in and gives you a fast boot.  If the system knows things have changed, it will then look to the Extensions archive(s) and failing that look at individual extensions and then recreate the boot cache.

When installing and modifying extensions in the Hackintosh realm, sometimes the system doesn’t get the message and will boot from the cache ignoring changes that it is unaware of.  This is covered in slightly more detail below, but this is what the ‘-f’ Chameleon boot flag is all about, it tells the system to ignore the boot cache and load up all the extensions as required and then create a new boot cache.

Series NavigationKnowledge: Getting Your Hands Dirty with Terminal»
  1. Tom says:

    Hey. I ask you about some problem.
    There are Bluetooth USB adapters, I mean, they look like flash usb pendrives, but they are bluetooth things. I realize you know what is it, and I am looking as a foul.

    Well, I have some of this, and my Inspiron 1525 doesnt have bluetooth integrated. So there arent drivers for Mac, but I think there is some way to make a driver (kext) for Mac, for this blueetoth, or any, knowing what system profiler says. What do you think about of this? possible or not? I am programmer, may I learn about of it… But if it isnt that easy (knowing devices location and more to configure it), i wouldnt try.

    ReplyReply
  2. Tom: Hey. I ask you about some problem.
    There are Bluetooth USB adapters, I mean, they look like flash usb pendrives, but they are bluetooth things. I realize you know what is it, and I am looking as a foul.Well, I have some of this, and my Inspiron 1525 doesnt have bluetooth integrated. So there arent drivers for Mac, but I think there is some way to make a driver (kext) for Mac, for this blueetoth, or any, knowing what system profiler says. What do you think about of this? possible or not? I am programmer, may I learn about of it… But if it isnt that easy (knowing devices location and more to configure it), i wouldnt try.

    Most bluetooth devices should work by installing the bluetooth fix on this page http://macyourpc.com/2009/05/30/common-problems-on-dell-inspiron-1525-hackintosh/

    ReplyReply

  3. mr turnip says:

    just wondering how the boot-132 is going ?

    i’m trying to get 10.5 going on a vostro 1200 (which looks quite similar to the 1525 with gm965 and x3100). and not having any luck with the generic or BOOT-KABYL-BUMBY :(

    ReplyReply
  1. There are no trackbacks for this post yet.

Leave a Reply


Mac Your PC is Digg proof thanks to caching by WP Super Cache