Upgrading The IOS On A Switch (The Right Way)

Since I’ve made a couple of postings describing flash upgrade horror stories, I thought I’d include a description of how to do it the right way.

Selecting an image

First verify your hardware, either use the web interface or use show version at the CLI.

  1. Go to cisco.com and login with your CCO account.
  2. Click Support from the menu
  3. Click Download Software in the “select a task” window
  4. Choose Switches Software from the list
  5. Choose LAN Switches from the list
  6. Expand the Cisco Catalyst 2950 Series Switches group
  7. Choose the type of 2950 switch, in this example choose Cisco Catalyst 2950G 48 EI Switch
  8. Choose IOS Software from the list
  9. And select the software version you want

Some advice on choosing images:

  • Generally speaking, I’d say take the latest image. If your hardware is relatively old, then the newest code is probably bugfixes only and will not be introducing new features (and their bugs). If this was newer hardware, I’d recommend you carefully read the release notes.
  • Never load the deferred releases — these have serious bugs in stability or performance. If the code you’re running right now is deferred, or isn’t listed at all then I’d say an upgrade to newer code is very important.
  • Choose an image that represents what flash resources you have — I like the image C2950 EI AND SI IOS CRYPTO AND WEB BASED DEVICE MANAGER because it supports ssh, and it has a web interface (SDM) built in. But the web SDM takes up flash space, so make sure you review your switch flash resources to make sure it can handle the larger file.

Prepare the TFTP server with images

You will need the tftp SERVER, not just the client. Check your documentation, but in Linux you usually have to modify /etc/default/tftpd to enable the tftpd service. Solarwinds makes a free win32 tftp server as well.

The tftpd root folder can be anywhere, but usually it is either /tftpboot or /var/lib/tftpboot; in Windows you can easily specify this folder to be wherever you want, but I’d recommend you create a tftpboot folder off the root of your drive. Put the tar files in the tftpd root folder.

It is a little easier to test these issues from a PC client; so you can save some troubleshooting time by testing if you can download the image from a PC tftp client, Windows ships with tftp so just login and download a file to test. If you’re running Linux then you might have to load the tftp client from your distribution repos.

Loading the new image

Connect to the CLI, and go into enable mode. You can tell you’re in enable mode when you see the # in the prompt.

