7

I have a kext that I would like to be loaded at startup time. It doesn't need to be loaded particularly early in the process, but I would like it to be loaded before a user logs in.

The kext in question is InsomniaT, and, unlike a device driver, there is nothing that is automatically going to request that it be loaded into the kernel, so just putting it in /System/Library/Extensions won't do anything.

What's the best way to do this?

2
  • Why not add the kext to /Library/Extensions, set the permissions to 755 and the owner/group to root:wheel, and rebuild the kernel cache after loading it?
    – Chealion
    Commented Sep 26, 2009 at 20:36
  • My understanding is that it won't actually be loaded unless something requests it. So I can do that, but I'm still left with getting something to request it.
    – wfaulk
    Commented Sep 26, 2009 at 22:13

2 Answers 2

7

Use a launch daemon to run /sbin/kextload at start up.

You might want something along these lines... link text

2
  • your link is not valid Commented Aug 10, 2015 at 11:03
  • 1
    Thank's Mani. The dangers of posting links, eh?! wfaulk's answer below superuser.com/a/47373 describes the solution that the linked used to describe Commented Aug 11, 2015 at 11:28
15

Steve Folly's link is accurate, but to have it here:

Create a plist file (which is just a plain text XML document) named something like com.domain.identifier.plist in /Library/LaunchDaemons with contents similar to this:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>KeepAlive</key>
        <false/>
        <key>Label</key>
        <string>com.domain.identifier</string>
        <key>ProgramArguments</key>
        <array>
                <string>/sbin/kextload</string>
                <string>/System/Library/Extensions/MyExtension.kext</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>StandardErrorPath</key>
        <string>/dev/null</string>
        <key>StandardOutPath</key>
        <string>/dev/null</string>
        <key>UserName</key>
        <string>root</string>
</dict>
</plist>

(There's a manpage, launchd.plist(5) that specifies the syntax of LaunchDaemon plist files.)

I then converted it to a binary plist file just for some trivial syntax checking:

plutil -convert binary1 com.domain.identifier.plist

Then activate the LaunchDaemon to run at startup:

launchctl load -w /Library/LaunchDaemons/com.domain.identifier.plist

And check to make sure that it's in there:

launchctl list | grep com.domain.identifier

The LaunchDaemon should run at startup and load the kext.

2
  • 1
    plutil also has a -lint option for syntax checking, which is also the default option for no arguments.
    – paxswill
    Commented Jan 5, 2012 at 23:44
  • All above commands needs 'sudo' permisions. Commented Jan 18, 2023 at 11:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .