How does router determine which IOS to boot?

Unanswered Question
Mar 18th, 2009


I had a situation this morning. I had two IOS images in flash. In the running config, I told it which IOS to boot, but either it lost the config or I forgot to write it (probably the latter), and it booted the other image. The images were:



When there are two images, is there a certain boot order that these things take when multiple images exist? I just deleted the ipbase image to fix this issue, but I was curious how the router picked this image over the other.



  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (2 ratings)
lamav Wed, 03/18/2009 - 09:06

John, it goes down the list. If the bootloader file (bootstrap) in ROM determines that the device should be booted in the "normal" way (confreg 0x2102), it will load that portion of the startup config that has the boot statements. It will then execute those statements one at a time, from the top to bottom. So the first IOS you have in the list is the one it will try to boot first. If unsuccessful, it goes down the list.

If no bootable image is found, in can load to RxBoot if the device supports it, or throw you into ROMMON.



John Blakley Wed, 03/18/2009 - 09:08


The config register is 0x2102, and when doing a dir, the ipbase shows first in the list. Is there a way to move these around in the folder though? If I want a certain one to boot first without using the "boot system" line in the running config?


Mohamad Qayoom Wed, 03/18/2009 - 09:12


Maybe you can delete the other image(ipbase). Or you can also delete one image(ipbase) and upload the deleted image(ipbase) to change the boot order. Is there any specific reason for not wanting to use the boot statement?



John Blakley Wed, 03/18/2009 - 09:14

Yes. If I lose my config, it'll boot from the wrong image. I had it happen this morning. I've already deleted the image, and it won't be an issue in the future because it won't have but the one image to boot from. :)

lamav Wed, 03/18/2009 - 09:25

John, I never met anyone with your requirement, but the way it works is that if there is no boot staatement in the config file, the bootstrap program will look for the first usable IOS in Flash.

Now, I have never experimented with this, but it seems feasible that if you delte the image from Flash that you want to use as a secondary image and then reload it, the router may place it in that order of existence - unless the Flash file system uses a different criterion for the order in which it places IOS images. Try it in a lab and see what you get.


If the router's blown the config anyway, its dead in the water, so who cares what IOS image it loads?

John Blakley Wed, 03/18/2009 - 09:32

"I never met anyone with your requirement"

Okay, here's the deal. From my OP, I stated that I had forgotten to write the config. My fault, I know.

Second. I shipped the router to the location that had TWO images: ipbase and entservices.

Problem is that because I forgot to write the config, my routes didn't come up because BGP isn't supported under ipbase. Because it didn't have a "boot system" statement, it loaded the first image in flash being ipbase. The router didn't support bgp under this image.

Now the problem lies in the fact that I configured the router using enterprise services with bgp and dlsw support, wrote my changes, but I forgot to put my boot line in the config. Because of this, it booted the config with the wrong image and thus wiped out my bgp configuration, hence my original question.

It's not that I have a "requirement", I was just curious as to why the router chose to boot ipbase instead of entservices considering the timestamp of entservices was later than ipbase because I uploaded it last.

lamav Wed, 03/18/2009 - 09:34

If the IPBASE image is worthless because it doesnt support BGP and DLSW, why have it? Get rid of it and be done with it. No?

Mohamad Qayoom Wed, 03/18/2009 - 09:36

I think he already deleted it. We all sometimes forget to type "wr." So, I wouldn't make John feel guilty about this.


lamav Wed, 03/18/2009 - 09:38

No ones making John feel guilty about anything at all. Not sure I know what youre talking about.

He forgot to save the config so the boot statements were gone. Got it. No biggie.

Get rid of the image you dont want and cant use and you wont have to worry about this again.

If one is asking out of curiosity for the purpose of understanding whwt happened and how maybe to avoid something this in the future, then I gave my suggestion already on what to do.

Joseph W. Doherty Wed, 03/18/2009 - 12:46

Yes, there is a default boot sequence. Usually first valid (for the device) image found. Devices that support multiple flashes, also have a default flash device search sequence.


With regard to some later questions, I haven't found a way to reorder the image sequence without deleting an image and reloading onto the same flash device. (Of course, using a boot statement takes less time.) With multiple flash devices of the same type, can swap flash to slot and obtain a different boot sequence. With different flash devices, you can pull the earlier in sequence flash device.

Something that can be done, I've noted the boot statement allows you to override the default flash device search sequence without the need to specify a specific image.

With the problem of losing your initial BGP configuration with an image that doesn't support it. Only the running image lost it. The BGP config should have been in startup until overridden.


This Discussion