Linux Troubleshooting 101-Knowing YOUR Hardware

Posted by JD 04/27/2013 at 16:00

Sometimes the hardware inside our PCs is not immediately discovered by Linux so we need to

  • figure out the hardware vendor and chips
  • understand the device driver (or a close relative in the same family of drivers)
  • locate/install the driver
  • load it as a kernel module
  • configure it through the kernel module
  • maintain the driver going forward – this can be 100% automatic or manual, depending on the driver involved.

After all this, there are some unsupported devices out there, so getting them to work under Linux is too difficult for most users. Even for an expert, the hassle-factor might become too great for seldom used hardware.

Determining the actual hardware and the chips used is the first step to getting it working.

Discovering Our Hardware

Linux has some great commands to discover what hardware it sees inside our computers.

  • dmesg
  • lsusb
  • lspci
  • lshw

Each of these commands have a few different options, which can make it easy to list only a specific type of device. As usual, the man page for each command is the best place to start. man lshw for example.

dmesg

dmesg shows hardware and other boot up options. When you attached a new device to a running system, the last few lines of the dmesg output should show that device information. A Nexus 4 phone:

$ dmesg
[4539711.437184] usb 1-1.1: USB disconnect, address 3
[4541602.863599] usb 1-1.1: new high speed USB device using ehci_hcd and address 4
[4541602.972987] usb 1-1.1: configuration #1 chosen from 1 choice

This information is not too helpful, since the machine I connected it to does not know about the N4 phone, but it does confirm that the USB connection was actually made and seen by the OS. That is something.

lsusb

lsusb shows attached USB devices. If a device is not understood, it should show a device ID which can be used to lookup whether it is supported by Linux, just not your current machine, or not.

$ lsusb
Bus 003 Device 002: ID 1058:1140 Western Digital Technologies, Inc.
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 002: ID 8087:0020
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 18d1:4ee2
Bus 001 Device 002: ID 8087:0020
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

From the dmesg command, I know that address 4 is my N4 device. The ID is 18d1:4ee2. Searching the internet for that confirms that as the Nexus 4 USB ID. Can I mount it? That is a different question. It is an MTP media device, so it needs a different style of mount with a special driver that I have not loaded. There are many reasons this phone is MTP and not a usual USB storage device which are beyond this article.

lspci

lspci shows PCI bus devices. A box here has a number of PCI devices, as you can see:

$ lspci 
00:00.0 Host bridge: Intel Corporation Core Processor DMI (rev 11)
00:03.0 PCI bridge: Intel Corporation Core Processor PCI Express Root Port 1 (rev 11)
00:08.0 System peripheral: Intel Corporation Core Processor System Management Registers (rev 11)
00:08.1 System peripheral: Intel Corporation Core Processor Semaphore and Scratchpad Registers (rev 11)
00:08.2 System peripheral: Intel Corporation Core Processor System Control and Status Registers (rev 11)
00:08.3 System peripheral: Intel Corporation Core Processor Miscellaneous Registers (rev 11)
00:10.0 System peripheral: Intel Corporation Core Processor QPI Link (rev 11)
00:10.1 System peripheral: Intel Corporation Core Processor QPI Routing and Protocol Registers (rev 11)
00:1a.0 USB Controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)
00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 05)
00:1c.0 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 1 (rev 05)
00:1c.4 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 5 (rev 05)
00:1c.5 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 6 (rev 05)
00:1c.6 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 7 (rev 05)
00:1c.7 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 8 (rev 05)
00:1d.0 USB Controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev a5)
00:1f.0 ISA bridge: Intel Corporation 5 Series Chipset LPC Interface Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 5 Series/3400 Series Chipset 6 port SATA AHCI Controller (rev 05)
00:1f.3 SMBus: Intel Corporation 5 Series/3400 Series Chipset SMBus Controller (rev 05)
01:00.0 VGA compatible controller: nVidia Corporation Device 0de1 (rev a1)
01:00.1 Audio device: nVidia Corporation Device 0bea (rev a1)
03:00.0 USB Controller: NEC Corporation Device 0194 (rev 04)
04:00.0 IDE interface: JMicron Technology Corp. JMB368 IDE controller
05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 03)
06:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
07:06.0 Ethernet controller: Marvell Technology Group Ltd. 88E8001 Gigabit Ethernet Controller (rev 12)

There is more information that is interesting but not too important too.

lshw

lshw is the granddaddy of all the prior commands. As part of my system management scripts, I run lshw daily on every physical and virtual machine here then store the output into a dated text file. What can I do with that information? If a device disappears from the list either it has been pulled or it has stopped working. Suppose that missing device is used for backup storage? Wouldn’t it be nice to know when it started disappearing? I’ve seen optical devices disappear from time to time too. This was a hint that a replacement would be needed, perhaps not today, not right now, but in the future.

lshw can be asked to limit the type of hardware it reports. One way to do that is to limit the Class of device returned. Classes are

  • Storage
  • Disk
  • Network
  • many others.

We can also ask for a summary of the hardware – lshw -short.
We can mix -short and -class to get to the point:


$ sudo lshw -short -C network
H/W path Device Class Description
===============
/0/100/1c.6/0 eth0 network RTL8111/8168B PCI Express Gigabit Ethernet controller
/0/100/1c.7/0 eth2 network 82574L Gigabit Network Connection
/0/100/1e/6 eth1 network 88E8001 Gigabit Ethernet Controller
/2 vnet0 network Ethernet interface

Handy? Yep.

From these commands, we can determine the hardware inside our Linux systems. Even if we run other operating systems, knowing the hardware to this level can be very helpful when seeking device drivers.

Summary

Next time you need to find a specific driver, regardless of OS involved, consider using a bootable Linux distro and running the commands above to learn the exact chips involved.

Next time you are having issues getting hardware working under Linux, use the commands above before asking for help so you can provide this critical data when trying to get help. Put the vendor and model in the title of any forum post to get the best help. Which title do you think will get the best replies?

  • Networking issue
  • Realtek RTL8111/8168B Network Failure

You decide.