Recently I came across a command to reset Cisco C9000 switches to factory default. The command is factory-reset and it was introduced in IOS XE 16.8.1a. This command can be handy and harmful. It can be harmful if you use it without paying attention to what option you use with it.
The factory-reset command allows using one of the following options:
The all option instructs the switch to wipe all its running and startup configuration, all partitions, NVRAM, and all images. When you issue the command factory-reset all the switch will prompt you to confirm before applying the command. The switch will also give you a warning message stating that all data will be wiped and the switch will be reset to its factory default. Once confirmed, the switch will reload and it will then go into rommon mode.
The two options I am aware of to recover the switch in that case are to use a usb drive which I tested, or to go through the emergency installation process which I did not test. The usb drive option is pretty straightforward, you just need to upload the switch image to the usb drive and then issuing the boot command from rommon mode similar to this:
After you issue the boot command the switch will boot from the usb drive and it will automatically partition the flash. Once the switch completes booting you need to copy the image from the usb drive to the flash, save your config and you are good to go.
Instead if you don’t have a usb drive then you would need to go through the second option which is the emergency installation. To do that, first you need to store the switch image on a TFTP server, then you need to define the network variables from the rommon mode, and finally to boot the switch from the TFTP server. More about this in the reference section at the end of this post.
The config option is the most common one we would use because it will reset the startup configuration leaving anything else intact. This would be the equivalent of the write erase command.
The boot-vars options helps if you want to reset the configured variables, nothing else will be reset.
This wraps up this post of how to reset Cisco C9000 switches to factory default. I hope it was useful and thanks for reading!