Difference between revisions of "Hwdetect"

From ArchWiki
Jump to: navigation, search
m (Tips)
m (use interwiki link)
 
(39 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
[[Category:Hardware detection and troubleshooting]]
 
[[Category:Hardware detection and troubleshooting]]
 +
[[ja:Hwdetect]]
 
[[tr:hwdetect]]
 
[[tr:hwdetect]]
[https://projects.archlinux.org/svntogit/packages.git/tree/hwdetect/trunk/hwdetect hwdetect] is a hardware detection script primarily used to load or list modules for use in [[rc.conf]] or [[mkinitcpio|mkinitcpio.conf]]. The script makes use of information exported by the [[Wikipedia:Sysfs|sysfs]] subsystem employed by the Linux kernel.
+
{{Related articles start}}
 +
{{Related|mkinitcpio}}
 +
{{Related articles end}}
 +
[https://projects.archlinux.org/svntogit/packages.git/tree/hwdetect/trunk/hwdetect hwdetect] is a hardware detection script primarily used to load or list modules for use in [[mkinitcpio.conf]]. As such, it informs its user about which kernel modules are required to drive the hardware. This is in contrast to many other tools, that only query the hardware, and show raw information, leaving the user with the task to associate that information with the required drivers. The script makes use of information exported by the [[Wikipedia:Sysfs|sysfs]] subsystem employed by the Linux kernel.
  
 
== Installation ==
 
== Installation ==
  
The {{Pkg|hwdetect}} package is available from the [[official repositories]].
+
[[Install]] the {{Pkg|hwdetect}} package.
  
==Usage==
+
== Usage ==
  
The latest usage information can be found [https://projects.archlinux.org/svntogit/packages.git/tree/hwdetect/trunk/hwdetect here] or by running {{ic|hwdetect --help}}.
+
See the [https://projects.archlinux.org/svntogit/packages.git/tree/hwdetect/trunk/hwdetect hwdetect source], or run {{ic|hwdetect --help}}.
  
== Example ==
+
=== Examples ===
You can use the following method to disable {{Ic|MOD_AUTOLOAD}} in [[rc.conf]]. This should improve boot times, as time will not be spent discovering modules.
+
# hwdetect --modules
+
  
The command should output something similar to the following (of course, output depends on the system):
+
You can use the following method to populate {{Ic|MODULES}} in [[mkinitcpio.conf]].
MODULES=(ac battery button processor thermal video cdrom ....)
+
  
Copy this output to replace the {{ic|MODULES}} section in {{ic|/etc/rc.conf}} and change {{Ic|MOD_AUTOLOAD}} from "yes" to "no". The system should now skip the auto-load and boot faster.
+
# hwdetect --show-modules
  
{{Note|If any of the module names change (unlikely) or you install new hardware on your computer, you will need to generate the list of modules again and update {{ic|MODULES}}.}}
+
The command should have similar output to the following (system-dependant):
  
== Tips ==
+
SOUND    : pcspkr
To generated a list of modules currently not used, run:
+
  OTHER    : 8139cp 8139too ac
  # hwdetect --modules-not-loaded
+
  
or use the following script:
+
Depending on what is used, copy the module names to replace the {{ic|MODULES}} section in {{ic|/etc/mkinitcpio.conf}}. The system should now boot faster, as some, or all, of the hardware detection and modules dependencies calculations is already stated.
{{hc|modules-not-loaded|<nowiki>
+
 
eval $(hwdetect --modules)
+
{{Note|
for m in ${MODULES[*]}; do
+
* The tool has dedicated output for usage within {{ic|/etc/mkinitcpio.conf}}.
    if ! grep -sq $(echo $m|tr - _) <(lsmod); then
+
* If any of the module names change because newer kernels have newer modules, or you install new hardware on your computer, you will need to generate the list of modules again and update {{ic|MODULES}}.
        echo $m;
+
    fi
+
done</nowiki>
+
 
}}
 
}}
 +
 +
== Tips and tricks ==
 +
 +
=== Unused modules ===
 +
 +
To generated a list of modules currently not used, use the following script:
 +
 +
#!/bin/bash
 +
modules=($(awk '{print $1}' /proc/modules))
 +
 +
for hw in $(hwdetect --show-modules | awk -F: '{gsub("-","_"); print $2}'); do
 +
    if ! grep -q "$hw" <(printf '%s\n' "${modules[@]}"); then
 +
        printf '%s\n' "$hw";
 +
    fi
 +
done
 +
 +
=== Higher level modules ===
 +
 +
The converse script is also of interest as it lists modules which are higher level, in the sense that they are less related to specific pieces of hardware:
 +
 +
#!/bin/bash
 +
lowlevel=($(hwdetect --show-modules | awk -F: '{gsub("-","_"); print $2}'))
 +
 +
for mod in $(awk '{print $1}' /proc/modules); do
 +
    if ! grep -q "$mod" <(printf '%s\n' "${lowlevel[@]}"); then
 +
        printf '%s\n' "$mod";
 +
    fi
 +
done
 +
 +
== See also ==
 +
 +
* [[wikipedia:Lspci|lspci, and other hardware detection related tools]]

Latest revision as of 09:09, 26 July 2016

Related articles

hwdetect is a hardware detection script primarily used to load or list modules for use in mkinitcpio.conf. As such, it informs its user about which kernel modules are required to drive the hardware. This is in contrast to many other tools, that only query the hardware, and show raw information, leaving the user with the task to associate that information with the required drivers. The script makes use of information exported by the sysfs subsystem employed by the Linux kernel.

Installation

Install the hwdetect package.

Usage

See the hwdetect source, or run hwdetect --help.

Examples

You can use the following method to populate MODULES in mkinitcpio.conf.

# hwdetect --show-modules

The command should have similar output to the following (system-dependant):

SOUND    : pcspkr
OTHER    : 8139cp 8139too ac

Depending on what is used, copy the module names to replace the MODULES section in /etc/mkinitcpio.conf. The system should now boot faster, as some, or all, of the hardware detection and modules dependencies calculations is already stated.

Note:
  • The tool has dedicated output for usage within /etc/mkinitcpio.conf.
  • If any of the module names change because newer kernels have newer modules, or you install new hardware on your computer, you will need to generate the list of modules again and update MODULES.

Tips and tricks

Unused modules

To generated a list of modules currently not used, use the following script:

#!/bin/bash
modules=($(awk '{print $1}' /proc/modules))

for hw in $(hwdetect --show-modules | awk -F: '{gsub("-","_"); print $2}'); do
    if ! grep -q "$hw" <(printf '%s\n' "${modules[@]}"); then
        printf '%s\n' "$hw";
    fi
done

Higher level modules

The converse script is also of interest as it lists modules which are higher level, in the sense that they are less related to specific pieces of hardware:

#!/bin/bash
lowlevel=($(hwdetect --show-modules | awk -F: '{gsub("-","_"); print $2}'))

for mod in $(awk '{print $1}' /proc/modules); do
    if ! grep -q "$mod" <(printf '%s\n' "${lowlevel[@]}"); then
        printf '%s\n' "$mod";
    fi
done

See also