Title: Modalias strings - a practical way to map "stuff" to hardware
-Tags: english, debian
-Date: 2013-01-14 11:10
+Tags: english, debian, isenkram
+Date: 2013-01-14 11:20
<p>While looking into how to look up Debian packages based on hardware
information, to find the packages that support a given piece of
<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
<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> >.
+<p>The modalias entries for a given Linux machine can be found using
+this shell script:</p>
+
+<pre>
+find /sys -name modalias -print0 | xargs -0 cat | sort -u
+</pre>
+
+<p>The supported modalias globs for a given kernel module can be found
+using modinfo:</p>
+
+<pre>
+% /sbin/modinfo psmouse | grep alias:
+alias: serio:ty05pr*id*ex*
+alias: serio:ty01pr*id*ex*
+%
+</pre>
+
<p><strong>PCI subtype</strong></p>
<p>A typical PCI entry can look like this. This is an Intel Host
one can use the following shell script:</p>
<pre>
- for id in $(cat $(find /sys -name modalias)|sort -u); do \
+ for id in $(find /sys -name modalias -print0 | xargs -0 cat | sort -u); do \
echo "$id" ; \
/sbin/modprobe --show-depends "$id"|sed 's/^/ /' ; \
done
packages to install when new hardware is plugged into a Debian
machine, please send me an email or talk to me on
<a href="irc://irc.debian.org/%23debian-devel">#debian-devel</a>.</p>
+
+<p><strong>Update 2013-01-15:</strong> Rewrite "cat $(find ...)" to
+"find ... -print0 | xargs -0 cat" to make sure it handle directories
+in /sys/ with space in them.</p>