From ArchWiki

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.


Install the hwdetect package.


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


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.

  • 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 generate a list of modules currently not used, use the following script:

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

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:

 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";

See also