跳转至内容

hwdetect

来自 ArchWiki

hwdetect 是一个硬件检测脚本,主要用于加载或列出要在 mkinitcpio.conf 中使用的模块。因此,它可以告知用户驱动硬件需要哪些内核模块。这与许多其他仅查询硬件并显示原始信息、需由用户自行将信息与所需驱动程序关联的工具不同。该脚本利用了 Linux 内核所采用的 sysfs 子系统导出的信息。

安装

安装 hwdetect 软件包。

用法

请参阅 hwdetect 源码,或运行 hwdetect --help

示例

您可以使用以下方法来填充 mkinitcpio.conf 中的 MODULES 项。

# hwdetect --show-modules

该命令的输出应与以下内容类似(取决于具体系统)

SOUND    : pcspkr
OTHER    : 8139cp 8139too ac

根据实际使用情况,复制模块名称以替换 /etc/mkinitcpio.conf 中的 MODULES 部分。由于部分或全部硬件检测和模块依赖计算已预先设定,系统现在的启动速度应该会更快。

  • 该工具具有专门用于 /etc/mkinitcpio.conf 的输出格式。
  • 如果由于新内核引入新模块而导致模块名称发生变化,或者您在计算机上安装了新硬件,您将需要重新生成模块列表并更新 MODULES

技巧与提示

未使用模块

要生成当前未使用的模块列表,请使用以下脚本

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

高层模块

相反的脚本同样值得关注,因为它列出了高层模块,即这些模块与特定硬件相关性较低的模块

 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

参见

© . This site is unofficial and not affiliated with Arch Linux.

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.