Removing "kext" kernel extensions

vikingshelmut

100% Bull Plop
Just wanted to ask everybody their thoughts regarding removing unnecessary kernel extensions from the "extensions" folder in os X. I've noticed extensions in there for ADB, SCSI, and other devices that I don't use, or ever plan on using. Is it save to remove a kext from the extensions folder? From what I understand, these are treated similar to extensions in 9, but I might be wrong. Are there other references to a kext in the system that could cause a problem when booting?

I might be wrong, but I just figured that at startup, the system looks in this directory, and if anything is present, loads it into the kernel. There is a lot of stuff in there that I don't need, so I want to get rid of it (backed up of course), to hopefully produce a smaller, more stable kernel (less kernel panics!).

Anybody test this out? Any negative results? Let me know!
 
Actually, looking at /etc/rc, it appears the cache should be rebuilt if anything in the Extensions directory is changed (the -ot part):

Code:
if [ ! -f /System/Library/Extensions.mkext -o \
     /System/Library/Extensions.mkext -ot /System/Library/Extensions ]; then
# rebuild cache here

So anytime anything updates the /System/Library/Extensions directory, a reboot should rebuild it.
 
Of course, since kernel extensions are only loaded on a need-basis, deleting them shouldn't affect performance much (only when rebuilding that cache).

To see what extensions are currently loaded, run

Code:
sudo kmodstat

According to my system, 63 are currently loaded.
Also, note, there are (on my system anyway) 104 .kext directories under /System/Library/Extensions but there are many more than this, as some kext's have kext's inside (ie, /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/IOUSBUserClient.kext).
 
Thanks for the quick responses. Some quick questions, though.

The rebuild cache process - this happens at every startup? If so, then this is theoretically like restarting 9 to unload an extension from memory (except that kext files arn't loaded in memory?)

So, why does apple have all these kexts installed on machines which don't require that kext. Shouldn't the installer be able to recognize that that new G4 Dual 1ghz you have on your desk doesn't have a freakin' ADB port?


Anybody actually test this out?
 
Might as well leave them in case you need them in the future. They don't take up much HD space, and OS X only loads them when needed.

Habits from using OS 9 are no longer useful. These extensions aren't like OS9's, where the fewer, the better.
 
When issuing this command from terminal, what user are you logged in as? When I try this from the command line (looged in as a user with admin permissions) the systems next response is <Password:>. When I type in my password it responses with <sudo: kmodstat: command not found>??!!

I used this command before when trouble shotting my Adaptec card! That was under 10.1.5. Would 10.2.4 make a difference?
 
Opps, it appears that the borad doesn't like you using left and right arrow.

Repost:
When issuing this command from terminal, what user are you logged in as? When I try this from the command line (looged in as a user with admin permissions) the systems next response is Password:. When I type in my password it responses with sudo: kmodstat: command not found.??!!

I used this command before when trouble shotting my Adaptec card! That was under 10.1.5. Would 10.2.4 make a difference?
 
Originally posted by stormbringer
Opps, it appears that the borad doesn't like you using left and right arrow.

Repost:
When issuing this command from terminal, what user are you logged in as? When I try this from the command line (looged in as a user with admin permissions) the systems next response is Password:. When I type in my password it responses with sudo: kmodstat: command not found.??!!

I used this command before when trouble shotting my Adaptec card! That was under 10.1.5. Would 10.2.4 make a difference?

Maybe not 10.2.4, but just 10.2.x... It doesn't work on my 10.2.3 machine either. The command under 10.2.? is kextstat. I'm not so sure that it's not loading up stuff that it doesn't need, though:


45 0 0x1dd80000 0x6000 0x5000 com.apple.iokit.SCSITaskUserClient (1.2.3) <38 36 5 4 3 2>
64 0 0x14f84000 0x6000 0x5000 com.apple.driver.AppleADBMouse (2.0.7d1) <15>


Could be that these contain code that is used by devices other than SCSI and ADB, so I'm not real interested in removing them just to "see what will happen", but I question their presence on my PowerBook...
 
I don't know if it is at all relevant to this case but FireWire is a SCSI derivative and it may well have common components in Apple's implementation. So just because you don't have a scsi card in your powerbook having the scsi module loaded may still make perfect since.

-Eric
 
That's true... I forgot about the SCSI/FW relationship.

I got curious about ADB, too, and I guess that on the 'Books, at least, the keyboard and trackpad are still ADB-esque. During early boot (well before disks even get mounted) there's a line in /var/log/system.log that reads "mach_kernel: ADB present:8c". Interesting...
 
Back
Top