Courseiva
SystemPrivileged EXEC

write erase

Erases the startup configuration from NVRAM, resetting the device to factory defaults on next reload.

Definition: write erase is a Cisco IOS privileged exec command. Erases the startup configuration from NVRAM, resetting the device to factory defaults on next reload.

Overview

The `write erase` command is a critical IOS command used to delete the startup configuration stored in NVRAM. When executed, it clears the configuration file that the router loads upon boot, effectively resetting the device to factory defaults after the next reload. This command is essential for network engineers when repurposing hardware, troubleshooting configuration corruption, or preparing devices for deployment in a new environment.

The underlying concept is that Cisco devices store two primary configuration files: the running-config (in RAM) and the startup-config (in NVRAM). The `write erase` command targets the latter, leaving the running-config untouched until a reload occurs. This distinction is important because it allows engineers to verify that the erase was successful without immediately losing the current operational state.

The command is typically used when a device needs to be completely reconfigured, when returning equipment to a lab or inventory, or when troubleshooting boot issues caused by a corrupted startup configuration. Alternatives include manually deleting the startup-config via `delete nvram:startup-config` or using `erase startup-config`, which is functionally identical. The command fits into a broader workflow: after erasing, the engineer usually reloads the device to apply the blank configuration, then configures from scratch or restores a backup.

Important IOS behaviors: the command requires privileged EXEC mode (enable), it does not affect the running configuration, and it prompts for confirmation (unless the `noconfirm` option is used in some IOS versions). The output is minimal—just a confirmation message. This command is fundamental for CCNA and CCNP candidates as it demonstrates understanding of configuration storage and device initialization processes.

Syntax·Privileged EXEC
write erase

When to Use This Command

  • Preparing a router for redeployment in a different network environment.
  • Clearing a misconfigured device before applying a new configuration.
  • Returning a device to a known clean state for troubleshooting.
  • Removing all configuration before returning leased equipment.

Command Examples

Basic write erase

write erase
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: complete

The command prompts for confirmation; pressing Enter confirms. The output confirms the NVRAM filesystem has been erased successfully.

Alternative command with reload

write erase reload
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: complete

Proceed with reload? [confirm]

%SYS-5-RELOAD: Reload requested

After erasing, the reload command reboots the device. The device will load the default factory configuration.

Understanding the Output

The output begins with a warning that all configuration files will be removed and prompts for confirmation. Typing 'yes' or pressing Enter proceeds. '[OK]' indicates the erase operation succeeded.

'Erase of nvram: complete' confirms the NVRAM filesystem is now empty. After this, the device still runs the current running configuration until reloaded. A subsequent 'reload' command will reboot the device, which then boots with no startup configuration, prompting the initial configuration dialog or entering setup mode.

Configuration Scenarios

Erasing startup config before redeploying a router to a different site

A network engineer needs to repurpose a Cisco 4321 router from a branch office to a new data center. The old configuration must be completely removed to avoid conflicts with the new network design.

Topology

R1 (standalone device, no topology needed)

Steps

  1. 1.Step 1: Connect to the router via console or SSH and enter privileged EXEC mode: Router> enable
  2. 2.Step 2: Verify the current startup configuration exists: Router# show startup-config
  3. 3.Step 3: Erase the startup configuration: Router# write erase
  4. 4.Step 4: Confirm the erase when prompted: [confirm] (press Enter)
  5. 5.Step 5: Verify the startup configuration is deleted: Router# show startup-config (should return 'startup-config is not present')
  6. 6.Step 6: Reload the router to apply the blank configuration: Router# reload
Configuration
! No configuration block needed; the command is executed in privileged EXEC mode
Router# write erase
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: complete

Verify: Router# show startup-config % Startup config is not present

Watch out: After `write erase`, the running configuration is still intact. If you reload without saving any changes, the router will boot with no configuration. Ensure you have a backup of the desired config before erasing.

Erasing startup config to troubleshoot a boot loop caused by a corrupt configuration

A router fails to boot properly, repeatedly restarting due to a corrupted startup configuration. The engineer needs to erase the startup config to allow the router to boot with factory defaults and then apply a known-good configuration.

Topology

R1 (standalone device, no topology needed)

Steps

  1. 1.Step 1: Access the router via console during boot and interrupt the boot process to enter ROMmon mode (if necessary) or boot without startup config by setting the configuration register to 0x2142.
  2. 2.Step 2: Boot the router without loading the startup config: rommon 1 > confreg 0x2142, then reset
  3. 3.Step 3: After the router boots, enter privileged EXEC mode: Router> enable
  4. 4.Step 4: Erase the corrupted startup configuration: Router# write erase
  5. 5.Step 5: Reset the configuration register to normal (0x2102) for future boots: Router(config)# config-register 0x2102
  6. 6.Step 6: Reload the router to ensure clean boot: Router# reload
Configuration
! In ROMmon mode:
rommon 1 > confreg 0x2142
rommon 2 > reset

