28

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

TL;DR 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 the CLI?

Here is the story:

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

Phoenix - Award WorkstationBIOS CMOS Setup Utility

And now, we have a new generation of BIOSes, such as this one:

Asus EFI BIOS Utility - EZ Mode

We call them UEFI BIOSes, am I correct?


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


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

Results? I've compared the dump results side-by-side with Meld and voilà! Nothing has changed! What the heck?

Here is the list of my questions. I'm an electronics engineer so you can go into details or refer to technical readings without a hesitation.

  1. In which part of the mainboard (I mean chip) did we store 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 is the UEFI BIOS hardware different than the old versions?
  3. Is there any way to access this hardware over any kind of drivers or files in Linux?
  4. Is it possible to change those configurations from the OS?

All responses will be appreciated greatly.

2

8 Answers 8

8

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

5
  • 1
    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? Commented Nov 22, 2016 at 22:39
  • Especially the "disable virtualization" setting (but several others too) needs a power cycle to be applied. Commented Jan 9, 2020 at 10:39
  • There was a utility that ran under DOS which could read and write the BIOS contents. You'd make a dump of the configured settings. Then you'd reboot, and change a setting, and save a new dump. Then you could load any of the saved dumps and write it to the bios.
    – Aethalides
    Commented Nov 20, 2021 at 20:16
  • All you said doesn't imply there can't be command line utility to change BIOS.
    – Dims
    Commented Sep 30, 2022 at 9:15
  • 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 seems to have been written without considering that you can flash a BIOS image entirely making any settings bypass-able in code. Most BIOS / UEFI I've encountered do not need the user to enter the boot config to do this, it's initiated by software on external media including hard drive. Eg: intel nook has this method to flash from windows. Commented Sep 21, 2023 at 10:54
13

I'm surprised nobody mentioned smbios-token-ctl.

The BIOS can indeed be modified from within the OS.

Example: My BIOS has a setting to enable / disable the integrated webcam. I can alter that setting from within Linux:

# apt install smbios-utils

# smbios-token-ctl | grep -i camera
Token: 0x0285 - Camera (Enable)
Desc: To enable Camera
Token: 0x0286 - Camera (Disable)

# smbios-token-ctl -i 0x0285
================================================================================
Token: 0x0285 - Camera (Enable)
value: bool = true
Desc: To enable Camera

# smbios-token-ctl -i 0x0286 --activate
Original Value
token: 0x0286
type: bool
value: false
Activating token...
New value
type: bool
value: true

# smbios-token-ctl -i 0x0285
================================================================================
Token: 0x0285 - Camera (Enable)
value: bool = false
Desc: To enable Camera
Desc: To disable Camera

Then I can reboot, go into the BIOS, and check that the camera setting has been changed.

Note: A reboot is needed for the changes to be applied.

3
  • This is specifically for Dell.
    – user130356
    Commented Mar 26 at 17:28
  • Indeed I used it on a Dell laptop. However nothing in the package description or manpages indicates that this command is specifically for Dell, some maybe it works with some other BIOS too.
    – ChennyStar
    Commented Apr 13 at 12:11
  • This was exactly what I needed to set the AC Power Recovery Mode without having to set up a monitor on my home server (an OptiPlex 5040).
    – Pockets
    Commented Aug 8 at 14:30
11

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.

3
  • 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. Commented Nov 22, 2016 at 21:21
  • 1
    The 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. Commented Nov 22, 2016 at 21:37
  • @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. Commented Jan 9, 2020 at 10:43
2

Dell provides "Dell Command | Configure". I used it to check what my server does after a power loss and change it without having to take server downtime.

$ sudo /opt/dell/dcc/cctk --AcPwrRcvry
AcPwrRcvry=Off

$ sudo /opt/dell/dcc/cctk --AcPwrRcvry=on
AcPwrRcvry=On
2

uefisettings can list, get, and (depending on your computer's security settings) set UEFI options. Run

sudo uefisettings hii list-questions

(add --json for programmatic usage) to get a (very long) list of options, like:

Question {
    name: "Restore On AC Power Loss",
    answer: "Disabled",
    options: [
        "Disabled",
        "Power On",
        "Power Off",
        "Last State",
        "Auto",
    ],
    help: "Restore Status On AC Power Loss",
},
Question {
    name: "GPIO Devices Support",
    answer: "Auto",
    options: [
        "Enabled",
        "Auto",
    ],
    help: "Enable/Disable GPIO ACPI Devices Support, disable it will disable i2C and uart interface device.",
},
Question {
    name: "ESATA Port On Port 0",
    answer: "Auto",
    options: [
        "Disabled",
        "Enabled",
        "Auto",
    ],
    help: "Enabled / Disabled Serial ATA Hot Plug",
}

Take the name field from this, and pass it like this to read the setting:

sudo uefisettings get "Restore On AC Power Loss"

(with the same JSON note as above). To set it, pick one of the options from above, and run:

sudo uefisettings set "Restore On AC Power Loss" "Power On"
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>
1
  • the link has been dead
    – phuclv
    Commented Mar 25, 2022 at 16:26
1

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.

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .