In order to factory reset a Cisco switch using the CLI follow the below steps
- Gain privileged EXEC mode by entering:
enable
2. Enter the command – * explained on the Explanation section
write erase
or
erase startup-config
3. Delete the VLAN database by using the command – * explained on the Explanation section
delete flash:vlan.dat
4. Reload the switch to apply the changes with the reload command
reload
if the device is asking System configuration has been modified. Save? [yes/no]:
enter NO otherwise, the switch !— reloads with the current running configuration and does not reset to default.
Explanation Section
* What is the difference between write rease and erase startup-config
write erase – is an Older / classic command
It’s equivalent to deleting the file nvram:startup-config.
It’s the legacy command (from older IOS versions) that erases the startup configuration file stored in NVRAM.
erase startup-config – Newer / recommended command (modern IOS / IOS-XE)
- Does exactly the same thing – it removes the startup configuration file from NVRAM.
- It’s the more “explicit” version of
write erase, and is preferred for clarity and consistency across platforms.
* Why do we need to remove the vlan.dat
- The VLAN data of the switch is not stored in the config of the switch but its stored in a seperate data file on the flash drive of the switch. in order to remove it we need to use the command above to remove the old data file. When we have new VLAN information in our device, the file will be newly created again