[code]]czo2NTpcIlVzZXIgQWNjZXNzIFZlcmlmaWNhdGlvbg0KUGFzc3dvcmQ6DQpTVzAyJmd0O2VuDQpQYXNzd29yZDoNClNXMDIjXCI7e1smKiZdfQ==[[/code]

Verify the space in the flash with dir. Chances are pretty good there is only room for one image at a time, but if you’re lucky you can fit two images.

[code]]czo2MDA6XCJTVzAyI2Rpcg0KRGlyZWN0b3J5IG9mIGZsYXNoOi8NCjIgICAtcnd4IDM3MjE5NDYgTWFyIDA3IDE5OTMgMjI6Mzk6MDJ7WyYqJl19ICswMDowMCBjMjk1MC1pNmsybDJxNC1tei4xMjEtMjIuRUExMy5iaW4NCjMgICAtcnd4ICAgIDIzMTYgTWF5IDI5IDIwMDggMjA6M3tbJiomXX0yOjEwICswMDowMCB2bGFuLmRhdA0KNCAgIC1yd3ggICAgIDExMiBNYXIgMDcgMTk5MyAyMjozNjoxMCArMDA6MDAgaW5mbw0KMTYge1smKiZdfSAtcnd4ICAgIDI4MDQgTWFyIDAxIDE5OTMgMDA6MDg6MjUgKzAwOjAwIGNvbmZpZy5vbGQNCjIyICAtcnd4ICAgICAzMzMgTWFyIDB7WyYqJl19NyAxOTkzIDIyOjQwOjQ4ICswMDowMCBlbnZfdmFycw0KMzM0IC1yd3ggICAgICAyNCBNYXIgMDEgMTk5MyAyMTowNDoyOCArMDA6MHtbJiomXX0wIHByaXZhdGUtY29uZmlnLnRleHQNCjYgICBkcnd4ICAgIDQ0MTYgTWFyIDA3IDE5OTMgMjI6NDA6MDQgKzAwOjAwIGh0bWwNCjE5e1smKiZdfSAgLXJ3eCAgICAgMTEyIE1hciAwNyAxOTkzIDIyOjQwOjM5ICswMDowMCBpbmZvLnZlcg0KMjQgIC1yd3ggICAgMjA2OCBNYXIgMDF7WyYqJl19IDE5OTMgMjE6MDQ6MjggKzAwOjAwIGNvbmZpZy50ZXh0DQo3NzQxNDQwIGJ5dGVzIHRvdGFsICgyMTM4NjI0IGJ5dGVzIGZyZWUpXCJ7WyYqJl19O3tbJiomXX0=[[/code]

If by some happy chance you’ve got more than 16Mb flash you probably have room for two images. But I think this is not the case, so you will have to erase the flash. You can go file by file with delete, but you’re better off just recursively wiping it like this.

[code]]czoyOTpcIlNXMDIjZGVsZXRlIC9yZWN1cnNpdmUgZmxhc2g6XCI7e1smKiZdfQ==[[/code]

Give yourself some peace of mind, and write the current running configuration to flash again to make sure it isn’t lost when you reboot. The startup config is written to an internal nvram flash, so this probably isn’t required, but I do it because it makes me feel better.

[code]]czoxOTpcIlNXMDIjY29weSBydW4gc3RhcnRcIjt7WyYqJl19[[/code]

Now the switch is ready to load the images from your TFTP server. Remember that TFTP is a UDP protocol, and has no inherent error correction — so make sure the link between the TFTP server and the switch is not lossy (like wireless or over the internet), a server on the same IP subnet is a good solution.

You can load a binary IOS image by tftp like this: copy tftp flash and then just follow the prompts in the script. But the problem is that the binary IOS image doesn’t have the web interface files, and you (probably) don’t have the space to copy the archived binary+webfiles and then extract it locally. So Cisco has a script that can download the archived binary+webfiles and extract it on the fly.

[code]]czo4NjpcIlNXMDIjYXJjaGl2ZSB0YXIgL3h0cmFjdCB0ZnRwOi8vMTkyLjE2OC4yLjExL2MyOTUwLWk2azJsMnE0LXRhci4xMjEtMjJ7WyYqJl19LkVBMTMudGFyIGZsYXNoOlwiO3tbJiomXX0=[[/code]

And now you watch the magic. Once the system is done downloading and extracting the images, you will reload and if all went well, you’ll be running on the new code.

NB: If you managed to squeeze two IOS binaries on one image, you will have to specify which one you want to boot from — this is not an issue if you erased the flash as described earlier.

  1. Figure out exactly which binary you want to boot from; use dir to list the files and look for those that end in “.bin”
  2. Make sure that there isn’t already a boot variable set; sh run | i boot should list any entries. If they’re in there, remove them. These boot parameters are processed in order, so you want to make sure your new image is first in the config — you can add the lines for any other images you’ve got on the flash after your new image.
  3. Set the new boot image:
[code]]czo5NjpcIlNXMDIjY29uZiB0DQpTVzAyKGNvbmZpZykjYm9vdCBzeXN0ZW0gZmxhc2g6L2MyOTUwLWk2azJsMnE0LW16LjEyMS0yMi57WyYqJl19RUExMy5iaW4NClNXMDIoY29uZmlnKSNlbmRcIjt7WyYqJl19[[/code]

Finally you write the new configuration and reload.

[code]]czozMjpcIlNXMDIjY29weSBydW4gc3RhcnQNClNXMDIjcmVsb2FkXCI7e1smKiZdfQ==[[/code]

One thought on “Upgrading The IOS On A Switch (The Right Way)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s