Managing Cisco Router Startup and Configuration
When a Cisco router boots, it performs a series of steps in a particular order. At several points during the process, the router makes a decision about the next step to take. Knowledge of the boot sequence can be of great help when troubleshooting a Cisco router and also when adjusting its configuration. The following sections describe each step in the router boot sequence.
Stages of the Router Power-On Boot Sequence
When a router boots, it performs a series of steps: performing tests, finding and loading the Cisco IOS Software, finding and loading configurations, and finally, running the Cisco IOS Software.
The sequence of events that occurs during the power-up (boot) process of a router is important. Knowledge of this sequence aids in accomplishing operational tasks and troubleshooting router problems.
When power is initially applied to a router, the events occur in the following order:
Step 1 Perform power-on self test (POST). This is a series of hardware tests that verifies whether all components of the Cisco router are functional. During this test, the router also determines what hardware is present. POST executes from microcode resident in the system ROM.
Step 2 Load and run bootstrap code. Bootstrap code is used to perform subsequent events, such as locating the Cisco IOS Software, loading it, and then running it. When the Cisco IOS Software is loaded and running, the bootstrap code is not used until the next time the router is reloaded or power cycled.
Step 3 The bootstrap code determines where the Cisco IOS Software to be run is located. Normally, the Cisco IOS Software image is located in the flash memory. The configuration register and configuration file determine where the Cisco IOS Software images are located and which image file to use.
Step 4 When the bootstrap code has found the proper image, it then loads that image into RAM and starts the Cisco IOS Software. Some routers do not load the Cisco IOS Software image into RAM, but execute it directly from flash memory.
Step 5 The default is to look in NVRAM for a valid saved configuration file, called startup-config.
Step 6 The desired configuration for the router is loaded and executed. If no configuration exists, the router will enter the setup utility or attempt an AutoInstall to look for a configuration file from a TFTP server.
Internal Router Components
The major internal components of a Cisco router include the interfaces, RAM, ROM, flash memory, NVRAM, and the configuration register. The major components of a router are shown in Figure 6-5.
Most of these components are hardware, as follows:
- CPU: This is the processor that runs the Cisco IOS and features like route processing.
- RAM: This read/write memory contains the software and data structures that enable the router to function. The principal software running in RAM is the Cisco IOS Software image and the running configuration. The RAM also contains the routing tables and packet buffers. RAM is volatile; its memory contents will be lost when power is turned off.
- ROM: This type of memory contains microcode for basic functions to start and maintain the router, including bootstrap and POST. The ROM contains the ROM Monitor (ROMMON) used for router disaster recovery functions, such as password recovery. The ROM also contains a subset of Cisco IOS, which is used for Cisco IOS image file recovery, such as when the Cisco IOS image file in flash memory is erased. ROM is nonvolatile; it maintains the memory contents even when the power is off.
- Flash memory: Flash read/write memory is primarily used to store the Cisco IOS Software image. Some routers run the Cisco IOS Software image directly from flash memory and do not need to transfer it to RAM. Some routers maintain a subset of the Cisco IOS Software in flash memory rather than in ROM. Flash memory is nonvolatile; it maintains the memory contents even when the power is off.
- NVRAM: This read/write memory is mainly used to store the saved configuration file, called the startup-config file. NVRAM uses a built-in battery to maintain the data when power is removed from the router.
- Configuration register: The configuration register is used to control how the router boots. The configuration register is part of the NVRAM.
- Interfaces: Interfaces are the physical connections to the external world for the router and include the following types, among others:
- Ethernet, Fast Ethernet, and Gigabit Ethernet
- Asynchronous and synchronous serial
- Token Ring
- Console and auxiliary ports
As shown in Figure 6-6, three major areas of microcode are generally contained in ROM.
The functions of these areas are as follows:
- Bootstrap code: The bootstrap code is used to bring the router up during initialization. It reads the configuration register to determine how to boot, and then, if instructed to do so, loads the Cisco IOS Software.
- POST: POST is the microcode used to test the basic functionality of the router hardware and determine which components are present.
- ROMMON: This is a low-level operating system normally used for manufacturing, testing, troubleshooting, and password recovery. In ROMMON mode, the router has no routing or IP capabilities.
NOTE Depending on the specific Cisco router platform, the components listed can be stored in flash memory or in bootstrap memory to allow a field upgrade to later versions.
How a Device Locates and Loads Cisco IOS Image and Configuration Files
When a Cisco router boots, it searches for the Cisco IOS image in a specific sequence: the location specified in the configuration register, flash memory, a TFTP server, and ROM. The bootstrap code is responsible for locating the Cisco IOS Software. It searches for the image according to the following sequence:
- The bootstrap code checks the boot field of the configuration register. The boot field is the lower 4 bits of the configuration register and is used to specify how the router boots. These bits can point to flash memory for the Cisco IOS image, the startup-config file (if one exists) for commands that tell the router how to boot, or a remote TFTP server. Or, these bits can specify that no Cisco IOS image is to be loaded and to just start the Cisco IOS subset image in ROM. The configuration register bits perform other functions as well, such as selecting the console baud rate and determining whether to use the saved configuration file (startup-config) in NVRAM.For example, a configuration register value of 0x2102 (the 0x indicates that the digits that follow are in hexadecimal notation) has a boot field value of 0x2 (the rightmost digit in the register value is 2 and represents the lower 4 bits of the register).
If the boot field value of the configuration register is from 0x2 to 0xF, the bootstrap code parses the startup-config file in NVRAM for the boot system commands that specify the name and location of the Cisco IOS Software image to load. Several boot system commands can be entered in sequence to provide a fault-tolerant boot plan. The boot system command is a global configuration command that allows you to specify the source for the Cisco IOS Software image to load. Some of the syntax options available include the following:
- boot system flash [filename]
- boot system tftp [filename][server-address]
- boot system rom
- If there are no boot system commands in the configuration, the router defaults to loading the first valid Cisco IOS image in flash memory and running it.
- If no valid Cisco IOS image is found in flash memory, the router attempts to boot from a network TFTP server using the boot field value as part of the Cisco IOS image file name.
NOTE Booting from a network TFTP server is a seldom-used method of loading a Cisco IOS Software image. Not every router has a boot helper image, so Steps 4 and 5 do not always follow.
- By default, if booting from a network TFTP server fails after five tries, the router will boot the boot helper image (the Cisco IOS subset) from ROM. The user can also set bit 13 of the configuration register to 0 to tell the router to try to boot from a TFTP server continuously without booting the Cisco IOS subset from ROM after five unsuccessful tries.
- If there is no boot helper image or if it is corrupted, the router will boot the ROMMON from ROM. When the router locates a valid Cisco IOS image file in flash memory, the Cisco IOS image is normally loaded into RAM to run, as shown in Figure 6-7. Some routers, including the Cisco 2500 series routers, do not have sufficient RAM to hold the Cisco IOS image and, therefore, run the Cisco IOS image directly from flash memory.
If the image is to be loaded from flash memory into RAM, it must first be decompressed. After the file is decompressed into RAM, it is started. Cisco IOS images that are run from flash memory are not compressed.
After the Cisco IOS Software image is loaded and started, the router must be configured to be useful. If there is an existing saved configuration file (startup-config) in NVRAM, it is executed. If there is no saved configuration file in NVRAM, the router either begins AutoInstall or enters the setup utility.
AutoInstall attempts to download a configuration from a TFTP server. AutoInstall requires a connection to the network and a previously configured TFTP server to respond to the download request.
The setup utility prompts a user at the console for specific configuration information to create a basic initial configuration on the router. Figure 6-8 shows how setup will copy the configuration file into running memory as well as NVRAM.
The show running-config and show startup-config commands are among the most common Cisco IOS Software EXEC commands, because they enable you to see the current running configuration in RAM on the router or the startup configuration commands in the startup-config file in NVRAM that the router will use on the next restart. If the words “Current configuration” are displayed, the active running configuration from RAM is being displayed.
If there is a message at the top indicating how much nonvolatile memory is being used, the startup configuration file from NVRAM is being displayed. This is shown in Figure 6-9.
Figure 6-9 Running Versus Startup Configuration In RAM
The configuration register includes information specifying where to locate the Cisco IOS Software image. You can examine the register with a show command, and you can change the register value with the config-register global configuration command. This topic describes how to display and change the boot information in the configuration register.
Before altering the configuration register, you should determine how the router is currently loading the software image. The show version command will obtain the current configuration register value. The last line of the display contains the configuration register value. This is shown in Example 6-6.
Example 6-6 Output of the show version Command
Cisco IOS Software, 2800 Software (C2800NM-IPBASE-M), Version 12.4(5a), RELEASE SOFTWARE (fc3)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2006 by Cisco Systems, Inc.
Compiled Sat 14-Jan-06 03:19 by alnguyen
ROM: System Bootstrap, Version 12.4(1r) [hqluong 1r], RELEASE SOFTWARE (fc1)
RouterX uptime is 1 week, 5 days, 21 hours, 30 minutes
System returned to ROM by reload at 23:04:40 UTC Tue Mar 13 2007
System image file is “flash:c2800nm-ipbase-mz.124-5a.bin”
Cisco 2811 (revision 53.51) with 251904K/10240K bytes of memory.
Processor board ID FTX1013A1DJ
2 FastEthernet interfaces
2 Serial(sync/async) interfaces
DRAM configuration is 64 bits wide with parity enabled.
239K bytes of non-volatile configuration memory.
62720K bytes of ATA CompactFlash (Read/Write)
Configuration register is 0x2102
You can change the default configuration register setting with the config-register global configuration command, as shown in Example 6-7.
Example 6-7 config-register Command
RouterA# configure terminal
RouterA(config)# config- register 0x21 00
The configuration register is a 16-bit register. The lowest 4 bits of the configuration register (bits 3, 2, 1, and 0) form the boot field. A hexadecimal number is used as the argument to set the value of the configuration register. The default value of the configuration register is 0x2102. The boot field would be the last digit in the hexadecimal register. The setting of this field determines how the device boots. This is illustrated in Table 6-1.
The guidelines for changing the boot field are as follows:
- The boot field is set to 0 to enter ROMMON mode automatically. This value sets the boot field bits to 0-0-0-0. In the ROMMON mode, the router displays the “>” or “rommon>” prompt, depending on the router processor type. From the ROMMON mode, you can use the boot command to manually boot the router.
- The boot field is set to 1 to configure the system to boot the Cisco IOS subset automatically from ROM. This value sets the boot field bits to 0-0-0-1. The router displays the Router(boot)> prompt in this mode.
- The boot field is set to any value from 0x2 to 0xF to configure the system to use the boot system commands in the startup-config file in NVRAM. The default is 0x2.
These values set the boot field bits to 0-0-1-0 through 1-1-1-1.
The show version command is used to verify changes in the configuration register setting. The new configuration register value takes effect when the router reloads.
In Example 6-6, the show version command indicates that the current configuration register setting of 0x2104 will be used during the next router reload.
NOTE When using the config-register command, all 16 bits of the configuration register are set. Be careful to modify only the bits that you are trying to change, for example, the boot field, and leave the other bits as they are. Remember that the other configuration register bits perform functions that include selecting the console baud rate and determining whether to use the saved configuration in NVRAM.
The show flash command displays the contents of flash memory, including the image file names and sizes. This is illustrated in Example 6-8.
Example 6-8 show flash Command
RouterX# sh flash
-#- --length-- -----date/time------ path
1 14951648 Feb 22 2007 21:38:56 +00:00 c2800nm-ipbase-mz.124-5a.bin
2 1823 Dec 14 2006 08:24:54 +00:00 sdmconfig-2811.cfg
3 4734464 Dec 14 2006 08:25:24 +00:00 sdm.tar
4 833024 Dec 14 2006 08:25:38 +00:00 es.tar
5 1052160 Dec 14 2006 08:25:54 +00:00 common.tar
6 1038 Dec 14 2006 08:26:08 +00:00 home.shtml
7 102400 Dec 14 2006 08:26:22 +00:00 home.tar
8 491213 Dec 14 2006 08:26:40 +00:00 128MB.sdf
41836544 bytes available (22179840 bytes used)
In the example, the bottom line tells how much flash memory is available. Some of it might already be in use. Flash memory is always read-only.