LPIC1 (2) Hardware Information
1. Hardware Information:
Some useful tools to report the information of the hardware and the module such as lsusb, lspci, lsdev and lsmod.
2. USB Information:
We can use lsusb to list the information of the USB devices.
$ lsusb -t
-t option for treelike diagram.
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M /: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
3. PCI Information:
We can use lspci to list the information of the USB devices.
$ lspci -tvv
-t option for treelike diagram and -vv option for very verbose version.
-[0000:00]-+-00.0 Intel Corporation 2nd Generation Core Processor Family DRAM Controller +-01.0-[01]----00.0 NVIDIA Corporation GF108M [GeForce GT 540M] +-02.0 Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller +-16.0 Intel Corporation 6 Series/C200 Series Chipset Family MEI Controller #1 +-1a.0 Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 +-1b.0 Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller +-1c.0-[02]----00.0 Qualcomm Atheros AR8151 v2.0 Gigabit Ethernet +-1c.1-[03]----00.0 Qualcomm Atheros AR9287 Wireless Network Adapter (PCI-Express) +-1c.2-[04]--+-00.0 Realtek Semiconductor Co., Ltd. RTS5209 PCI Express Card Reader | \-00.1 Realtek Semiconductor Co., Ltd. RTS5209 PCI Express Card Reader
4. Device Information:
The lsdev command displays the information about your system’s hardware, such as interrupt, addresses and I/O ports.
$ lsdev | less
Device DMA IRQ I/O Ports ------------------------------------------------ 0000:00:02.0 0000-0000 0000:00:1f.2 31 0000-0000 0000-0000 0000-0000 0000-0000 0000-0000 0000:00:1f.3 0000-0000 0000:01:00.0 0000-0000 0000:02:00.0 0000-0000 acpi 9 ACPI 0000-0000 0000-0000 0000-0000 0000-0000 0000-0000 0000-0000 ahci 0000-0000 0000-0000 0000-0000
5. List Module:
A module is dynamically linked into the running kernel when it is loaded.
The modules loaded in the system is recorded in /proc/modules.
$ cat /proc/modules | less
drbg 32768 1 - Live 0x0000000000000000 ansi_cprng 16384 0 - Live 0x0000000000000000 ctr 16384 1 - Live 0x0000000000000000 ccm 20480 1 - Live 0x0000000000000000 rfcomm 69632 2 - Live 0x0000000000000000 vmw_vsock_vmci_transport 32768 0 - Live 0x0000000000000000 vsock 36864 1 vmw_vsock_vmci_transport, Live 0x0000000000000000 vmw_vmci 65536 1 vmw_vsock_vmci_transport, Live 0x0000000000000000 ipt_MASQUERADE 16384 1 - Live 0x0000000000000000 nf_nat_masquerade_ipv4 16384 1 ipt_MASQUERADE, Live 0x0000000000000000 xfrm_user 32768 1 - Live 0x0000000000000000 xfrm_algo 16384 1 xfrm_user, Live 0x0000000000000000
For each kernel module loaded, the lsmod displays its name, size, use count, and a list of other referring modules.
$ lsmod | less
Module Size Used by drbg 32768 1 ansi_cprng 16384 0 ctr 16384 1 ccm 20480 1 rfcomm 69632 2 vmw_vsock_vmci_transport 32768 0 vsock 36864 1 vmw_vsock_vmci_transport vmw_vmci 65536 1 vmw_vsock_vmci_transport ipt_MASQUERADE 16384 1 nf_nat_masquerade_ipv4 16384 1 ipt_MASQUERADE
6. Insert Module:
The insmod command is used to insert the module.
Tipically, one module depends on other modules. For example, module A is depend on the module B and C. Before we inserting the module A, we must insert the module B and C first. The insmod command would not check the dependency automatically. Using the modprobe command instead of using insmod command to automatically determine these dependencies and it would install the prerequisite modules.
$ insmod <module name>
$? would report the status code of last command. echo $? return 0 for success.
$ echo $?
7. Remove Module:
The rmmod command can be used to remove the module which is not used in the system.
$ rmmod$ rmmod -a
-a option for all modules which is not used in the system.
8. Module Information:
Display the information of the module.
- -a: display the module’s author.<-li>
- -d: display the module’s description.
- -p: display the typed parameters that a module supports.
$ cd /lib/modules/4.4.0-119-generic/kernel/drivers/usb/class $ modinfo -d usblp.ko $ modinfo -a usblp.ko $ modinfo -p usblp.ko
9. Module Probe:
The modprobe command determines prerequisite relationships between modules by reading modules.dep at the top of the module directory hierarchy. If the module is dependent upon other modules, they will be loaded first.
$ modprobe <module name> # insert a module $ modprobe -r <module name1> <module name2> # remove the modules
Reference
[1] Adam Haeder, Stephen Addison Schneiter, Bruno Gomes Pessanha, and James Stanger , LPI Linux Certification in a nutshell (3rd), O’Reilly Media (2010)
留言
張貼留言