]> pere.pagekite.me Git - homepage.git/blob - blog/data/2013-01-14-hw-autoinstall-modalias.txt
Generated.
[homepage.git] / blog / data / 2013-01-14-hw-autoinstall-modalias.txt
1 Title: Modalias strings - a practical way to map "stuff" to hardware
2 Tags: english, debian, isenkram
3 Date: 2013-01-14 11:20
4
5 <p>While looking into how to look up Debian packages based on hardware
6 information, to find the packages that support a given piece of
7 hardware, I refreshed my memory regarding modalias values, and decided
8 to document the details. Here are my findings so far, also available
9 in
10 <a href="http://anonscm.debian.org/viewvc/debian-edu/trunk/src/hw-support-handler/">the
11 Debian Edu subversion repository</a>:
12
13 <p><strong>Modalias decoded</strong></p>
14
15 <p>This document try to explain what the different types of modalias
16 values stands for. It is in part based on information from
17 &lt;URL: <a href="https://wiki.archlinux.org/index.php/Modalias">https://wiki.archlinux.org/index.php/Modalias</a> &gt;,
18 &lt;URL: <a href="http://unix.stackexchange.com/questions/26132/how-to-assign-usb-driver-to-device">http://unix.stackexchange.com/questions/26132/how-to-assign-usb-driver-to-device</a> &gt;,
19 &lt;URL: <a href="http://code.metager.de/source/history/linux/stable/scripts/mod/file2alias.c">http://code.metager.de/source/history/linux/stable/scripts/mod/file2alias.c</a> &gt; and
20 &lt;URL: <a href="http://cvs.savannah.gnu.org/viewvc/dmidecode/dmidecode.c?root=dmidecode&view=markup">http://cvs.savannah.gnu.org/viewvc/dmidecode/dmidecode.c?root=dmidecode&view=markup</a> &gt;.
21
22 <p>The modalias entries for a given Linux machine can be found using
23 this shell script:</p>
24
25 <pre>
26 find /sys -name modalias -print0 | xargs -0 cat | sort -u
27 </pre>
28
29 <p>The supported modalias globs for a given kernel module can be found
30 using modinfo:</p>
31
32 <pre>
33 % /sbin/modinfo psmouse | grep alias:
34 alias: serio:ty05pr*id*ex*
35 alias: serio:ty01pr*id*ex*
36 %
37 </pre>
38
39 <p><strong>PCI subtype</strong></p>
40
41 <p>A typical PCI entry can look like this. This is an Intel Host
42 Bridge memory controller:</p>
43
44 <p><blockquote>
45 pci:v00008086d00002770sv00001028sd000001ADbc06sc00i00
46 </blockquote></p>
47
48 <p>This represent these values:</p>
49
50 <pre>
51 v 00008086 (vendor)
52 d 00002770 (device)
53 sv 00001028 (subvendor)
54 sd 000001AD (subdevice)
55 bc 06 (bus class)
56 sc 00 (bus subclass)
57 i 00 (interface)
58 </pre>
59
60 <p>The vendor/device values are the same values outputted from 'lspci
61 -n' as 8086:2770. The bus class/subclass is also shown by lspci as
62 0600. The 0600 class is a host bridge. Other useful bus values are
63 0300 (VGA compatible card) and 0200 (Ethernet controller).</p>
64
65 <p>Not sure how to figure out the interface value, nor what it
66 means.</p>
67
68 <p><strong>USB subtype</strong></p>
69
70 <p>Some typical USB entries can look like this. This is an internal
71 USB hub in a laptop:</p>
72
73 <p><blockquote>
74 usb:v1D6Bp0001d0206dc09dsc00dp00ic09isc00ip00
75 </blockquote></p>
76
77 <p>Here is the values included in this alias:</p>
78
79 <pre>
80 v 1D6B (device vendor)
81 p 0001 (device product)
82 d 0206 (bcddevice)
83 dc 09 (device class)
84 dsc 00 (device subclass)
85 dp 00 (device protocol)
86 ic 09 (interface class)
87 isc 00 (interface subclass)
88 ip 00 (interface protocol)
89 </pre>
90
91 <p>The 0900 device class/subclass means hub. Some times the relevant
92 class is in the interface class section. For a simple USB web camera,
93 these alias entries show up:</p>
94
95 <p><blockquote>
96 usb:v0AC8p3420d5000dcEFdsc02dp01ic01isc01ip00
97 <br>usb:v0AC8p3420d5000dcEFdsc02dp01ic01isc02ip00
98 <br>usb:v0AC8p3420d5000dcEFdsc02dp01ic0Eisc01ip00
99 <br>usb:v0AC8p3420d5000dcEFdsc02dp01ic0Eisc02ip00
100 </blockquote></p>
101
102 <p>Interface class 0E01 is video control, 0E02 is video streaming (aka
103 camera), 0101 is audio control device and 0102 is audio streaming (aka
104 microphone). Thus this is a camera with microphone included.</p>
105
106 <p><strong>ACPI subtype</strong></p>
107
108 <p>The ACPI type is used for several non-PCI/USB stuff. This is an IR
109 receiver in a Thinkpad X40:</p>
110
111 <p><blockquote>
112 acpi:IBM0071:PNP0511:
113 </blockquote></p>
114
115 <p>The values between the colons are IDs.</p>
116
117 <p><strong>DMI subtype</strong></p>
118
119 <p>The DMI table contain lots of information about the computer case
120 and model. This is an entry for a IBM Thinkpad X40, fetched from
121 /sys/devices/virtual/dmi/id/modalias:</p>
122
123 <p><blockquote>
124 dmi:bvnIBM:bvr1UETB6WW(1.66):bd06/15/2005:svnIBM:pn2371H4G:pvrThinkPadX40:rvnIBM:rn2371H4G:rvrNotAvailable:cvnIBM:ct10:cvrNotAvailable:
125 </blockquote></p>
126
127 <p>The values present are</p>
128
129 <pre>
130 bvn IBM (BIOS vendor)
131 bvr 1UETB6WW(1.66) (BIOS version)
132 bd 06/15/2005 (BIOS date)
133 svn IBM (system vendor)
134 pn 2371H4G (product name)
135 pvr ThinkPadX40 (product version)
136 rvn IBM (board vendor)
137 rn 2371H4G (board name)
138 rvr NotAvailable (board version)
139 cvn IBM (chassis vendor)
140 ct 10 (chassis type)
141 cvr NotAvailable (chassis version)
142 </pre>
143
144 <p>The chassis type 10 is Notebook. Other interesting values can be
145 found in the dmidecode source:</p>
146
147 <pre>
148 3 Desktop
149 4 Low Profile Desktop
150 5 Pizza Box
151 6 Mini Tower
152 7 Tower
153 8 Portable
154 9 Laptop
155 10 Notebook
156 11 Hand Held
157 12 Docking Station
158 13 All In One
159 14 Sub Notebook
160 15 Space-saving
161 16 Lunch Box
162 17 Main Server Chassis
163 18 Expansion Chassis
164 19 Sub Chassis
165 20 Bus Expansion Chassis
166 21 Peripheral Chassis
167 22 RAID Chassis
168 23 Rack Mount Chassis
169 24 Sealed-case PC
170 25 Multi-system
171 26 CompactPCI
172 27 AdvancedTCA
173 28 Blade
174 29 Blade Enclosing
175 </pre>
176
177 <p>The chassis type values are not always accurately set in the DMI
178 table. For example my home server is a tower, but the DMI modalias
179 claim it is a desktop.</p>
180
181 <p><strong>SerIO subtype</strong></p>
182
183 <p>This type is used for PS/2 mouse plugs. One example is from my
184 test machine:</p>
185
186 <p><blockquote>
187 serio:ty01pr00id00ex00
188 </blockquote></p>
189
190 <p>The values present are</p>
191
192 <pre>
193 ty 01 (type)
194 pr 00 (prototype)
195 id 00 (id)
196 ex 00 (extra)
197 </pre>
198
199 <p>This type is supported by the psmouse driver. I am not sure what
200 the valid values are.</p>
201
202 <p><strong>Other subtypes</strong></p>
203
204 <p>There are heaps of other modalias subtypes according to
205 file2alias.c. There is the rest of the list from that source: amba,
206 ap, bcma, ccw, css, eisa, hid, i2c, ieee1394, input, ipack, isapnp,
207 mdio, of, parisc, pcmcia, platform, scsi, sdio, spi, ssb, vio, virtio,
208 vmbus, x86cpu and zorro. I did not spend time documenting all of
209 these, as they do not seem relevant for my intended use with mapping
210 hardware to packages when new stuff is inserted during run time.</p>
211
212 <p><strong>Looking up kernel modules using modalias values</strong></p>
213
214 <p>To check which kernel modules provide support for a given modalias,
215 one can use the following shell script:</p>
216
217 <pre>
218 for id in $(find /sys -name modalias -print0 | xargs -0 cat | sort -u); do \
219 echo "$id" ; \
220 /sbin/modprobe --show-depends "$id"|sed 's/^/ /' ; \
221 done
222 </pre>
223
224 <p>The output can look like this (only the first few entries as the
225 list is very long on my test machine):</p>
226
227 <pre>
228 acpi:ACPI0003:
229 insmod /lib/modules/2.6.32-5-686/kernel/drivers/acpi/ac.ko
230 acpi:device:
231 FATAL: Module acpi:device: not found.
232 acpi:IBM0068:
233 insmod /lib/modules/2.6.32-5-686/kernel/drivers/char/nvram.ko
234 insmod /lib/modules/2.6.32-5-686/kernel/drivers/leds/led-class.ko
235 insmod /lib/modules/2.6.32-5-686/kernel/net/rfkill/rfkill.ko
236 insmod /lib/modules/2.6.32-5-686/kernel/drivers/platform/x86/thinkpad_acpi.ko
237 acpi:IBM0071:PNP0511:
238 insmod /lib/modules/2.6.32-5-686/kernel/lib/crc-ccitt.ko
239 insmod /lib/modules/2.6.32-5-686/kernel/net/irda/irda.ko
240 insmod /lib/modules/2.6.32-5-686/kernel/drivers/net/irda/nsc-ircc.ko
241 [...]
242 </pre>
243
244 <p>If you want to help implementing a system to let us propose what
245 packages to install when new hardware is plugged into a Debian
246 machine, please send me an email or talk to me on
247 <a href="irc://irc.debian.org/%23debian-devel">#debian-devel</a>.</p>
248
249 <p><strong>Update 2013-01-15:</strong> Rewrite "cat $(find ...)" to
250 "find ... -print0 | xargs -0 cat" to make sure it handle directories
251 in /sys/ with space in them.</p>