How to recover a Cisco router when the flash is erased
ElementZero | December 11, 2008I 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 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 now type set again to make sure you variables are set correctly. Once you make sure they are set right, just do 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 or depending on what you want.
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]
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
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.
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 doingcopy run tftpcopy start tftp






