Managing Cisco IOS Software Images 659 Figure 14-4 Capturing the Config File After the capture is complete, you need to edit the configuration file to remove extra text. To create this file in a form to be copied and pasted back into the router, remove any unnecessary information from the captured configuration. You can add comments to the text to explain the various parts of the configuration. Add a comment by begin- ning a line with an exclamation mark (!). You can edit the configuration file from a text editor such as Notepad. To edit the file from Notepad, complete the following steps: Step 1 Click File > Open. Step 2 Find the captured file and select it. Step 3 Click Open. The lines you need to delete contain the following: ■ show running-config ■ Building configuration ■ Current configuration: ■ - More - ■ Any lines that appear after the word End 1102.book Page 659 Tuesday, May 20, 2003 2:53 PM 660 Chapter 14: Managing Cisco IOS Software At the end of each of the interface sections, add the no shutdown command. Clicking File > Save saves the clean version of the configuration. You can then restore the backup configuration from a HyperTerminal session. How- ever, before you restore the configuration, remove any remaining configuration from the router, which you can do by entering the command erase startup-config at the enable router prompt and then restarting the router by entering reload. After you remove any remaining configuration, you can use HyperTerminal to restore a configuration. You can copy the clean backup of the configuration into the router as follows: Step 1 Go into the router global configuration mode. Step 2 From the HyperTerminal, choose Transfer > Send > Text File. Step 3 Select the name of the file for the saved backup configuration. Step 4 The lines of the file are entered into the router as if the lines are being typed. Step 5 Look for any errors. Step 6 After the configuration is entered, press Ctrl + z to exit the global config- uration mode. Step 7 Restore the startup configuration with copy running-config startup-config. Managing Cisco IOS Software Images with TFTP Occasionally, the router will need to have the Cisco IOS Software image upgraded or restored. The first time a router is used, the Cisco IOS Software should be backed up to a TFTP server using the copy flash tftp command. This Cisco IOS Software image can be stored in a central server with other Cisco IOS Software images to restore or upgrade the Cisco IOS Software image on routers and switches in the internetwork. This server should have a TFTP service running. You can initiate the Cisco IOS Soft- ware upgrade from the privilege EXEC mode with the copy tftp flash command as shown in Example 14-9. Lab Activity Copying, Editing, and Pasting Configurations In this activity, you capture the running configuration of a router to an ASCII text file with HyperTerminal. You clean up the configuration by editing or modifying the captured text file with a text editor such as Notepad. Then, you upload the clean text file to configure another router using HyperTerminal. 1102.book Page 660 Tuesday, May 20, 2003 2:53 PM Managing Cisco IOS Software Images 661 The router prompts you to enter the IP address of the TFTP server. When you are prompted for the filename of the Cisco IOS Software image on the server, the router might then prompt you to erase Flash. This prompt to erase Flash often happens if there is not sufficient Flash memory available for the new image. As the image is erased from Flash, a series of letter “e”s appear to show the erase process. As each datagram of the Cisco IOS Software image file is downloaded, an “!” will be displayed. This Cisco IOS Software image is several megabytes in size and might take some time to download. The new Flash image is verified after it is downloaded. The router is now ready to be reloaded to use the new Cisco IOS Software image. Example 14-10 uses a different router and TFTP server and provides additional infor- mation on the steps used to copy the Cisco IOS Software image from the TFTP server back to the router. After you enter the copy tftp flash command, as shown in Example 14-10, the system prompts you for the IP address (or name) of the TFTP server. This address or name can be another router serving ROM or Flash software images. The system then prompts you for the filename of the software image. Example 14-10 shows sample output from copying a system image, named C4500-I, into Flash memory. Example 14-9 Backing Up Cisco IOS Software to a TFTP Server Cougar# copy tftp flash Address or name of remote host []? 192.168.119.20 Destination filename [C2600-js-l_121-3.bin]? Accessing tftp://192.168.119.20/C2600-js-l_121-3.bin Erase flash: before copying? [confirm] Erasing the flash file system will remove all files Continue? [confirm] Erasing device eeeeee…eeeeeeeeeeeee…erased Loading C2600-js-l_121-3.bin from 192.168.119.20 (via FastEthernet 0/0): !!!!!!!!!!!!!!…!!!!!!!!!!!!!!!!!! Verifying Check sum…………………… OK [OK-8906589 bytes] 8906589 bytes copied in 277.45 secs Cougar# NOTE The symbol “!” means that the Flash file is loading success- fully. The symbol “.” means that the Flash file cannot be found. If the symbol “.” appears, make sure you typed the correct command syntax. 1102.book Page 661 Tuesday, May 20, 2003 2:53 PM 662 Chapter 14: Managing Cisco IOS Software If you attempt to copy into Flash memory a file that is already there, a prompt tells you that a file with the same name already exists. This file is deleted when you copy the new file into Flash memory. If there is room for both copies in Flash memory, the first copy of the file still resides within Flash memory, but is rendered unusable in favor of the newest version; it will be listed with the [deleted] tag when you use the show flash command. If you abort the copy process, the newer file will be marked (deleted) because the entire file was not copied and is, therefore, not valid. In this case, the original file still resides within Flash memory and is available to the system. Managing Cisco IOS Software Images with ROMmon If the Cisco IOS Software image in Flash has been erased or corrupted, you might need to restore the Cisco IOS Software image from the ROM monitor mode (ROMmon). In many of the Cisco hardware architectures, the ROMmon mode is identified from the rommon# > prompt. Example 14-10 Copying the Cisco IOS Software Image from the TFTP Server to the Router Router# copy tftp flash IP address or name of remote host [255.255.255.255]? 172.16.13.111 Name of tftp filename to copy into flash []? c4500-I copy C4500-I already exists; it will be invalidated! Copy C4500-I from 172.16.13.111 into flash memory? [confirm] xxxxxxxx bytes available for writing without erasure. erase flash before writing? [confirm] Clearing and initializing flash memory [please wait] #### ## Loading from 172.16.13.111: !!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!! (text omitted) [OK – 324572/524212 bytes] Verifying checksum VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VVVVVVVVV (text omitted) Flash verification successful. Length = 1204637, checksum = 0x95D9 Lab Activity Managing IOS Images with TFTP In this activity, you back up a copy of a router’s Cisco IOS image to a TFTP server. You then reload the backup copy from the TFTP server into Flash mem- ory on the router. 1102.book Page 662 Tuesday, May 20, 2003 2:53 PM Managing Cisco IOS Software Images 663 The first step in this process is to identify why the Cisco IOS Software image did not load from Flash. This problem could be due to a corrupt or missing image or damaged Flash memory. Examine the Flash memory with the dir flash: command. If you locate an image that appears to be valid, attempt to boot from that image. You perform this boot attempt by using the boot flash: command. For example, if the image name is c2600-is-mz.121-5, the command is as follows: rommon > boot flash:c2600-is-mz.121-5 You need to check a couple of items if the router boots properly because you need to be determine why the router booted to the ROMmon instead of using Cisco IOS Soft- ware from Flash. First, use the show version command to check the configuration reg- ister to ensure that it is configured for the default boot sequence. If the configuration register value is correct, use the show startup config command. This command shows if there is a boot system command instructing the router to use the Cisco IOS Software for ROMmon. If the router will not properly boot from the image or there is no Cisco IOS Software image, you need to download a new Cisco IOS Software image. You can recover the Cisco IOS Software file either through using Xmodem to restore the image through the console or by downloading the image using TFTP from the ROMmon mode. Downloading Cisco IOS Software Using Xmodem from ROMmon To restore the Cisco IOS Software image through the console, the local PC needs to have a copy of the Cisco IOS Software file to restore and a terminal emulation pro- gram such as HyperTerminal. You can restore the Cisco IOS Software image using the default console speed of 9600 bps. You can change the baud rate to 115200 bps to speed up the download. You can change the console speed from ROMmon mode using the confreg command. After you enter the confreg command, the router will prompt for the various parameters that can be changed, as shown in Example 14-11. Example 14-11 Changing the Console Speed rommon 1 >confreg Configuration Summary …<output omitted>… console baud: 9600 boot: the ROM Monitor do you wish to change the configuration? y/n [n]: y enable "diagnostic mode"? y/n [n]: continues 1102.book Page 663 Tuesday, May 20, 2003 2:53 PM 664 Chapter 14: Managing Cisco IOS Software You must reset or power cycle for the new config to take effect. When prompted: “change console baud rate? y/n [n]:” selecting y provides you with a prompt to select the new speed. After changing the console speed, restart the router into the ROMmon mode. The terminal session at 9600 bps is terminated, and a new session is started at 115200 bps to match the console speed. You can use the xmodem command from the ROMmon mode to restore a Cisco IOS Software image from the PC. The format for the xmodem command is as follows: xmodem -c image_file_name For example, to restore a Cisco IOS Software image file with the name c2600-is- mz.122-10a.bin, type the command as shown in Example 14-12. …<output omitted>… enable "ignore system config info"? y/n [n]: change console baud rate? y/n [n]: y enter rate: 0 = 9600, 1 = 4800, 2 = 1200, 3 = 2400 4 = 19200, 5 = 38400, 6 = 57600, 7 = 115200 [0]: 7 change the boot characteristics? y/n [n]: Configuration Summary enabled are: break/abort has effect console baud: 115200 boot: the ROM Monitor do you wish to change the configuration? y/n [n]: Example 14-12 Restoring a Cisco IOS Software Image File with the xmodem Command rommon 1 > rommon 1 >xmodem -? xmodem: illegal option ? usage: xmodem [-cyrx] <destination filename> -c CRC-16 -y ymodem-batch protocol -r copy image to dram for launch -x do not launch on download completion Example 14-11 Changing the Console Speed (Continued) 1102.book Page 664 Tuesday, May 20, 2003 2:53 PM Managing Cisco IOS Software Images 665 The -c in the command format instructs the Xmodem process to use cyclic redundancy check (CRC) for error checking during the download. You will receive a prompt from the router to not begin the transfer and a warning mes- sage will be shown. The warning message indicates that the bootflash will be erased, and the router asks to confirm whether or not to continue with the process. When you continue the process, the router then prompts to start the transfer. You now need to start the Xmodem transfer from the terminal emulator. In Hyper- Terminal, select Transfer > Send. Then, in the Send File popup, specify the image name/location, select Xmodem as the protocol, and start the transfer. During the trans- fer, the Sending File popup displays the status of the transfer. After the transfer is complete, a message appears indicating that flash is being erased. This message is followed by the “Download Complete!” message. Before restarting the router, you need to set the console speed back to 9600 bps and the configuration register back to 0x2102. Use the confreg 0x2102 command at the privileged EXEC prompt to set back the configuration register. While the router is rebooting, you need to end the 115200 bps terminal session and begin a 9600 bps session. Using Environmental Variables for Restoring Cisco IOS Software Images You can also restore the Cisco IOS Software from a TFTP session. Downloading the image using TFTP from ROMmon is the fastest way to restore a Cisco IOS Software image to the router. You perform this process by setting the environmental variables and then using the tftpdnld command. rommon 2 > xmodem -c c2600-is-mz.122-10a.bin Do not start the sending program yet Warning: All existing data in bootflash will be lost! Invoke this application only for disaster recovery. Do you wish to continue? y/n [n]: y Ready to receive file c2600-is-mz.122-10a.bin Example 14-12 Restoring a Cisco IOS Software Image File with the xmodem Command (Continued) 1102.book Page 665 Tuesday, May 20, 2003 2:53 PM 666 Chapter 14: Managing Cisco IOS Software Because ROMmon has limited functions, no configuration file is loaded during boot. The router, therefore, has no IP or interface configuration. The environmental vari- ables provide a minimal configuration to allow for the TFTP of the Cisco IOS Soft- ware image. The ROMmon TFTP transfer works only on the first LAN port, so a simple set of IP parameters are set for this interface. To set a ROMmon environment variable, you type the variable name, then the equal sign (=), and the value for the vari- able (VARIABLE_NAME=value). For example, to set the IP address to 10.0.0.1, type IP_ADDRESS=10.0.0.1 at the ROMmon prompt. The minimum variables required to use tftpdnld are as follows: ■ IP_ADDRESS—The IP address on the LAN interface ■ IP_SUBNET_MASK—The subnet mask for the LAN interface ■ DEFAULT_GATEWAY—The default gateway for the LAN interface ■ TFTP_SERVER—The IP address of the TFTP server ■ TFTP_FILE—The Cisco IOS Software filename on the server To check the ROMmon environment variables, you can use the set command, as shown in Example 14-13. Once you set the variables for the Cisco IOS Software download, you enter the tftpdnld command, as shown in Example 14-14, with no arguments. The ROMmon echoes the variables, and then a confirmation prompt appears with a warning that this process will erase the Flash memory. Example 14-13 Checking ROMmon Environmental Variables rommon 10> set IP_ADDRESS=10.0.0.1 IP_SUBNET_MASK=255.255.255.0 DEFAULT_GATEWAY=10.0.0.254 TFTP_SERVER=192.168.1.1 TFTP_FILE=GAD/original_2003_Jan_22/c2600-i-mz.121-5 Example 14-14 tftpdnld rommon 12 > tftpdnld IP_ADDRESS: 10.0.0.1 IP_SUBNET_MASK: 255.255.255.0 DEFAULT_GATEWAY: 10.0.0.254 TFTP_SERVER: 192.168.1.1 N O TE All environmental variable names are case sensitive. 1102.book Page 666 Tuesday, May 20, 2003 2:53 PM Managing Cisco IOS Software Images 667 As each datagram of the Cisco IOS Software file is received, a “!” is displayed. When the complete Cisco IOS Software file has been received, the Flash is erased and the new IOS image file is written. Appropriate messages are displayed as the process is completed. When the new image is written into Flash and the ROMmon prompt is displayed, you can restart the router by typing i. The router now boots from the new Cisco IOS Soft- ware image in Flash memory. Verifying the File System You can use several commands to verify the router file system. One of those commands is the show version command, which you can use to check the current image and the total amount of Flash memory This command also verifies two other items concerning loading the Cisco IOS Software image. The show version command identifies the source of the Cisco IOS Software image that the router used to boot and displays the configu- ration register. You can examine the boot field setting of the configuration register to determine where the router is to load the Cisco IOS Software image. If the current image and the boot field setting of the configuration register do not agree, there might be a corrupt or missing Cisco IOS Software image in Flash or there might be boot sys- tem commands in the startup config. Example 14-15 demonstrates use of the show version command. TFTP_FILE: GAD/original_2003_Jan_22/c2600-i-mz.121-5 Invoke this command for disaster recovery only. WARNING: all existing data in all partitions on flash will be lost! Do you wish to continue? y/n: [n]: y Receiving GAD/original_2003_Jan_22/c2600-i-mz.121-5 from 192.168.1.1!!!!.!!!!!!!!!!!!!!!!!!!.!! File reception completed. Copying file GAD/original_2003_Jan_22/c2600-i-mz.121-5 to flash. Erasing flash at 0x607c0000 program flash location 0x60440000 rommon 13> Lab Activity Managing IOS Images with ROMmon and Xmodem In this activity, you recover a Cisco 1700 series router from ROM monitor mode due to missing or corrupt IOS / boot flash image. Example 14-14 tftpdnld (Continued) 1102.book Page 667 Tuesday, May 20, 2003 2:53 PM 668 Chapter 14: Managing Cisco IOS Software You can also use the show flash command to verify the file system and to identify the Cisco IOS Software image or images in Flash and the amount of Flash memory that is available. The show flash command is often used to confirm that there is enough space to store a new Cisco IOS Software image. Example 14-16 demonstrates sample output from the show flash command. As mentioned, the configuration file might contain boot system commands. You can use these commands to identify the source of the desired Cisco IOS Software boot image. You can use multiple boot system commands to create a fallback sequence to discover and load a Cisco IOS Software image. These boot system commands are pro- cessed in the order of their appearance in the configuration file. Example 14-15 Verifying the Router File System HMH# show version Cisco Internetwork Operating System Software IOS (tm) 1700 Software (C1700-BNSY-L), Version 12.2(11)P, RELEASE SOFTWARE (fc1) … <output omitted>… System image file is "flash:c1700-bnsy-l.122-11.p", booted via flash cisco 171 (68360) processor (revision C) with 3584K/512K bytes of memory. Processor board ID 12014633, with hardware revision 00000000 Bridging software. X.25 software, Version 2.0, NET2, BFE and GOSIP compliant. 1 Ethernet/IEEE 802.3 interface(s) 2 serial(sync/async) network interface(s) System/IO memory with parity disabled 2048K bytes of DRAM onboard 2048K bytes of DRAM on SIMM System running from FLASH 8K bytes of non-volatile configuration memory. 6144K bytes of processor board PCMCIA flash (Read ONLY) Configuration register is 0x2102 HMH# Example 14-16 show flash Command Output Router# show flash 4096 bytes of flash memory on embedded flash (in XX). file offset length name 0 0x40 1204637 xk09140z [903848/2097152 bytes free] 1102.book Page 668 Tuesday, May 20, 2003 2:53 PM . IP_ADDRESS =10 .0.0 .1 IP_SUBNET_MASK =25 5 .25 5 .25 5.0 DEFAULT_GATEWAY =10 .0.0 .25 4 TFTP_SERVER =19 2 .16 8 .1. 1 TFTP_FILE=GAD/original _20 03_Jan _22 /c2600-i-mz . 12 1-5 Example 14 -14 tftpdnld rommon 12 > tftpdnld IP_ADDRESS:. tftp flash Address or name of remote host []? 19 2 .16 8 .11 9 .20 Destination filename [C2600-js-l _ 12 1-3.bin]? Accessing tftp:/ /19 2 .16 8 .11 9 .20 /C2600-js-l _ 12 1-3.bin Erase flash: before copying? [confirm] Erasing. y Receiving GAD/original _20 03_Jan _22 /c2600-i-mz . 12 1-5 from 19 2 .16 8 .1. 1!!!!.!!!!!!!!!!!!!!!!!!!.!! File reception completed. Copying file GAD/original _20 03_Jan _22 /c2600-i-mz . 12 1-5 to flash. Erasing