Musings of a technophile

Just another blog from a computer nerd
  • Home
  • About Me
  • Funny things my kids say

How to recover a Cisco router when the flash is erased

ElementZero | December 11, 2008

I have a few routers at my work place, and I wanted to move some of them around in order to get some more redundancy going with hsrp (Hot Standby Router Protocol). I took an old router we had and booted it up on the serial port. Before making any changes I wanted to save the config real quick, so I thought saving it to the flash drive would be good enough. To do this I did
copy run flash
This will ask you
Destination filename [my-config]?
Unfortunately I got a little enter button happen and hit enter twice, making it go ahead and accept the default on the next question, which unfortunately is:
Erase flash: before copying? [confirm]

Well. That sucks. If you delete the IOS image file off the flash disk, the router will fail to boot up again. This is probably why you don't want to save things to the flash anyways, but as I said I was looking for the quickest method. Also note though that this can happen if your flash device was corrupted, so don't go thinking that as long as you don't wipe the flash clean, you'll be safe.

Since I'm the kind to want to know what happens and how to fix it if something like this happens, I decided to go for it and rebooted the router. Of course, once the router reboots, it will try to load the image off the flash device. This will occur three times before the router just throws you to rommon, which is the recovery console for the router.

Now the most important thing you want to have is a valid backup of your Cisco IOS image (the file that was deleted off the flash drive) so that you can put it back onto the flash drive. The best way to do this is via TFTP. In rommon, all the settings are just saved in variables, and you can use the set command to see what variables are defined. You set the variables but just typing them in, so for instance you just type

rommon 1 > IP_ADDRESS=172.18.16.76
rommon 2 > IP_SUBNET_MASK=255.255.255.192
rommon 3 > DEFAULT_GATEWAY=172.18.16.65
rommon 4 > TFTP_SERVER=172.18.16.2
rommon 5 > TFTP_FILE=c2600-i-mz.bin

now type set again to make sure you variables are set correctly. Once you make sure they are set right, just do

rommon 6 > tftpdnld
to download the file. Once the file has been successfully stored on the flash drive, you can just reboot the router by issuing the reset command, and should be able to load up from the image file again.

By the way, you can use any tftp server to download the file from. tftp comes with many linux distro's, and for Windows there are some good ones like tftpd32 and (my favorite) pumpKIN.

Also - if anything this document should show you that you should ALWAYS backup you Cisco IOS image file. If you lose that file, you'll have to call Cisco and get a contract with them if you don't have one already ($$). Then you can use their site to download the correct firmware for your router. In order to backup the file from the flash, you need to find out what the name is the file is first. You can do by running the command
show ver
and it will have a line like
System image file is "flash:c2600-i-mz.120-7.T"
now just do
copy flash:c2600-i-mz.120-7.T tftp
replacing the file name with the value you saw in the show version output. This will ask you for the ip address of the tftp and the file name to save the file as, and then transmit the file. Additionally you can backup your current config to the tftp server by doing

copy run tftp

or

copy start tftp

depending on what you want.

Categories
Computer Troubleshooting
Tags
Cisco
Comments rss
Comments rss
Trackback
Trackback

« Upgraded to WordPress 2.7 Differences in men and women with how sex drugs are treated »

Leave a Reply

Click here to cancel reply.

Categories

  • Anime
    (8)
  • Computer Troubleshooting
    (24)
  • Games
    (17)
  • Family and Everyday Life
    (25)
  • Misc Thoughts
    (13)

Search

Archives

  • June 2010 (2)
  • May 2010 (7)
  • April 2010 (1)
  • January 2010 (1)
  • November 2009 (1)
  • July 2009 (1)
  • May 2009 (1)
  • April 2009 (3)
  • March 2009 (5)
  • February 2009 (8)
  • January 2009 (11)
  • December 2008 (12)
  • November 2008 (12)
  • October 2008 (11)
  • September 2008 (8)

Tags

Apple ASP.NET Blizzard Cisco coding computer repair Disney ecchi Ethan Exchange firewall Food Fort Myers FPS furniture hacking iis 7 jokes Kaden linux Logan Madelyn movies networking Racing RTS SEO Server Administration Shonen SQL SSRS 2005 StarCraft II Warcraft III Windows Server 2008 WordPress Zoo
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox Admin Login