If you have your own Cisco switch equipment at your home lab or at your work environment you might have encountered the situation that you want to completely erase the whole switch configuration including any VLANs that are already configured on the switch (usually the vlan.dat file).
In a Cisco switch, erasing the switch startup configuration is one thing and erasing the VLANs that exist on the switch is another thing. The VLAN information is stored in a file with name vlan.dat which exists in the flash storage of the switch. If you run “show flash” command you will see this file.
It is a good practice to completely erase everything on a switch (both switch configuration and switch Vlans) before using the switch in another part of your network. This is important in order to avoid any network conflicts because of any old configuration settings that are already configured on the switch.
Now let us see how to delete the configuration and Vlans from a Cisco switch.
1) Deleting the switch configuration
This is the easy part. It’s the same as deleting the configuration from any other Cisco network IOS device. Basically you need to delete the “startup-configuration” and then reboot the switch.
Switch#erase startup-config
Erasing the nvram filesystem will remove all configuration files! Continue?
[confirm]
[OK]
Erase of nvram: complete
Switch#reload
2) Deleting the switch Vlans
The strange part is that after deleting the switch configuration you will notice that the Vlans are still there.
Switch#show vlan brief
2 VLAN0002 active
3 VLAN0003 active
4 VLAN0004 active
By executing the command “show vlan brief” you can see that there are 3 vlans configured on the switch. These vlans are stored in a file in flash memory called “vlan.dat” as we mentioned at the beginning of this article. You can see this file if you read what is stored in the flash:
Switch#show flash:
Directory of flash:/
1 -rw- 4414921 <no date> c2960-lanbase-mz.122-25.FX.bin
2 -rw- 616 <no date> vlan.dat
64016384 bytes total (59600847 bytes free)
As you can see from output above, the file “vlan.dat” is stored in flash. You have to delete this file in order to completely erase all vlans on the switch.
Switch#delete vlan.dat
Delete filename [vlan.dat]?
Delete flash:/vlan.dat? [confirm]
Switch#sh flash
Directory of flash:/
1 -rw- 4414921 <no date> c2960-lanbase-mz.122-25.FX.bin
64016384 bytes total (59601463 bytes free)
Switch#reload
After executing the command “delete vlan.dat” just hit enter twice and it will be gone. Then you have to reload the switch.