! After boot:
Router> enable
Router# write erase
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Router# configure terminal
Router(config)# config-register 0x2102
Router(config)# end
Router# reload

Verify: After reload, the router should boot to the initial configuration dialog (setup mode) or a blank config. Verify with `show startup-config` which should indicate no startup config.

Watch out: If you forget to reset the configuration register to 0x2102, the router will continue to ignore the startup config on subsequent boots. Always verify the config register after troubleshooting.

Troubleshooting with This Command

The `write erase` command is primarily used as a corrective action rather than a diagnostic tool, but it plays a key role in troubleshooting boot issues and configuration corruption. When a router exhibits symptoms such as boot loops, unexpected behavior, or error messages during boot (e.g., 'Invalid configuration' or 'Configuration file not found'), the startup configuration may be corrupted. In such cases, the healthy state is that the router boots normally and loads a valid startup config.

Problem indicators include the router repeatedly restarting, entering ROMmon mode automatically, or displaying checksum errors. To diagnose, first check the status of the startup configuration using `show startup-config`. If the output shows garbled text, incomplete lines, or an error, the file is likely corrupt.

Another useful command is `dir nvram:` to list files in NVRAM; a corrupt file may have an unusual size or fail to display. If the router cannot boot, you may need to access ROMmon mode and set the configuration register to 0x2142 to bypass loading the startup config. After booting, immediately erase the corrupt file with `write erase`.

Then, reload the router to confirm it boots cleanly. Correlate with `show version` to verify the configuration register setting and `show running-config` to ensure no remnants of the old config remain. In advanced troubleshooting, you can use `more nvram:startup-config` to view the raw file; if it shows binary data or errors, the file is corrupt.

Always ensure you have a backup of the desired configuration before erasing, as recovery from a corrupt file without a backup may require reconfiguration from scratch.

CCNA Exam Tips

1.

CCNA exam tip: 'write erase' is equivalent to 'erase startup-config' — both remove the startup configuration from NVRAM.

2.

CCNA exam tip: The command does not affect the running configuration; a reload is required to clear the running config.

3.

CCNA exam tip: You must be in privileged EXEC mode (enable) to use this command.

4.

CCNA exam tip: After 'write erase', the device will prompt for initial configuration on next reload; this is a common scenario for password recovery.

Common Mistakes

Mistake 1: Forgetting to reload after 'write erase' — the running configuration remains active until reboot.

Mistake 2: Confusing 'write erase' with 'write memory' — 'write memory' saves the running config to startup, while 'write erase' deletes it.

Mistake 3: Not confirming the prompt — the command requires confirmation; simply pressing Enter is sufficient.

write erase vs erase startup-config

The commands 'write erase' and 'erase startup-config' both reset a Cisco device to factory defaults on reload, but they differ in syntax, historical usage, and potential side effects. 'write erase' is a legacy command that may erase the entire NVRAM filesystem with a confirmation prompt, while 'erase startup-config' is the modern equivalent that specifically deletes the startup-config file.

Aspectwrite eraseerase startup-config
Command syntaxwrite eraseerase startup-config
Confirmation promptPrompts to erase entire NVRAM filesystemPrompts to erase startup-config only
Effect on other filesMay delete all NVRAM files (e.g., VLAN database)Deletes only the startup-config file
History/DeprecationOlder, still functional in modern IOSCurrent recommended command
Typical usageQuick factory reset in field environmentsStandard method in lab or production

Use write erase when you need a quick factory reset and understand that it may affect other NVRAM files.

Use erase startup-config when you want a precise, file-specific erasure of the startup configuration.

Platform Notes

On IOS-XE (e.g., Catalyst 9000 switches, ISR 4000 series), the `write erase` command behaves identically to classic IOS, erasing the startup configuration from NVRAM. However, on some IOS-XE platforms, the startup configuration may be stored in a different filesystem (e.g., 'nvram:' or 'flash:'). The command still works as expected.

On NX-OS (e.g., Nexus switches), the equivalent command is `write erase` or `erase startup-config`, but NX-OS also supports `copy running-config startup-config` to save. The syntax is the same. On ASA firewalls, the equivalent is `write erase` or `clear configure all` (which erases both startup and running config).

Note that on ASA, `write erase` only erases the startup config, similar to IOS. On IOS-XR (e.g., ASR 9000, CRS), the command is `write erase` but the configuration is stored in a binary database; the command erases the committed configuration. However, IOS-XR uses a different paradigm with commit operations, so the command may not be available in all contexts.

In IOS versions 12.x and earlier, `write erase` is the standard; in 15.x and later, it remains unchanged. Some newer IOS versions support `erase nvram:` as an alternative. There is no difference in output format between versions.

Always verify the filesystem location of the startup config using `show file systems` if unsure.

Related Commands

Practice for the CCNA 200-301

Test your knowledge with practice questions covering all CCNA 200-301 exam domains.

Practice CCNA 200-301 Questions