1.Dd March 6, 2009 
2.Os Darwin
3.Dt KEXTUNLOAD 8
4.Sh NAME
5.Nm kextunload
6.Nd terminate driver I/O Kit driver instances and unload kernel extensions (kexts)
7.Sh SYNOPSIS
8.Nm
9.Op Ar options
10.Op Fl -
11.Op Ar kext Li \&.\|.\|.
12.Sh DESCRIPTION
13The
14.Nm
15program is used to terminate and unregister I/O Kit objects
16associated with a kernel extension (kext)
17and to unload the code and personalities for that kext.
18.Nm
19must run with superuser privileges.
20.Pp
21If another loaded kext has a dependency on the kext being unloaded,
22the unload will fail.
23You can determine whether a kext has dependents using the
24.Xr kextstat 8
25tool.
26.Pp
27.Nm
28is a formal interface for unloading kexts in the Darwin OS and
29in Mac OS X.
30Software and installers can rely on its presence
31and invoke it in order to unload kexts.
32Note that long options are present as of Mac OS X 10.6 (Snow Leopard).
33.Pp
34The arguments and options are:
35.Bl -tag -width -indent
36.It Ar kext
37Unload the loaded kext whose bundle identifier matches
38the CFBundleIdentifier of
39.Ar kext .
40All instances of IOService subclasses defined by the loaded kext
41and in the IOService plane of the I/O Registry are terminated;
42the kext is checked to make sure no instances
43of its libkern C++ classes remain;
44the kext's C++ static destructores and module stop routine are invoked;
45then the kext's executable and IOKitPersonalities are unloaded from the kernel.
46Failure at any stage prevents kext unload.
47.It Fl b Ar identifier , Fl bundle-id Ar identifier
48Unload executable and IOKitPersonalities (as described immediately above)
49for the kext whose CFBundleIdentifier is
50.Ar identifier .
51.It Fl c Ar classname , Fl class Ar classname
52Terminate all instances of class
53.Ar classname
54that are in the IOService plane of the I/O Registry,
55if possible,
56but do not unload the defining kext or its IOKitPersonalities.
57New load requests for devices that were driven
58by these terminated instances
59may result in the same class being instantiated at any time.
60.It Fl h , Fl help
61Print a help message describing each option flag and exit with a success result,
62regardless of any other options on the command line.
63.It Fl m Ar identifier
64Same as
65.Fl b
66(remains for backward compatibility).
67.It Fl p , Fl personalities-only
68Terminate services and remove personalities only;
69do not unload kexts.
70.It Fl q , Fl quiet
71Quiet mode; print no informational or error messages.
72.It Fl v Li [ 0-6 | 0x#### Ns Li ] , Fl verbose Li [ 0-6 | 0x#### Ns Li ]
73Verbose mode; print information about program operation.
74Higher levels of verbosity include all lower levels.
75By default
76.Nm
77prints only warnings and errors.
78You can specify a level from 0-6,
79or a hexadecimal log specification
80(as described in
81.Xr kext_logging 8 Ns No ).
82The levels of verbose output are:
83.Bl -tag -width "1 (or none)"
84.It 0
85Print only errors (that is, suppress warnings); see also
86.Fl quiet .
87.It 1 (or none)
88Print basic information about program operation.
89.It 2
90Prints information about unload stages.
91.It 3
92Prints information about removal of personalities.
93.It 4
94Prints information about module stop functions and C++ class destruction.
95.It 5
96Prints detailed information internal operations such as bookkeping.
97.It 6
98Identical to level 5 for
99.Nm .
100.El
101.Pp
102Unlike in other kext tools,
103the
104.Fl verbose
105flag in
106.Nm
107applies to all kexts
108(that is, it turns on hexadecimal bit 0x8 by default).
109See
110.Xr kext_logging 8
111for more information on verbose logging.
112.El
113.Sh DIAGNOSTICS
114.Nm
115exits with a zero status upon success,
116or prints an error message and exits with a nonzero status upon failure.
117.Sh BUGS
118Many single-letter options are inconsistent in meaning
119with (or directly contradictory to) the same letter options
120in other kext tools.
121.Sh SEE ALSO
122.Xr kextcache 8 ,
123.Xr kextd 8 ,
124.Xr kextload 8 ,
125.Xr kextstat 8 ,
126.Xr kext_logging 8
127