How to read/write all BIOS settings from Linux CLI?

11

2

I have been searching around 8 hours and I would like to clear the points that I haven't fully figured out yet.

(TLDR Version: How can I access (read and write) all BIOS settings (such as enabling/disabling virtualization, enable/disable turbo frequency of GPU, set log display time etc..) from CLI?)

Here is the story.

First, we had old BIOSes, such as this one.

And now, we have the new generation of BIOSes, such as this one. And we call them as a UEFI BIOS, am I correct?


Then I've read (and tested) following articles:

  • www.pixelbeat.org/docs/bios/
  • stackoverflow.com/questions/6259124/apis-for-querying-and-setting-bios-properties (and also all links referred in responses)
  • unix.stackexchange.com/questions/126132/how-to-dump-bios-data-to-a-file
  • stackoverflow.com/questions/34537435/where-does-dmidecode-get-the-smbios-table
  • en.wikipedia.org/wiki/System_Management_BIOS
  • www.linux-mag.com/id/7768/
  • www-pc.uni-regensburg.de/hardware/techdok/bios_dmi_20.pdf (up to page 17)
  • www.geeklab.info/2010/05/backup-your-cmos-from-linux/
  • www.bioscentral.com/misc/cmosmap.htm
  • smackerelofopinion.blogspot.com.tr/2010/09/digging-into-bios-cmos-memory.html

After that, I've changed the bios settings (such as virtualization, enable/disable IGD turbo, changing usb settings etc.) several times and dumped the entire contents of following files/commands on each boot.

  • dmidecode
  • biosdecode
  • cpuid
  • /dev/mem
  • /dev/nvram

Result? I've compared the dump results side by side with Meld and woala! Nothing has changed! What the heck?!!

