1. Introduction
During the early power-up period, a computer is managed by the program provided by the BIOS – Basic Output/Input System and retained settings stored in CMOS. The BIOS content is usually proprietary and vendor-dependent. So, we have limited access to this firmware. In order to shed more light on system BIOS, specifications such as SMBIOS or UEFI try to make the firmware more transparent for the operating system.
In this tutorial, we’ll learn how to access BIOS information from the Linux command line.
2. SMBIOS and dmidecode
SMBIOS stands for System Management BIOS and is maintained by the DMTF organization. We can regard SMBIOS as a specification to present firmware information to the system. We’re provided with a set of standard DMI types, each relating to a particular aspect of the computer architecture. Within types, we can find predefined values to describe their features. SMBIOS data are defined for both UEFI and non-UEFI systems.
The SMBIOS table resides in the RAM. It’s filled with data by the manufacturer’s software during boot time. So, the SMBIOS content and its reliability depend on the vendor.
The common tool to query SMBIOS data is dmidecode. Because BIOS probes the system hardware, the command loads finished information. Let’s take a look into the command’s manual to find out recognizable DMI types:
DMI TYPES
The SMBIOS specification defines the following DMI types:
Type Information
────────────────────────────────────────────
0 BIOS
1 System
2 Baseboard
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
#...
42 Management Controller Host Interface
For the human-readable output of SMBIOS records, we can use the -t (–type) option to dmidecode, followed by one or more numerical types. Additionally, keywords are allowed. Each keyword corresponds to a set of DMI types:
$ dmidecode --type
dmidecode: option '--type' requires an argument
Type number or keyword expected
Valid type keywords are:
bios
system
baseboard
chassis
processor
memory
cache
connector
slot
For example, system combines DMI types 1, 12, 15, 23, and 32.
2.1. BIOS Information With dmidecode
Now, let’s show the BIOS information:
$ sudo dmidecode --type bios
# dmidecode 3.3
Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: Dell Inc.
Version: A16
Release Date: 09/09/2013
Address: 0xF0000
Runtime Size: 64 kB
ROM Size: 12 MB
Characteristics:
PCI is supported
PNP is supported
BIOS is upgradeable
BIOS shadowing is allowed
Boot from CD is supported
Selectable boot is supported
EDD is supported
5.25"/1.2 MB floppy services are supported (int 13h)
3.5"/720 kB floppy services are supported (int 13h)
3.5"/2.88 MB floppy services are supported (int 13h)
Print screen service is supported (int 5h)
8042 keyboard services are supported (int 9h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
ACPI is supported
USB legacy is supported
BIOS boot specification is supported
Function key-initiated network boot is supported
Targeted content distribution is supported
UEFI is supported
BIOS Revision: 4.6
The bios preset is equivalent to using two types – 0 and 13, which refer to BIOS and BIOS language information, respectively:
$ sudo dmidecode --type 0 13
3. The biosdecode Command
The biosdecode command parses the BIOS memory. As a result, we’ll obtain information organized into entry points:
$ sudo biosdecode
# biosdecode 3.3
BIOS32 Service Directory present.
Revision: 0
Calling Interface Address: 0x000E9D80
SMBIOS 2.7 present.
Structure Table Length: 3789 bytes
Structure Table Address: 0x000EC310
Number Of Structures: 85
Maximum Structure Size: 253 bytes
# ...
The entry points correspond to different BIOS present in the system. Of them all, we’re most interested in SMBIOS. The information in this node directly describes the SMBIOS data structure, the address and size of the structure table, and the number of records inside.
4. The smbios-utils Package
The smbios-utils package provides us with a bunch of commands to work with the SMBIOS. It’s a Python wrapper to the libsmbios C library. Let’s install the package under Ubuntu with the following:
$ sudo apt install smbios-utils
We’re most interested in the smbios-token-ctl command. With its help, we can read and even modify some users’ settings in BIOS. However, the implementation relies on the proprietary Dell features.
4.1. Reading Tokens
We can dump the BIOS settings with the –dump-tokens option to smbios-token-ctl:
$ sudo smbios-token-ctl --dump-tokens
# ...
================================================================================
Token: 0x0022 - Sound Device (Enable)
value: bool = true
Desc: Enable the system's built-in sound device
================================================================================
Token: 0x0023 - Sound Device (Disable)
value: bool = false
Desc: Disable the system's built-in sound device
================================================================================
Token: 0x0028 - Auto-on (Disable)
value: bool = true
Desc: Disable the system's auto-on capabilities
================================================================================
Token: 0x0029 - Auto-on (Every Day)
value: bool = false
Desc: Enable the system's auto-on capabilities every day of the week
# ...
In this output, we see the token’s name, value, and description. Here we have all values of the bool type. So, true indicates that the feature is set. Note the separate entries for the sound device. Token 0x0022 says that the feature Sound Device (Enable) is true, while 0x0023 reports the Sound Device (Disable) is false. So, putting this together, the system’s built-in sound device is on.
For more concise data, we can put the output in CSV format:
$ sudo smbios-token-ctl --dump-tokens-csv
ID,Type,Value,Name,Setting
0x0005,bool,false,Serial Port 1,COM2
0x0006,bool,false,Serial Port 1,COM4
0x000f,bool,false,Serial Port 1,Disable
0x0011,bool,true,Serial Port 1,COM1
0x0012,bool,false,Serial Port 1,COM3
0x0022,bool,true,Sound Device,Enable
0x0023,bool,false,Sound Device,Disable
0x0028,bool,true,Auto-on,Disable
# ...
4.2. Searching for Tokens
Assuming that we know the token ID, we can find its data with the -i option:
$ sudo smbios-token-ctl -i 0x0357
================================================================================
Token: 0x0357 - Enable Legacy Option ROMs (Disabled)
value: bool = true
Desc: Disable BIOS detection and usage of legacy expansion ROMs
5. Managing the Boot Order
A common task performed through the BIOS menu is to set the boot order. In the UEFI BIOS machine, we can inspect and modify the UEFI Boot Manager with the efibootmgr command:
$ efibootmgr
BootCurrent: 0002
Timeout: 0 seconds
BootOrder: 0002,000B,0000,000C,0001,000A,0005,0009,0007
Boot0000* ubuntu
Boot0001 Diskette Drive
Boot0002* Fedora
Boot0005* USB Storage Device
Boot0007* Onboard NIC
Boot0009* CD/DVD/CD-RW Drive
Boot000A* HGST HTS725050A7E630
Boot000B UEFI: HGST HTS725050A7E630
Boot000C UEFI: HGST HTS725050A7E630
We can see the BootCurrent entry shows 0002, which corresponds to Fedora. Next, the BootOrder is provided, followed by the code and description of each entry. Note the star symbol after, e.g., Boot0000, indicating the entry is active.
With efibootmgr we can also change the boot order, create or delete entries or set a boot entry for the next boot only.
6. Using Firmware
If we’re using a Dell computer, we can install the Command|Configure utility from Dell’s website. For the Fedora 35 distribution, we’re going to use the RHEL 8.0 rpm files. Afterward, we can navigate to the /opt/dell/dcc folder and start the cctk command. Let’s check the BIOS version:
$ sudo ./cctk --BiosVer
BiosVer=A16
We can obtain the whole list of commands and options by running cctk without argument. In addition, we can use the -H option to obtain more information about the particular command:
$ sudo ./cctk -H --NumLock
NumLock/NumLockLed: Turns the keyboard number lock on or off.
Arguments: Enabled+ | Disabled+
Note : + Indicates the arguments supported in the current machine.
Finally, let’s dump all BIOS settings to a human-readable file with this syntax:
$ sudo ./cctk --outfile bios_setting.txt
The Command Configure package allows modification of BIOS settings as well.
7. Conclusion
In this article, we learned about standards to access the BIOS information in Linux. First, we used the dmidecode command to retrieve SMBIOS standard hardware information. Then, thanks to the UEFI standard, we check the boot order with the efibootmgr command. Finally, we applied the Dell firmware to read the BIOS setting.
In addition, we introduced the Dell-rooted smbios-utils suite to provide BIOS information and biosdecode to find BIOS locations in RAM.