How to reset a switch & router back to factory defaults


I recently purchased some switches and routers from eBay. What is the proper way to wipe and reset to factory defaults?


This should get you started:

R1#write ?
  erase     Erase NV memory
R1#write erase 
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
Erase of nvram: complete
R1#delete flash:vlan.dat
Delete filename [vlan.dat]? 
Delete flash:vlan.dat? [confirm]