So here is the list of my questions (I'm an electronics engineer so you can go for details or refer technical readings without a hesitation).

  1. In which part of the mainboard (I mean chip) we were storing all the BIOS settings (for old versions)?
  2. What kind of hardware do we require to keep the settings and interface of UEFI BIOSes? And how UEFI BIOS hardware is differentiating from the old versions?
  3. Is there any way to access this (or these) hardware over any kind of drivers/files in Linux?
  4. Is it possible to change those configurations from over the OS?

All responses will be appreciated greatly.

Thanks from now.

benjamin button

Posted 2016-11-22T20:29:08.057

Reputation: 113

I could be wrong but I think your BIOS need to be open source which is very rare. They do exist though. – LateralTerminal – 2018-01-08T17:16:31.293

Answers

6

There is no generic way an OS can access the system BIOS. This would only be possible if manufacturers were to provide detailed information and there were established standards as to how this is to be done. This is not the case, and I don't think it would be a good idea anyway.

Some manufacturers have created software for their own systems, at least for Windows. This software must be designed for specific versions of the BIOS.

The issue is that the BIOS is proprietary to each manufacturer. Typically settings are stored in the CMOS but there is no requirement for this. Manufacturers are free to store settings wherever and however they choose. No documentation is available for these details.

There are security implications with this. If legitimate software could access the BIOS then there would be nothing to stop malicious software from doing the same. This would open up a whole new world of possibilities for malware, one which it's creators would take full advantage. Of course safeguards could be developed but they could be and would be evaded

LMiller7

Posted 2016-11-22T20:29:08.057

Reputation: 1 849

At this point a weird question appears in my mind (maybe just because of the lack of basic kernel knowledge) : As I know kernel kernel scans for the external peripheral ICs on predefined bused and loads required drivers for them. So kernel should report which buses and devices are open to communicate. Can I find any clue that might lead me to the that specific IC by looking kernel boot up logs? If there is any chance to do it, from where should I start? Which software and how it reads information about the system bios and loads those information to the end of the DMI table? – benjamin button – 2016-11-22T22:39:25.210

Especially the "disable virtualization" setting (but several others too) needs a power cycle to be applied. – Simon Richter – 2020-01-09T10:39:13.983

4

What you call BIOS is (at least) 3 different things:

  • The system setup utility (Often wrongly called the BIOS or CMOS Setup)
  • The BIOS (i.e. a rudimentary bootloader and standardized APIs)
  • (U)EFI Firmware (i.e. a more modern version of bootup hardware abstraction)

While the latter two expose a well-defined set of APIs, the former does not. This means, that there is no vendor-neutral universal way of manipulating all the settings, that the setup utility provides.

As to where the settings are stored: Most vendors use battery-backed static RAM ("CMOS-RAM" in ancient nomenclature), which is why it is a hassle if those CR2032 cells on the mainboard die.

Eugen Rieck

Posted 2016-11-22T20:29:08.057

Reputation: 15 128

In this case, I wonder how vendors (i.e. ASUS) can update their "The system setup utility" in Windows OS (with bios update utilities)? Which means that they have an access to this CMOS-RAM. So is it possible to access this IC for read/write operations? Dumping raw content of entire memory of the IC and writing a specific value to specific address would be enough for me. – benjamin button – 2016-11-22T21:21:10.723

1The vendors know their products, so they can develop kernel drivers to access the NVRAM. This is of course vendor- and model-specific, there is no universal way to do so. – Eugen Rieck – 2016-11-22T21:37:10.580

@benjaminbutton, there is an API that allows the EFI applications to send each other data blocks. The BIOS upgrade mechanism works by leaving a signed update package to the BIOS -- BIOS memory is writeable only directly after a reboot, and a write protection mechanism that only unlocks during a system-wide reset is set up before starting any OS code. – Simon Richter – 2020-01-09T10:43:35.403

1

On HPE servers you can change settings using utility called conrep. It's part of the hp-scripting-tools RPM. The usage is described here:

h20566.www2.hpe.com/hpsc/doc/public/display?sp4ts.oid=5249594&docLocale=en_US&docId=emr_na-c05182235

It's quite simple. With -s (save) parameter you say it to save the configuration, like:

conrep -s -f BL460Gen8.dat

And with -l (load) parameter you say it to load the configuration:

conrep -l -f BL460Gen8.dat

The dat file is actually XML code. So if you want for example enable/disable hyperthreading settings, find respective line and modify the value. See the example for G6 and newer generations:

<Section name="Intel_Hyperthreading" helptext="Toggles hyperthreading on Intel based G6 and greater systems">Enabled</Section>

Jaroslav Kucera

Posted 2016-11-22T20:29:08.057

Reputation: 1 352

0

Much more convenient to be able to enable stuff from desktop then having to reboot into the bios. I know some settings you can change from desktop. AMD desktop CPU’s are capable of running ECC memory, and most mainboards are capable of using ECC as well, but many vendors do not provide a bios option for turning it on. Nonetheless you can toggle it yourself. I’ve done this and it does turn on ECC memory. Could be not good if you turned it on while running regular memory though, so don’t do that.

sudo modprobe -v amd64_edac_mod ecc_enable_override=1

There’s the command. And the below makes it persistent between boots.

sudo echo "options amd64_edac_mod ecc_enable_override=1" >> /etc/modprobe.d/amd64_edac_mod.conf

I’m currently looking to turn on the wireless on a laptop and wondering if I can do that from desktop. Would be nice to have a list of what options can be configured from desktop. The ECC isn’t even offered in the bios, so how many features like that might be available, especially with certain venders who ship a bare bones bios.

Be real, be sober.

WSmart

Posted 2016-11-22T20:29:08.057

Reputation: 1

0

If your system is running UEFI firmware, it is possible to develop a CLI tool that would allow you to systematically enumerate all BIOS setup questions and available answers to each of them. You can also then use the CLI tool to change the option of a specific setup question. Technically this tool is a HII Parser. Now, what is HII. If you could down the UEFI Specification, it explains the HII in detail. In nutshell the UEFI FW contains HII metadata in a spec defined data structure. and the UEFI FW provides an EFI NVRAM variable that points to the system memory address where the metadata is placed. The Tool (HII Parser) must implement the HII support. With this it can literally act like a BIOS setup utility running on top of your OS.

There is one last caveat. Often UEFI FW will lock the BIOS setup configuration before booting to OS, to protect it. This will render the tool not being able to change the setup questions' options.

So typically an OEM would instrument their UEFI firmware to allow this and also provide the CLI Tool (HII parser). And then it could be used for personality dump/load/migration usage models.

Sugu

Posted 2016-11-22T20:29:08.057

Reputation: 1