1 Title: Modalias strings - a practical way to map "stuff" to hardware
2 Tags: english, debian, isenkram
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
10 <a href="http://anonscm.debian.org/viewvc/debian-edu/trunk/src/hw-support-handler/">the
11 Debian Edu subversion repository</a>:
13 <p><strong>Modalias decoded</strong></p>
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 <URL: <a href="https://wiki.archlinux.org/index.php/Modalias">https://wiki.archlinux.org/index.php/Modalias</a> >,
18 <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> >,
19 <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> > and
20 <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> >.
22 <p>The modalias entries for a given Linux machine can be found using
23 this shell script:</p>
26 find /sys -name modalias -print0 | xargs -0 cat | sort -u
29 <p>The supported modalias globs for a given kernel module can be found
33 % /sbin/modinfo psmouse | grep alias:
34 alias: serio:ty05pr*id*ex*
35 alias: serio:ty01pr*id*ex*
39 <p><strong>PCI subtype</strong></p>
41 <p>A typical PCI entry can look like this. This is an Intel Host
42 Bridge memory controller:</p>
45 pci:v00008086d00002770sv00001028sd000001ADbc06sc00i00
48 <p>This represent these values:</p>
53 sv 00001028 (subvendor)
54 sd 000001AD (subdevice)
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>
65 <p>Not sure how to figure out the interface value, nor what it
68 <p><strong>USB subtype</strong></p>
70 <p>Some typical USB entries can look like this. This is an internal
71 USB hub in a laptop:</p>
74 usb:v1D6Bp0001d0206dc09dsc00dp00ic09isc00ip00
77 <p>Here is the values included in this alias:</p>
80 v 1D6B (device vendor)
81 p 0001 (device product)
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)
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>
96 usb:v0AC8p3420d5000dcEFdsc02dp01ic01isc01ip00
97 <br>usb:v0AC8p3420d5000dcEFdsc02dp01ic01isc02ip00
98 <br>usb:v0AC8p3420d5000dcEFdsc02dp01ic0Eisc01ip00
99 <br>usb:v0AC8p3420d5000dcEFdsc02dp01ic0Eisc02ip00
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>
106 <p><strong>ACPI subtype</strong></p>
108 <p>The ACPI type is used for several non-PCI/USB stuff. This is an IR
109 receiver in a Thinkpad X40:</p>
112 acpi:IBM0071:PNP0511:
115 <p>The values between the colons are IDs.</p>
117 <p><strong>DMI subtype</strong></p>
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>
124 dmi:bvnIBM:bvr1UETB6WW(1.66):bd06/15/2005:svnIBM:pn2371H4G:pvrThinkPadX40:rvnIBM:rn2371H4G:rvrNotAvailable:cvnIBM:ct10:cvrNotAvailable:
127 <p>The values present are</p>
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)
141 cvr NotAvailable (chassis version)
144 <p>The chassis type 10 is Notebook. Other interesting values can be
145 found in the dmidecode source:</p>
149 4 Low Profile Desktop
162 17 Main Server Chassis
165 20 Bus Expansion Chassis
166 21 Peripheral Chassis
168 23 Rack Mount Chassis
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>
181 <p><strong>SerIO subtype</strong></p>
183 <p>This type is used for PS/2 mouse plugs. One example is from my
187 serio:ty01pr00id00ex00
190 <p>The values present are</p>
199 <p>This type is supported by the psmouse driver. I am not sure what
200 the valid values are.</p>
202 <p><strong>Other subtypes</strong></p>
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>
212 <p><strong>Looking up kernel modules using modalias values</strong></p>
214 <p>To check which kernel modules provide support for a given modalias,
215 one can use the following shell script:</p>
218 for id in $(find /sys -name modalias -print0 | xargs -0 cat | sort -u); do \
220 /sbin/modprobe --show-depends "$id"|sed 's/^/ /' ; \
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>
229 insmod /lib/modules/2.6.32-5-686/kernel/drivers/acpi/ac.ko
231 FATAL: Module acpi:device: not found.
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
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>
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>