Loading a New IOS Image:
You want to upgrade the IOS image that your router uses.
The copy tftp command allows you to use TFTP to download a new IOS version into the router’s flash memory:
Sooner or later you will need to upgrade your router’s IOS image. Common reasons for upgrading the IOS include new features, bug fixes, and security vulnerabilities. Before you attempt to upgrade your IOS, you should save a backup copy of your current IOS to your TFTP server, as discussed in Recipe 1.9.
You should always start by analyzing how much free space is available in your router’s flash to ensure that there is enough space to load the new IOS image. If there isn’t enough, then you may have to erase existing image(s) from flash as we did in our example. And in some cases, you may not have enough flash to load the new image at all. You can use the show flash command to see how much flash memory is available:
Some routers can support additional flash memory in the form of PCMCIA cards. The show slot0: and show slot1: commands will give you details about these additional storage locations. You can store IOS images on the flash cards, but keep in mind that the router will load the first available IOS image in the router’s main flash by default. Recipe 1.7 shows how to boot the router by using IOS images located on flash cards.
Before you can load an IOS image to your router, you must, of course, download the appropriate image from Cisco or purchase it on CD media. You will then need to move the new image into the TFTP directory to ensure that the file is world readable. On Unix systems, you can use the chmod command to do this. If the file is not world readable, the TFTP process will not be able to access it, and the IOS upgrade will fail. You should also do some simple sanity checks on the file by confirming the file size is correct and that the checksum or MD5 “fingerprint” match the values provided by Cisco. We note in passing that it would be extremely unwise to use an IOS image that was not created and supported by Cisco.
The router will do several tests while loading a new IOS image to ensure that the process goes smoothly. The first test is to see whether the TFTP server has the specified file:
Here you can see that the router tried to find the file on the TFTP server before going any further, and discovered that it was not present. If the file exists and the permissions are correct, then the router will continue with the dialogue. If your TFTP server keeps detailed logs of activity, you will see an aborted TFTP file transfer as the router checked to see if the file was available. These aborted attempts are normal and shouldn’t cause concern. If the requested file is present but not world-readable, the router will show an error message and abort the upgrade process:
Aborting the upgrade early in the process like this ensures that you don’t erase the flash unless there is a suitable replacement image available for download.
In the next step in the download process, you must tell the router whether or not to erase the flash before downloading a new image. If there is enough room available in flash then you can load the new image without erasing the existing image or images. However, if you attempt to download an image and you don’t have enough flash space available, then the router will protest and abort the procedure:
The process of upgrading your router’s IOS image is fairly forgiving. The router performs sanity checks throughout the process to ensure that image integrity is maintained. After downloading the image, the router does one final sanity check and verifies the image’s checksum. This ensures that the IOS image was not corrupted during transmission. If the image does not pass the verification test, attempt your download again and do not reload the router.
You can manually check to see if the IOS checksum is correct by using the verify command.
If the IOS upgrade goes smoothly and the checksum verifies correctly, then it is safe to reboot your router to load the new IOS image. Once the router becomes reachable again, you should verify the new IOS loaded correctly with the show version command:
In this example, you can see that the router’s boot sequence completed successfully correctly and that it’s running the new IOS version. Also, notice that the router’s new system image file matches the name of the file we just downloaded. This indicates the IOS upgrade was completely successful.