Skip to main content

Linux tools: examining hardware in the terminal with dmidecode

Linux distros have powerful command-line tools built-in. Here, we explore the DMI Decoder.
Image
rotor cipher machine

Image by skeeze @ Pixabay

The DMI table decoder is a command-line tool for Linux systems. It is commonly used to translate a machine's DMI table (System Management BIOS, or SMBIOS) into a human-readable format. This tool allows you to see additional information about a system's hardware configuration, and even gives information not directly related to the current build. Information like the maximum supported amount of memory or the fastest-supported CPU type can be found by using a few key flags.

Practical application

From a practical standpoint, you might run into situations where you need a serial number or a key piece of hardware information during troubleshooting. In my time as a storage engineer, I ran into multiple instances where a customer would purchase a virtual edition server and then try to run massive amounts of data backups or replication to this machine. Depending on the size of the jobs, they would sometimes overload the memory included and exceed the swap space. In turn, this issue would cause Out-of-Memory (OOM) Killer to have a field day with the system. So, rather than looking up hardware specs in a manual, I could use dmidecode to grab this information. 

The breakdown

First off, all of the following information can be found in the man-pages for the tool by running man dmidecode. Feel free to follow along there. At the most basic level, each record has one of the following (as listed in the man page): 

Handle - This is a unique identifier, which allows records to reference each other. For example, processor records usually reference  cache  memory records using their handles.

Type - The SMBIOS specification defines different types of elements a computer can be made of. For example, type 2 refers to "Base Board Information". 

Size - Each record has a 4-byte header (2 for the handle, 1 for the type, 1 for the size), the rest is used by the record data. This vaule does not take the text strings into account (these are placed at the end of the record), so the actual length of a record may be (and is often) greater than the displayed value

Decoded Value - The information presented of course depends on the type of record. Here, we learn about the board's manufacturer, model, version and serial number.

You can see an example listing here:

Image
dmi example

There are many options that can be used to create a more precise output. I will not cover all of these here, but they are laid out plainly using the man page. What I will talk about are the DMI type codes that are included with the command to make specific information rapidly accessible. Going back to my previous example, you will remember that we routinely had issues with OOM errors. To gather information about a system's memory configuration, you can use the following command: 

$ dmidecode -t x

where x is equal to the numeric type code you wish to gather. For this example, the codes 5, 6, 16, and 17 would all be helpful to gather. See the man page's full chart below for all the available type codes:

Image
dmi decoder type codes

Shortcuts

Keywords can be used with the --type flag to pull all associated type codes into the command. From the example below, you can see that all of the information associated with using numerical type codes 16 and 17 is supplied: 

$ dmidecode --type memory

# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.0.0 present.

Handle 0x0003, DMI type 16, 23 bytes
Physical Memory Array
	Location: System Board Or Motherboard
	Use: System Memory
	Error Correction Type: None
	Maximum Capacity: 32 GB
	Error Information Handle: Not Provided
	Number Of Devices: 2

Handle 0x0004, DMI type 17, 40 bytes
Memory Device
	Array Handle: 0x0003
	Error Information Handle: Not Provided
	Total Width: 64 bits
	Data Width: 64 bits
	Size: 8192 MB
	Form Factor: SODIMM
	Set: None
	Locator: ChannelA-DIMM0
	Bank Locator: BANK 0
	Type: DDR4
	Type Detail: Synchronous Unbuffered (Unregistered)
	Speed: 2133 MT/s
	Manufacturer: Samsung
	Serial Number: 00000000
	Asset Tag: None
	Part Number: M471A1K43BB1-CRC    
	Rank: 1
	Configured Memory Speed: 2133 MT/s
	Minimum Voltage: Unknown
	Maximum Voltage: Unknown
	Configured Voltage: 1.2 V

Handle 0x0005, DMI type 17, 40 bytes
Memory Device
	Array Handle: 0x0003
	Error Information Handle: Not Provided
	Total Width: 64 bits
	Data Width: 64 bits
	Size: 8192 MB
	Form Factor: SODIMM
	Set: None
	Locator: ChannelB-DIMM0
	Bank Locator: BANK 2
	Type: DDR4
	Type Detail: Synchronous Unbuffered (Unregistered)
	Speed: 2133 MT/s
	Manufacturer: SK Hynix
	Serial Number: 2A7E0BA5
	Asset Tag: None
	Part Number: HMA81GS6AFR8N-UH    
	Rank: 1
	Configured Memory Speed: 2133 MT/s
	Minimum Voltage: Unknown
	Maximum Voltage: Unknown
	Configured Voltage: 1.2 V

You can see here of the information associated with using type codes 5, 6, 16, and 17. 

Wrap-up

I hope that this quick rundown of the DMI Decoder tool has been helpful. Let us know when you have used this command or had need of it. Hopefully, you now have a better strategy or reference point for the next hardware issue you run into.

[Want to try out Red Hat Enterprise Linux? Download it now for free.]

Topics:   Linux   Hardware  
Author’s photo

Tyler Carrigan

Tyler is a community manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. More about me

Related Content

OUR BEST CONTENT, DELIVERED TO YOUR INBOX