- How to Load & Unload Kernel Extensions in Mac OS X
- Loading a Kernel Extension in Mac OS X with kextload
- Unloading a Kernel Extension with kextunload
- Load OS X kext in the early boot process
- 2 Answers 2
- How to Add and Remove Kexts from macOS
- Do Macs on Big Sur and Later Use Kexts?
- Where Are Kexts Found?
- How to Remove Kexts
- How to Install Kexts Automatically
- How to Install Kexts Manually
- Frequently Asked Questions
- 1. How do I access my Big Sur system extensions?
- 2. A system extension on my Mac is blocked. What should I do?
- 3. Are system extensions and kernel extensions the same?
- Wrapping Up
- How to Install Kernel Extensions in Mac OS X Manually
- Manually Installing Kext into Mac OS X
- Related
- Enjoy this tip? Subscribe to our newsletter!
- Thank you!
- Related articles:
- 11 Comments
How to Load & Unload Kernel Extensions in Mac OS X
Kernel extensions, called kext for short, are modules of code that are loaded directly into the kernel space of Mac OS X, able to run at a low-level to perform a variety of tasks. Most kexts are part of the core Mac OS X system software, typically hardware device drivers, but some third party apps will install a kext as well.
Sometimes, advanced Mac users and systems administrators may need to manually load or unload a kernel extension. Because kernel extensions are often critical components of MacOS, this is only appropriate for users who have a specific reason to be modifying whether a kext is loaded or unloaded into the MacOS X kernel space. Inappropriate modification of kext behavior can render Mac hardware useless or inaccessible, and can also prevent Mac OS X from functioning at all, so do not attempt to change any kernel extension without a compelling reason and understanding of what it’s usage is.
Loading a Kernel Extension in Mac OS X with kextload
To load a kernel extension into Mac OS X, you’ll need to use the command line kextload utility. The syntax is otherwise simple enough, requiring sudo for administrative access to perform the action:
sudo kextload /path/to/kext.kext
You can also use the bundle identifier (which are frequently the targets of defaults commands) with the -b flag:
sudo kextload -b com.apple.driver.ExampleBundle
Either way, hit return and with the entry of the administrator password the kernel extension will be loaded into Mac OS X.
You can confirm a kernel has been loaded by listing it with kextstat, using grep to search for the given name like so:
$ kextstat |grep com.apple.driver.ExampleBundle
125 0 0xdddddd7f23351040 0x5000 0x5000 com.apple.driver.ExampleBundle (1) 12 8 7 5 4 2 1
This can be helpful after manually installing a kernel extension into Mac OS X as in some situations it will prevent the need for rebooting the Mac.
Modern versions of Mac OS X also allow kernel extension loading to be completed with the kextutil command, which is a bit more full featured for debugging reasons, but is otherwise the same for loading a kext.
Unloading a Kernel Extension with kextunload
Unloading a kernel extension from Mac OS X is basically the exact same as loading a kext, except you’ll use the kextunload utility with sudo as follows:
sudo kextunload -b com.apple.driver.ExampleBundle
Or by pointing directly to the kernel extensions path:
sudo kextunload /System/Library/Extensions/ThirdPartyMystery.kext
Again, you can confirm the kernel extension has been unloaded by using kextstat and grep, where it should return nothing.
Источник
Load OS X kext in the early boot process
I have a working OSX kernel extension which I would like to be automatically loaded at boot time as early as possible. The kext is using KAUTH for monitoring access on a specific path so it seems to me there won’t be anything that will request it to be loaded into the kernel. In this case, copying it in /Library/Extensions (at least since Yosemite this is the recommended path for third-party extensions) won’t solve my problem.
Is there a possibility to achieve this, whether or not by modifying the code or through some auxiliary configuration?
I already read about using a launchd daemon to use kextload in order to load the extension, as specified in this question, but in my case, I want it to be loaded as early as possible.
Update:
I am using a «generic» kernel extension (linked against BSD library) and not an I/O Kit based one.
I want my extension to be loaded before launchd is started.
2 Answers 2
You don’t explicitly state it in the question, but I infer from the context that you’re using a «generic» kernel extension (in contrast to an I/O kit based one)? These are only loaded either because another kext depends on them, or because they are explicitly loaded via kextutil/kextload or the KextManager API.
Contrast this to I/O Kit kexts, which are loaded on-demand when one of their personality dictionaries matches a registered service in the IO registry. This is usually for driving specific devices, but various non-hardware-dependent system services use the mechanism to match the ‘IOResources’ nub (documentation) which turns up during early boot so any kexts listing it as a provider for a personality also get loaded on boot.
So the solution would be to modify your kext to provide an IOService which matches the IOResources nub. The service itself doesn’t really need to do anything if your userspace component already uses another interface to communicate with the kext.
Источник
How to Add and Remove Kexts from macOS
Kexts, or kernel extensions, expand the basic functionality of macOS’s Darwin kernel. They’re analogous to drivers under Windows, and they let the kernel communicate with your computer’s hardware. Most of the time, these files require no maintenance. But if you’re having problems, you may need to fiddle with a kext or two. In this article, you’ll learn how to add and remove Kexts on macOS.
Do Macs on Big Sur and Later Use Kexts?
Apple no longer recommends using kexts with your macOS device. To make thing worse, macOS Big Sur doesn’t even support some kexts; you can find a list of those here.
Where Are Kexts Found?
You can find kexts in two places on your Mac. Most live in the “System/Library/Extensions” directory, which is the primary home for kexts. Some are also found in the “/Library/Extensions” folder as well, but that’s less common.
You can recognize the files by their .kext extension as well as their plugin-style icon.
How to Remove Kexts
There are two ways to remove kexts. The first is by using the Terminal command kextunload .
1. Determine which kext you need to remove. Be absolutely certain you have the right one. Removing a system-critical kext can cause major problems, and kext names are often cryptic.
2. Open Terminal and enter the following command:
Make sure to change “kext.kext” to the name of your kext file. For example, if the kext you want to remove is named “AppleMobileDevice.kext,” the command would be:
3. After typing in your kext, press Enter, then type your administrator password and press Enter again.
If that fails to work, you can also just force-delete the kext using rm .
1. Use the following Terminal command to remove the kext file:
Make sure to change “kext.kext” to the name of your kext file. For example, if the kext you want to remove is named AppleIntelE1000e.kext, the command would be:
2. Enter your admin password and press Enter.
3. Restart your computer.
Also read: How to Install and Use wget on Mac
How to Install Kexts Automatically
The steps below to remove kexts will only work if you are using a Mac operating system prior to Big Sur and utilize the KextBeast utility that was initially created for use with Hackintoshes.
1. Download KextBeast. If you don’t have a free account with tonymacx86.com yet, you’ll need to create one to download the file.
2. Move the kext file you want to install to your Desktop. The program will automatically operate on any kext files in the “
/Desktop” directory, so make sure you have the right one.
3. Open KextBeast and click “Continue.”
4. Click “Continue” again.
5. Choose your system’s boot drive as the installation destination and click “Continue.”
6. Tick the box next to “/System/Library/Extensions” or “/Library/Extensions,” depending on where your kext needs to be installed. If you don’t know which one to pick, choose “/System/Library/Extensions.”
8. Click “Continue.”
9. Enter your administrator password and click “Install Software.”
10. Wait for the installation to finish and click “Close.”
11. Restart your computer.
How to Install Kexts Manually
If you use a Mac running on Big Sur or later, you’ll probably want to look at kernel extension alternatives. Apple recommends DriverKit and Network Extension, among other things.
Still, if you use an operating system earlier than Big Sur, kexts can be installed manually. It’s a more cumbersome process, however, and your Mac really doesn’t like you installing kexts like this.
1. Drag and drop your kext file into “/System/Library/Extensions”.
2. Click “Authenticate.”
3. Enter your admin password.
4. Open Terminal and use the command sudo kextload kext.kext to load your newly copied kext file. Make sure to replace “kext.kext” with the name of your kext file.
5. Enter your administrator password.
6. Restart your computer.
Also read: How to Enable the Root User on Mac
Frequently Asked Questions
1. How do I access my Big Sur system extensions?
Go to “System Preferences -> Extensions” to find extensions installed on your device – both native and third party.
2. A system extension on my Mac is blocked. What should I do?
Go to “System Preferences -> Security & Privacy -> General.”
In the bottom right of your window, you should see an “Allow” button next to the message: “System software from developer [Developer’s Name] was blocked from loading.”
Click on the padlock in the bottom left and enter your password, then tap on the “Allow” button.
3. Are system extensions and kernel extensions the same?
System extensions and kernel extensions were designed with the same end goal but work a little differently. Both aim to make background tasks on your Mac run more smoothly.
However, system extensions don’t work within the kernel (working instead like individual apps). Therefore, they don’t pose as much of a threat to your Mac if an issue arises.
Wrapping Up
You shouldn’t need to mess with kexts too often. And if your device runs on Big Sur or later, you’ll almost never need to install one.
If you do need to remove a kext at some point, you can use the Terminal to delete it without much trouble. And if you use an older Mac and need to install a kext, use KextBeast to simplify the process.
When it comes to macOS maintenance, something else you might occasionally need help with is deleting files that won’t delete the usual way.
Danny has been a professional writer for over five years. Now based in Copenhagen, Denmark, he plied his trade working for various companies in the UK — where he was born — before taking the leap into freelancing. He specializes in iOS and Mac.
Источник
How to Install Kernel Extensions in Mac OS X Manually
Advanced Mac OS X users may find it useful to know that KEXT (kernel extensions) can be manually installed. The process of installing kexts manually into OS X is not too difficult if you’re comfortable with the command line, but it is a multi-step process of copying the appropriate .kext file to the appropriate kernel extensions directory, and then using chmod and chown to assign appropriate permissions to the kext so that it will run as intended.
Manually Installing Kext into Mac OS X
You’ll need to use the Terminal to complete the kext install, this process is the same in all versions of OS X:
- Copy the .kext file(s) to /System/Library/Extensions/
- Open the Terminal and type:
- cd /System/Library/Extensions/
Type the following commands at the terminal, replacing the kext name with the one you are installing
sudo chmod -R 755 kextfile.kext
sudo chown -R root:wheel kextfile.kext
Now remove the kext caches:
sudo rm -R Extensions.kextcache
sudo rm -R Extensions.mkext
The kernel extension should now be installed. You can query a list of the active kernel extensions in OS X with the kextstat command to be sure, use grep to limit the results.
Similarly, you can remove an item from the same /System/Library/Extensions/ folder to uninstall a kext file, rebooting the Mac again for the change to take effect.
As you can see this is more time consuming than relying on an app installer to place a kext itself, and it’s a bit more complex than the alternative like Kext Drop, so ideally you’ll just one of the installer applications instead, because most kext files are coming from an application installer anyway, right? Nonetheless, if you can’t use an installer app or a kext modifier app for some reason to install a kernel extension, the manual installation method outlined above works great in all versions of OS X.
Related
Enjoy this tip? Subscribe to our newsletter!
Get more of our great Apple tips, tricks, and important news delivered to your inbox with the OSXDaily newsletter.
Thank you!
You have successfully joined our subscriber list.
Related articles:
11 Comments
Help, My mac is acting annoyingly, I can’t install hamachi because Hams.kext, Kamns.kext was not installed properly i tried searching how to reinstall them but no results, This method u gave to us does not work for me 🙁
Thanks for this Post. After my late 2011 macbook pro had the known GPU fault, i disabled some Extension (by copying them out of the extensions folder) to at least save my data before an official apple retailer repaired the motherboard on warranty.
After that, I still had slow bootup and strange graphical behaviour. I tried to re-install the extensions by moving the extension-files back, but nothing happened. I even had error messages after reboot, that some extensions could not be installed.
A “sudo kextload MyKext.kext” said something about missing file permissions. After some research on installing extensions manually I came upon this post and i compared the file-permissions and owners with other extension-files and saw, that they were different.
The chmod / chown commands as written in this post worked fine.
On Mac OSX Yosemite the kext-cache is located differently. The following post and these commands helped me recompile the kext-cache:
https://www.tonymacx86.com/threads/cant-boot-solved-with-rebuilding-cache-than-again-and-again.146259/
Commands:
sudo rm -r /System/Library/Caches/com.apple.kext.caches
sudo touch /System/Library/Extensions
sudo kextcache -update-volume /
[…] i came across this post on manually installing kernel extensions. However, I could not find the kext caches they […]
[…] for some reason the package installer fails, you can install the kext using the traditional manual installation method described here, though it’s a bit more advanced. Likewise, you can uninstall the kext that way, and if […]
So I just tried to do this on my MT Lion for my SSD drive, however I did not see the part about del the cache files…Im remote from my system at the moment and unfort logmein is now showing my system as offline so I have no idea what I will be seeing when I get home. Can I just del the cache files and all will be right or did I just screw myself…also I saved the ones I replaced on my desktop do I just copy them back to reverse things.
just use a nice hackintosh tool, this also works on real macs: Kextutility or Kext Wizard.
So I just tried to do this on my MT Lion for my SSD drive, however I did not see the part about del the cache files…Im remote from my system at the moment and unfort logmein is now showing my system as offline so I have no idea what I will be seeing when I get home. Can I just del the cache files and all will be right or did I just screw myself…also I saved the ones I replaced on my desktop do I just copy them back to reverse things.
I’ll stick with kext helper but thanks anyway
This is true unless the kexts are for hackintosh, in which case they are stored at
Instead of the System location
Actually, the latest version of Multibeast now installs all kexts to /System/Library/Extensions.
Источник