Cisco router with an empty flash

Most people just order stuff from Cisco, opens the box, installs the fresh & new kit into the rack, poweres on and watches the IOS to load. But what if there is no IOS, just a blank flash memory? This could happen if things have gone bad (someone erased something), or you just ordered a new, empty flash and powered down the router. Where to go from here? Afraid no more, lone netwok warrior, here is the solution.

First and foremost, IOS has nothing to do with Apple, it's short for Internetworking Operating System. It's Cisco's OS for switches, routers, load balancers and many more. Some network admins never have to deal with it, but most have to. When there is no IOS to load, the network device will stay in rommon. This is a pre-booted state in which you have a limited number of options and only a subset of the normal commands to use. You will immediately be able to tell if you're stuck in rommon, because of two things. One is very obvious: the prompt will say: rommon (and a number). Second: none of the normal functions of the network device are working. Being stuck in rommon in case of a production device is definitely a showstopper (I learned this phrase back in 2007 when I was working with an airline, it comes from Queen's famous song about how the show must go on).

The solution is called environmental variables, and most linux / unix geeks are familiar with them. Environmental variables are present on windows too, but most people just never notice them. In this very case, you need to give a value to several environmental variables, to be able to move on. By moving on, I mean downloading an IOS image from your tftp server. That's right, you'll need a tftp server too. But I assume you already have one, most network admins have their favourite tftp server configured on their laptops exactly for cases like this. So fire it up, have your IOS image handy, and start typing:

rommon 1 > IP_ADDRESS=192.168.25.207
rommon 2 > IP_SUBNET_MASK=255.255.255.224
rommon 3 > TFTP_SERVER=192.168.25.212
rommon 4 > TFTP_FILE=/c1841-adventerprisek9-mz.124-25g.bin
rommon 5 > DEFAULT_GATEWAY=192.168.25.222

Use the environmental variables seen above and give them reasonable values. During the troubleshooting process, at this stage usually your laptop is within the same subnet with the intended network device, so most people would think a default gateway is not needed. It is. It's mandatory to specify a gateway value. Everything you see above is needed to be able to download the image. In my case, it's a 1841 router, as you can tell from the image file name. Below is a list of optional environmental variables, take a look at them, and decide if you need any of these:

  The following variables are OPTIONAL:
          TFTP_VERBOSE: Print setting. 0=quiet, 1=progress(default), 2=verbose
      TFTP_RETRY_COUNT: Retry count for ARP and TFTP (default=18)
          TFTP_TIMEOUT: Overall timeout of operation in seconds (default=7200)
         TFTP_CHECKSUM: Perform checksum test on image, 0=no, 1=yes (default=1)
               FE_PORT: 0= (default), 1
         FE_SPEED_MODE: 0=10/hdx, 1=10/fdx, 2=100/hdx, 3=100/fdx,
                        4=Auto (default)
      TFTP_DESTINATION: The flash destination device for the file
                        flash:(default), usbflash0:

After defining the variables you need, time to start the download process. Use the following command to download _and_ boot the IOS image:

rommon 6 > tftpdnld -r

The -r switch tells the rommon to load the image into DRAM and launch it, instead of downloading it onto the flash. What this means, that once the image is downloaded and executed, your switch will be booted. But not from the flash - directly from the network. After booting the network device, you still need to write a valid IOS to the flash memory, otherwise you'll have to repeat the process the next time you power off the device.