Loading System Image Files
When a Cisco router boots, one of the first things it does is look for the Cisco IOS software image. To successfully search, find, and load the image file, the router uses two special components:
- Bootstrap code
- Configuration register
The bootstrap code is a small piece of firmware stored in the router's ROM memory, and it is run as soon as the router is powered on or rebooted. The primary function of the bootstrap code is to run initial hardware tests, locate the Cisco IOS software image, and load it into RAM for execution. In other words, the bootstrap code is primarily responsible for configuring the initial conditions for the router's boot-up process.
The configuration register is a setting in the router's NVRAM. It is a 16-bit value that can be changed to control various aspects of the router's startup behavior. For instance, whether the router loads the startup configuration during the boot-up process or to skip it. The value of the configuration register is expressed in hexadecimal and is commonly referred to as the "config register" or "confreg." The default configuration register is 0x2102.
Now, let’s find out how the bootstrap code and the configuration register are interconnected and help the boot-up process of the router.
During boot-up, the configuration register instructs the bootstrap code where to look for the Cisco IOS software image. The configuration register value determines the order in which the bootstrap code looks for the IOS image, for example, in flash memory, or a TFTP server. This way, you can specify the source for the image file based on your requirements.
In addition, the configuration register can also control the router's boot behavior, which can come in handy when troubleshooting or recovering from a certain problematic situation, such as a forgotten password for the router’s privilege mode.
For instance, based on your goal, you can define the configuration register as whether the router loads the startup configuration from NVRAM or ignores it during boot-up to perform password recovery.
As you can see in the image above, the right-most digit in the register value represents the lowest 4 bits of the register. By default, this is 2 (0x2102). However, by changing this value, you can achieve different results, such as:
- If the boot field value is 0x0, the router boots to the ROMMON session, which is used only for password recovery or downloading a software image into flash memory when none is available.
- If the boot field value is 0x1, the router searches flash memory for Cisco IOS images and loads the first one from the list of available images.
- When the boot field value is between 0x2 and 0xF, the router uses the startup settings, if available, such as boot system commands that specify the location of the Cisco IOS software image. If the image is found, it is loaded. On the other hand, the router looks for the image in the router's flash memory and loads the first available one from the list.
To view the current configuration register on the router, use the “show version” command. If you want to change it, use the “config-register value” command. In addition, to manually define which software image to load on the router during booting up, you need to use the “boot system” global configuration command and specify the desired image, for example, “boot system flash:/c2900-universalk9-mz.SPA.154-1T.bin.”