Deployment Solution

 View Only

Read, Write, and Update the BIOS with Linux Automation, Part 1 

Oct 31, 2008 03:08 PM

There are many cases in which you may want to read and/or write information to the BIOS. For example, in our environment we write the inventory number to the BIOS's asset tag and set the BIOS's property tag to our university's name. You may also want to know what BIOS version a machine has, what its service tag is, the manufacturer, etc. This article will show you how to compile the two software packages that can be used to read/write information to the BIOS. The article also contains an archive of the programs that are already compiled.

Preface

If you plan on following the whole guide through the compiling process, you need to read my previous article on setting up your Linux environment for compiling. That article can be found here. If you do not plan on compiling your own programs or can't because you do not have a Linux workstation available to you, you can download the archive at the end of the article. I do however suggest that you still at least skim the article so you know how the archive is set up.

Throughout the article I will put certain parts of a command in bold font. This indicates that you need to substitute that text with your own (Mostly replacing filenames).

Finally, and just as a precaution, I OFFER NO WARRANTY TO ANY TERRIBLE/UNFORTUNANTE THINGS THAT MAY HAPPEN TO YOUR SYSTEM FROM USING THESE TOOLS! Obviously I wouldn't write this article if I thought there was a good chance of that happening but you should always do some prior investigation before attempting to make changes to the BIOS.

I'll be covering two software packages in these articles. The first of the two is called "dmidecode" and the second is called "libsmbios". Part 1 of this series will cover the compiling process of both packages and part 2 will deal with adding them to your automation image and their functionality.

Dmidecode

Dmidecode is described on their website (http://www.nongnu.org/dmidecode/) as:

"Dmidecode reports information about your system's hardware as described in your system BIOS according to the SMBIOS/DMI standard (see a sample output). This information typically includes system manufacturer, model name, serial number, BIOS version, asset tag as well as a lot of other details of varying level of interest and reliability depending on the manufacturer. This will often include usage status for the CPU sockets, expansion slots (e.g. AGP, PCI, ISA) and memory module slots, and the list of I/O ports (e.g. serial, parallel, USB)."

Compiling this package is very simple. First open a terminal window (On Ubuntu, its Applications -> Accessories -> Terminal) and run this command.

cd ~

This will take you to your home directory. Now run this command and write/remember the result as we will be using it later. The command simply tells you what directory you're currently in. From here on, anytime you see [home_directory], replace it with this commands output.

pwd

Now we can start the fun stuff. We want to make a directory to store our source code and then another install to. These directories are called "src" and "local" respectively. This command will make a directory called "src" with a sub directory called "local".

mkdir -p src/local

Now we need to download our source code. Go here and download the newest version that ends with "tar.gz" to your [home_directory]/src. When that is done, go back to your terminal and type the following commands. (NOTE: Your file names may differ from mine depending on which version we downloaded. Obviously, substitute your own file names.)

cd ~/src
tar xvzf dmidecode-2.9.tar.gz
cd dmidecode-2.9

The first command changed the directory to [home_directory]/src , the second extracted our archive, and the third changed our directory to the newly created directory that contains all of the source code for the program. Before compiling, we need to make a quick change. Again from the command line, type the following command.

nano Makefile

This will open up the 'Makefile' file in a text editor so we can make changes. A Makefile is a script that is used to aid us in the compiling process, aka it turns the process of compiling into a simple process instead of a hair-pulling process. Move your cursor to the line that says "prefix = /usr/local". This line sets the installation directory of the program after it's created. Since we are building this for another system, we don't want to actually install it and clutter up our own system. (More than likely, your system already has it installed anyways) Instead we are going to change this directory to our [home_directory]/src/local directory. So as an example, since my home directory is "/home/sysajwilli", I changed my line to read:

prefix = /home/sysajwilli/src/local

Once that's changed, hit Ctrl+X to exit nano. Since we made changes, it will ask us if we would like to save. Hit the 'y' key and then enter.

Now we're ready to compile. Type the following commands.

make
make install

The first command reads 'Makefile', gathers its settings, and compiles the program. The second command then actually installs the programs into our src/local directory.

Libsmbios

"Libsmbios" is a project hosted by Dell for reading, and in some cases, writing values to the BIOS. The package also contains a program for flashing the BIOS, adjusting the LCD brightness, controlling the onboard LEDs, and many other things. The outdated homepage is at http://linux.dell.com/libsmbios/main/index.html and the more up to date "Trac" page is at https://fedorahosted.org/libsmbios/.

Again, the first thing we need to do is get the source archive. The downloads are all here with each version getting its own version. Find the newest version, go into that folder, and download the ".tar.gz" file to "[home_directory]/src" as we did before. When it's done downloading, go back to your terminal so we can extract the archive. The command is below, and again, substitute the name of my file with yours.

cd ~/src
tar xvzf libsmbios-2.0.3.tar.gz
cd libsmbios-2.0.3

You may notice that this package does not contain a 'Makefile'. Instead we run the 'configure' script which we can pass some arguments into that will in turn create the 'Makefile' for us. I've successfully used libsmbios with this configure command.

./configure --enable-shared --with-gnu-ld \
--prefix=[home_directory]/src/local/

Note: Hit enter after the "\" to get to the next line, then hit enter again after you've typed the rest to finally run the command.

This script will output a lot of text to the screen as it checks all of the necessary information to make the 'Makefile'. Finally, when it completes, we can compile and install our package. Those commands are of course...

make
make install

We have now successfully compiled both packages for use with our Linux automation image. There is one last "tweak" that you will more than likely want to try. Currently, all of the binary executables/libraries we made still contain their debugging symbols. These are used for troubleshooting a program if it crashes. Because the Linux automation image is very small (32 megabytes), we want to use as little space as possible and one way to save space is to remove the debugging symbols. The 'strip' command is used for removing those symbols from our binaries. Run the following commands to strip the binaries you created.

cd ~/src/local/sbin
strip *
cd ../lib
strip *

The first command changes to the directory that houses the "runnable" programs. The tilde is short for your home directory. The next command runs the strip command on every file in that directory. The third command goes up one directory and into the lib directory. Two periods always means the parent folder and one period means the current folder. Finally, just as before, the last command runs strip on every file in that directory.

Note: Don't worry if you see an error like this: "strip: libsmbios.la: File format not recognized". It doesn't hurt anything.

Precompiled Archive

For those of you who just need the programs already compiled for you, I've provided my "src" directory in zip format. (Sorry Linux folks, Juice doesn't allow tarballs to be uploaded) This archive contains both the source code and the final compiled product. The attachment is at the bottom of the article.

You can now read part 2 where I'll describe how to add these packages to your image and illustrate some simple use cases. If you get stuck or have any issues with the article, feel free to send me a private message.

License: AJSL
By clicking the download link below, you agree to the terms and conditions in the Altiris Juice Software License
Support: User-contributed tools on the Juice are not supported by Altiris Technical Support. If you have questions about a tool, please communicate directly with the author by visiting their profile page and clicking the 'contact' tab.

Statistics
0 Favorited
0 Views
2 Files
0 Shares
0 Downloads
Attachment(s)
jpg file
6098.jpg   3 KB   1 version
Uploaded - Feb 25, 2020
zip file
linux_bios.zip   4.40 MB   1 version
Uploaded - Feb 25, 2020

Tags and Keywords

Related Entries and Links

No Related Resource entered.