Digging into your Linux system's hardware

digging dog deb
Credit: flickr / Deb

Ever find yourself having to look into the particulars of your servers' hardware? Maybe you go scrounging for the original invoice or for some email you were sent several years ago or the quote that was generated when you were about to purchase it? Well, stop. There's an alternative that you're probably going to like quite a bit. You can get your hardware to tell you about itself. Just use a command called dmidecode.

The name "dmidecode" might not ring any bells, but the "dmi" part of the name stands for "Desktop Management Interface". It's an API that allows you to gather information about the your system's underlying hardware. The command is designed to work on any Linux system as it was originally designed by a consortium -- the Desktop Management Task Force -- for gathering information and configuring systems.

The dmidecode command gets its data from the DMI tables stored in memory and presents it in a human readable format. The commands that you will probably like the most are commands like these:

$ sudo dmidecode | grep Vendor
        Vendor: Dell Inc.
$ sudo dmidecode -t system | grep Product
        Product Name: PowerEdge R710

These commands show that the system that Linux is running on is a Dell PowerEdge R710. And, while piping the dmidecode's output to grep might seem a bit "much", you should note that the command generates quite a bit of output -- often more than a thousand lines. Looking for specific lines will probably save you quite a bit of time.

# dmidecode | wc -l

Finding the serial number of the system:

# dmidecode | grep "Serial Number" | head -n1
        Serial Number: FWZPXQ1

Finding out something about the CPUs:

# dmidecode | grep CPU
        Socket Designation: CPU1
        Version: Intel(R) Xeon(R) CPU           X5650  @ 2.67GHz
        Socket Designation: CPU2
        Version: Intel(R) Xeon(R) CPU           X5650  @ 2.67GHz

Determining if the system has a RAID array:

# dmidecode | grep RAID
        Description: Integrated RAID Controller
                Integrated RAID

You can also learn about specific components if you know their type identifiers. For example, processors are type 4, so let's pull up information on the processors (much more than we looked at in the command above).

# dmidecode -t 4 | head -53
# dmidecode 2.7
SMBIOS 2.6 present.

Handle 0x0400, DMI type 4, 40 bytes.
Processor Information
        Socket Designation: CPU1
        Type: Central Processor
        Family: Xeon
        Manufacturer: Intel
        ID: C2 06 02 00 FF FB EB BF
        Signature: Type 0, Family 6, Model 44, Stepping 2
                FPU (Floating-point unit on-chip)
                VME (Virtual mode extension)
                DE (Debugging extension)
                PSE (Page size extension)
                TSC (Time stamp counter)
                MSR (Model specific registers)
                PAE (Physical address extension)
                MCE (Machine check exception)
                CX8 (CMPXCHG8 instruction supported)
                APIC (On-chip APIC hardware supported)
                SEP (Fast system call)
                MTRR (Memory type range registers)
                PGE (Page global enable)
                MCA (Machine check architecture)
                CMOV (Conditional move instruction supported)
                PAT (Page attribute table)
                PSE-36 (36-bit page size extension)
                CLFSH (CLFLUSH instruction supported)
                DS (Debug store)
                ACPI (ACPI supported)
                MMX (MMX technology supported)
                FXSR (Fast floating-point save and restore)
                SSE (Streaming SIMD extensions)
                SSE2 (Streaming SIMD extensions 2)
                SS (Self-snoop)
                HTT (Hyper-threading technology)
                TM (Thermal monitor supported)
                PBE (Pending break enabled)
        Version: Intel(R) Xeon(R) CPU           X5650  @ 2.67GHz
        Voltage: 1.2 V
        External Clock: 6400 MHz
        Max Speed: 3600 MHz
        Current Speed: 2666 MHz
        Status: Populated, Enabled
        Upgrade: <OUT OF SPEC>
        L1 Cache Handle: 0x0700
        L2 Cache Handle: 0x0701
        L3 Cache Handle: 0x0702
        Serial Number: Not Specified
        Asset Tag: Not Specified
        Part Number: Not Specified

That's a lot of information and probably more than most of us want to know, but for some people, this level of detail might be very important. And note that this output is only showing the first of the two CPUs to keep it from dominating this post.

And, no, you don't have to memorize the device types. You'll find a table like this in the dmidecode command's man page or you can reference this nice little post every time you get curious (I'd suspect the man page is a tad easier to find).

       Type   Information
          0   BIOS
          1   System
          2   Base Board
          3   Chassis
          4   Processor
          5   Memory Controller
          6   Memory Module
          7   Cache
          8   Port Connector
          9   System Slots
         10   On Board Devices
         11   OEM Strings
         12   System Configuration Options
         13   BIOS Language
         14   Group Associations
         15   System Event Log
         16   Physical Memory Array
         17   Memory Device
         18   32-bit Memory Error
         19   Memory Array Mapped Address
         20   Memory Device Mapped Address
         21   Built-in Pointing Device
         22   Portable Battery
         23   System Reset
         24   Hardware Security
         25   System Power Controls
         26   Voltage Probe
         27   Cooling Device
         28   Temperature Probe
         29   Electrical Current Probe
         30   Out-of-band Remote Access
         31   Boot Integrity Services
         32   System Boot
         33   64-bit Memory Error
         34   Management Device
         35   Management Device Component
         36   Management Device Threshold Data
         37   Memory Channel
         38   IPMI Device
         39   Power Supply

You'll probably find that dmidecode knows a lot more about your servers' hardware than you'd ever want to understand, but the command makes it easy to fetch information when yoiu need it and doesn't require you to go scrounging through your file cabinet or your old email.

And you don't have to be anywhere near the systems to find the information that you need.

Join the Network World communities on Facebook and LinkedIn to comment on topics that are top of mind.
Must read: 10 new UI features coming to Windows 10