LPI Linux Certification/Configure Fundamental BIOS Settings
Configure Fundamental BIOS Settings
editDetailed Objective
editWeight: 1
- Description
- Candidates should be able to configure fundamental system hardware by making the correct settings in the system BIOS in x86 based hardware.
- Key knowledge area(s):
- The following is a partial list of the used files, terms and utilities:
- /proc/ioports
- /proc/interrupts
- /proc/dma
- /proc/pci
BIOS
editBIOS Tips & Tricks |
---|
Familiarize yourself with BIOS settings in equipment that you support. |
Know your beeps: You may not have access to the internet when things go wrong. |
Change control: Always make sure you can reverse any change you make in a BIOS. |
BIOS updates: Keep informed. Don't roll them out as soon as they hit the mirrors. Wait a couple of months then check manufacturer forums for problems with the update. Once you are happy, update one system, monitor it and then roll out to the rest of your systems. Document the change, BIOS updates are normally a nightmare to reverse. |
Be aware of the F1 key to continue, particularly when rebooting remote servers. |
Lights Out Management if it is available, utilize it. |
Think long and hard about implementing BIOS security. Can the same level of security be implemented elsewhere? Normally it can. |
Understand the limitations of BIOS date and time. Can system date and time be better maintained by other means? |
Introduction
editThe BIOS (Basic Input / Output System) can be thought of as a suite of small programs that operate between the operating system and the hardware on any given computer. It provides a number of services that enable the computer to boot any given operating system. The BIOS can also provide or present other services to the operating system depending on the operating system and / or the type of hardware installed. It is also wise to note that a modern-day computer may have multiple BIOS chips interfacing the various different hardware components that combine to build the whole computer. These include Disk Array Controllers, Graphic Cards, Sound Cards, and possibly a few others. Firstly let's look at the services the BIOS provides regardless of which operating system is installed: these being the POST (Power On Self Test), Hardware Management, Security and Date & Time.
Intel and other manufacturers have developed another standard called EFI (Extensible Firmware Interface), which performs a similar function to BIOS, but does the job in a different manner. EFI is far more flexible and powerful than BIOS, but it has not enjoyed as much commercial success. Exploration of EFI is beyond the scope of this document for now.
POST - Power On Self Test
edit- The POST process involves a small diagnostic program that checks system hardware such as RAM or motherboard components. If a particular piece of hardware is present, a basic test is performed to check for faults. More advanced tests such as a long memory test may be performed, but normally these features need to be manually enabled in the BIOS.
- If the POST process finds errors it will usually sound beeps on the motherboard speaker and / or show some visual message via LEDs on the motherboard and / or messages on the screen. This is known as an "Irregular POST Condition".
- The number (and in some cases the pattern) of the beeps, lights, or messages will aid you in diagnosing the problem; however, different motherboard models (even those from the same manufacturer) have different implementations of these signals, so it is always wise to have a printed reference manual for each model you support or internet access on another machine for a quick look-up.
Hardware Management
edit- During the POST process, the BIOS allows you great flexibility to customize certain aspects of the system via settings stored in CMOS (Complementary Metal Oxide Semiconductor) memory. CMOS memory is volatile memory, but your motherboard has a backup battery to preserve any customized system configurations that you have made. This battery will eventually die. If you find that your computer is not retaining BIOS settings from one power cycle to another, the usual reason is that you need to replace this battery.
- Useful BIOS settings often edited by users and system administrators may include:
- Boot device priority
- Enable / disable motherboard features like integrated video, LAN, or sound
- Setting preferred memory addresses or IRQ vectors for PCI (or older) cards
- On older motherboards these configurations were done by positioning certain jumpers or dip switches to the hardware manufacturer's specifications. Modern CMOS menus have replaced nearly all of these devices, with the exception of setting SCSI ID or resetting a BIOS password. There are still some "old school" motherboards in operation, so always keep the possibility of jumpers in mind.
Security
edit- Most BIOSs allow the user to set a password. The computer will require this password to be input before completing the boot process. Often this BIOS password adds inconvenience without any real security: information on how to get around these passwords is freely available on the internet. If the user forgets this password, the computer will not proceed to load an operating system. It's not hard to see why BIOS Passwords are rarely invoked at the business level.
- Many modern computers have the ability to detect configuration changes such as memory size changes and even if the case has been removed. The BIOS will often report these changes and prompt the user to press a key (usually the F1 key) to continue if this change is acceptable. Users may be required to hit another key to enter the BIOS configuration screens to change parameters depending on the particular BIOS manufacturer.
Date and Time
edit- Setting the time and date are options within any modern BIOS. This is a "real-time" clock that runs constantly, powered by the same battery that preserves the CMOS settings. It's not very accurate, even compared to a wrist-watch, but it's better to have this poor clock than to require users to enter the time manually at every reboot. (That's how it was done in the early days of computers.)
- Linux (like other operating systems) maintains its own clock in software by counting interrupts generated by an oscillator circuit in your computer. This clock only functions while the operating system is running.
- The BIOS provides the date and time to the operating system upon booting. After the operating system has gathered this information, the BIOS clock and the Operating System clock continue to run independently. This means that the BIOS clock will soon differ from the operating system clock, even if it is only in milliseconds.
- Linux has a command called hwclock which can be used to synchronize the operating system clock with the BIOS. Once synchronized, they will drift apart again, however. (This is due to the Hardware nature of the BIOS clock and the Software nature of the OS clock.)
- Further on in the course, you will start to look at ntp and how important it is to maintain a consistent "Network Time". Knowing that the BIOS and operating system maintain separate clocks will aid you in setting out a solution.
- The BIOS does not handle time zone or daylight savings time adjustments. These are handled by the operating system. For this reason, some administrators may choose to set their BIOS clocks to UTC rather than the local time.
Disk Drives
editMost computers use Hard Disk Drives to hold an operating system and users' data. Some newer computers use Solid State Disk Drives instead. Though the physical devices vary greatly, there is little difference from the standpoint of configuring Linux or other operating systems.
Attachment Interfaces
editFirstly let's address the confusion that often comes around from disk drive terminology such as IDE/ATA (Integrated Drive Electronics / Advanced Technology Attachment) and SATA (Serial Advanced Technology Attachment) and indeed PATA (Parallel Advanced Technology Attachment), which all use the ATA (Advanced Technology Attachment) standard to communicate with the device. The first part of the acronym can be thought of simplistically as a revision. Take for instance the revisions IDE, Fast IDE, EIDE, etc. These revisions changed the physical cables or ribbons that connect the disk drives to the computer, which enabled certain features, e.g. to address more disk space or speed up communications with the device. SATA was like a rewrite, once SATA came into being it was decided that all historical ATA devices that predated SATA (IDE, etc.) were to be grouped under the terminology PATA.
SCSI is another popular attachment interface that has undergone several generations of revision over the years: SCSI, SCSI-2, SCSI-3, U160, U320, and SAS. Click on the link at the head of this paragraph for more details, if desired. The SCSI family of attachment interfaces is not hardware-compatible with the ATA family, nor do they use the same software command set, so you cannot mix SCSI drives with ATA controllers or ATA drives with SCSI controllers. Because they use different commands, Linux will enumerate them with different labels. This will be handled in more detail when it becomes important later.
A Brief History
editTo get an understanding of modern hard drives, it helps to have some background. The BIOS traditionally uses INT13h as an interface to the hard drive. INT13h, from a historical standpoint, had certain limitations. On the other hand, the IDE/ATA interfaces also had restrictions. These restrictions are highlighted in the table below.
Specification | Max Cylinders | Max heads | Max sectors | Max Size |
---|---|---|---|---|
IDE/ATA | 65,536 | 16 | 256 | 138GB |
INT13h | 1,024 | 256 | 63 | 528MB |
Clearly you can see that because of the limitations of INT13h and IDE/ATA (which we have highlighted) under the above scenario, the largest drive your average computer could handle was 528MB. We call this specification CHS (cylinder-head-sector). You may recall that to calculate the total size of a hard drive use the following formula:
- Cylinders * Heads * Sectors * 512 = Capacity
To get around this a new specification was implemented called ECHS (extended cylinder-head-sector), sometimes also referred to as "Large Mode". This introduced a translation layer between the BIOS and INT13h. The translation layer then allowed a computer to handle disk drives up to 8.4GB in size. We can see this with a modification to the table above, which we have set out below and highlighted the relevant row.
Specification | Max Cylinders | Max heads | Max sectors | Max Size |
---|---|---|---|---|
IDE/ATA | 65,536 | 16 | 256 | 138GB |
ECHS | 620 | 128 | 63 | 2.5GB |
INT13h | 1,024 | 256 | 63 | 8.4GB |
To see how the translation works, let's take a 2.5GB hard drive with 4960 cylinders, 16 heads, and 63 sectors. The translation program looks at the number of cylinders and makes a "best fit" with the INT13h limitation of 1,024 cylinders. The translation program does this by division, normally. It divides the number of cylinders by one of the following numbers: 2,4,6,8 and in some cases 16. In our case, 4960 / 8 = 620, which does not break the limitation of INT13h. Now the translation program multiplies the number of heads by 8, so 16 * 8 = 128. In this way, the translation program maintains the INT13h standard and provides a way in which the computer can see the whole disk. We can see this by calculating the disk space at both points previous translation and after.
- Native 4960 * 16 * 63 * 512 = 2.5GB
- Translation 620 * 128 * 63 * 512 = 2.5GB
The Table above needs a little more clarification. You will note that the maximum number of heads for the ECHS (translation layer) is 128, which is incompatible with the IDE/ATA Layer, which specifies a limit of 16. We get away with this because the translation layer is only concerned with INT13h and is not in any way related to the IDE/ATA layer. The next table will show how this model really looks.
Specification | Max Cylinders | Max heads | Max sectors | Max Size |
---|---|---|---|---|
Physical Drive | 4,660 | 16 | 63 | 2.5GB |
IDE/ATA | 65,536 | 16 | 256 | 138GB |
INT13h | 1,024 | 256 | 63 | 8.4GB |
ECHS | 620 | 128 | 63 | 2.5GB |
Needless to say, hard drives got a lot bigger than 8.4GB, so some other way was needed, as the cylinder-head-sector method was no longer a viable option. This is covered in the next section where we bring you right up to date.
LBA
editLBA (Logical Block Addressing) is the most common scheme in use today to get past the 528MB limit imposed on an IDE/ATA disk drive. With LBA each block has a unique identification number that starts at 0 and then 1,2,3,4,5... In order for this mechanism to work it must be supported by the BIOS, the operating system, and the IDE drive. A common misconception with LBA is that it is the LBA itself that gets around the 528MB limit when in fact LBA uses translation. When you enable LBA mode in a BIOS you are in effect enabling translation. The translation can be the same as ECHS as discussed above, or another algorithm can be used by a 3rd party. It is way beyond the scope of this course to look at these algorithms. But the point of 3rd party algorithms should be made. More and more with modern operating systems the BIOS is taking a back seat when "talking" to the drive, and modern operating systems now perform this function with their own interpretation of the ATA specification preferring to bypass the BIOS altogether.
IRQ
editThere are 16 IRQs (Interupt ReQuest) channels on x86 architecture. Of those only a few are freely available. The table below lists the IRQs that cannot be used in red and the IRQs that could be reassigned (providing that certain hardware does not exist in your system) in orange, and those that you are free to assign as you please in white.
IRQ No. | Hardware Assignment | IRQ No. | Hardware Assignment | IRQ No. | Hardware Assignment | IRQ No. | Hardware Assignment |
---|---|---|---|---|---|---|---|
0 | System timer | 4 | COM1 | 8 | Real Time Clock | 12 | PS2 Mouse |
1 | Keyboard | 5 | LPT2 / Sound Card | 9 | Available | 13 | Floating Point Proc |
2 | Handles IRQ 8 - 15 | 6 | Floppy Controller | 10 | Available | 14 | Primary IDE |
3 | COM2 | 7 | Parallel Port | 11 | Available | 15 | Secondary IDE |
In essence IRQs are used to halt the computer from processing any further information and immediately service the request from the interrupt. That being the device that is assigned to the interrupt. The table above explains what the IRQ architecture looked like under PIC (Programmable Interrupt Controller), however it does hide the issue of priorities. The priorities of the IRQ structure are given by 0-1-2-8-9-10-11-12-13-14-15-3-4-5-6-7. The reason 8-15 have a higher priority is that they hook into IRQ 2, in fact IRQ 2 can be said to be IRQ 9. What we have looked at here is somewhat historical. Under the above scenario adding new hardware quickly became an art and a pain! The advent of PCI and USB enabled a greater range of addresses and also the ability to just plug things in and go.
DMA
editDMA (Direct Memory Access) is a feature of the modern computer to enable devices to bypass the CPU when needing to write or read information to or from another device, the purpose of this is to take the load off the CPU and utilize the DMA controller and RAM to move blocks of data from one area to another. Although the CPU is never completely eliminated in a DMA transfer, its role is purely to initiate the process rather than manage it.
I/O
editI/O (Input / Output) refers to moving data among all devices, both external and internal, within a modern computer system. Some devices can perform both input and output functions. An example of this is a Network Card. Obviously keyboards, mouse, etc. are examples of input devices and monitors and printers are examples of output devices.
Putting it all together
editWhen you turn the PC on, BIOS instructions are loaded into RAM from a permanently available ROM chip on the motherboard. These instructions, after performing a POST, may further inform the processor where the operating system is located and how to load it into RAM. In order to allow operating systems and applications to run on a PC, the BIOS provides a standard layer of services that the operating system can use to "talk" to the hardware. In turn, the operating system provides standard services to applications to perform their functions. It is important to understand that not all operating systems use all BIOS services: some use their own instructions to access the hardware. The direct method of accessing the hardware may improve performance.
The BIOS utilizes a number of technologies to perform the services we have addressed above. However, as with all things in the computer industry, technology is moving forward fast. The BIOS performs a crucial role within the system and new technology added to the motherboard will normally require BIOS cooperation so that the OS can utilize the new technology.
By now you should have a good understanding of the BIOS and the role it performs with hardware. In the next section we look at Linux and how it interacts with the BIOS / Hardware. This will hopefully give you a system administrator's view of these relationships.
Viewing BIOS-related information in Linux
editIntroduction
editFrom this point onward it becomes necessary to have access to a Linux PC. Although some theory is involved, we shall be interacting with Linux more and more. I advise that you attempt the commands as you come across them, testing your understanding as you go. Do be careful with some of the commands as an incorrect switch, or in some cases running a command from the wrong directory is not healthy. (One famous example is running rm -R * from / as root.) So if you are new to Linux, be careful: don't misuse the root account. Only use it when you have to. I personally advise a separate Linux installation for the course that contains no personal data.
Understand that No author / contributor to this book is in any way responsible for any loss of data or damage to any hardware, however it is caused. Mistakes in typing can happen and this is an open book for anyone to edit regardless of their knowledge.
/proc
edit/proc is a pseudo-filesystem which is used as an interface to kernel data structures. Most of it is read-only, but some files allow kernel variables to be changed, particularly in /proc/sys. if you were to list the file system in /proc you would see something like this:
user@host:~$ cd /proc user@host:/proc$ ls 1 4190 5071 5462 5859 6 dma pagetypeinfo 128 4312 5103 5478 5867 6024 driver partitions 1475 44 5162 5547 5868 6553 execdomains sched_debug 1481 45 5164 5563 5871 6583 fb scsi 1508 4589 5205 5574 5879 6593 filesystems self 1524 4590 5224 5579 5880 6685 fs slabinfo 1526 4594 5227 5655 5884 6694 interrupts stat 165 4595 5289 5660 5890 6714 iomem swaps 166 4597 5302 5661 5892 6716 ioports sys 1784 4765 5315 5695 5901 6717 irq sysrq-trigger 1786 4805 5318 5697 5902 6735 kallsyms sysvipc 1787 4878 5328 5698 5903 7 kcore timer_list 2 4932 5336 5816 5905 acpi key-users timer_stats 207 4934 5356 5820 5912 asound kmsg tty 2272 4956 5362 5821 5915 buddyinfo loadavg uptime 2273 4972 5363 5829 5918 bus locks version 2515 4986 5370 5832 5925 cgroups meminfo version_signature 2718 4999 5373 5842 5938 cmdline misc vmcore 3 5 5378 5851 5941 cpuinfo modules vmnet 3181 5021 5416 5854 5970 crypto mounts vmstat 4 5042 5419 5856 5973 devices mtrr zoneinfo 41 5043 5423 5858 5982 diskstats net
The first thing that you will notice is the numbered directories these represent processes running on your system. Each numbered directory, has a common subset of directories that provide information about that process. The number representing the directory is consistent with the process number seen with the ps command. We cover processes in a later section.
The directories and files we are interested in are the following:
/proc/acpi * Power Management /proc/bus/pci * Note on some distributions this may be /proc/pci /proc/cpuinfo * processor information /proc/devices /proc/dma /proc/interrupts /proc/iomem /proc/ioports /proc/irq /proc/meminfo
Getting kernel information
edit/proc is a pseudo-filesystem which is used as an interface to kernel data structures. Most of it is read-only, but some files allow kernel variables to be changed.
Examples of available directories are:
[Number]: Process information running on the system. cmdline: The complete command line, cwd: The working directory, ...
/proc/uptime Since when the system is up and running. /proc/sys/kernel Kernel information. /proc/sys/net Network information. /proc/partitions Hard drive partitions information. /proc/scsi SCSI information. /proc/mounts Mounted file system information. /proc/devices List the loaded drivers. /proc/bus Bus information. /proc/version Linux version.
/proc/acpi
editacpi is the interface to monitor events and states.
Getting hard drive Information
editIn order to get disk information, use hdparm. More information is available at the hdparm man page
hdparm [options] [devices] Common options: -g: Get the disk geometry. -C: Display the power mode of the hard drive. active/idle: Normal operation, Standby: Low power mode, or sleeping: Lowest power mode. -v: Display all settings, except -i (same as -acdgkmnru for IDE, -gr for SCSI or -adgr for XT). This is also the default behaviour when no flags are specified.
Examples:
hdparm -g /dev/hda /dev/hda: geometry = 3648/255/63, sectors = 58605120, start = 0
hdparm -C /dev/hda /dev/hda: drive state is: active/idle
And more... Bold text
Exercises
edit- What is the RAM size of your system?
- Which devices are sharing an interrupt line?
- Use the lspci utility with the right option to draw the PCI architecture of your system.
- How many PCI buses and bridges are there?
- Are there any PCI/ISA bridges?
- What is the lspci option to list all the Intel PCI devices?
- What is the command to set your IDE hard drive to read-only mode?
- What is the command to turn on/off the hard drive disk cache?
- What does the setpci utility do? (Not mentioned in the above article, but do a web search to understand what it does)
- What is the command to write a word in register N of a PCI device?
- To show the amount of physical RAM available: use free or cat /proc/meminfo | grep MemTotal
- Which are the devices that are sharing an interrupt line? cat /proc/interrupts | more
- How many PCI buses and bridges are there? lspci | wc -l
- Are there any PCI/ISA bridges? lspci | grep 'PCI\|ISA'
- What is the option with lspci to list all the Intel PCI devices? lspci -d 8086:*
- What is the command to set you IDE hard drive in read only mode? hdparm -r1 <device>
- What is the command to turn on/off the disk cache hard drive? hdparm -W1 <device> hdparm -W0 <device>
- What does the setpci utility do? setpci is a utility for querying and configuring PCI devices.
- What would be the command to write a word in register N of a PCI device? setpci -s 12:3.4 N.W=1