To delete all of the files from your router’s flash memory, use the erase command:
Router1#erase
Erasing the slot1 filesystem will remove all files! Continue? [confirm]
slot1:
<enter>
Erasing device... eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ...erased Erase of slot1: complete Router1#
Tip
Not all router types support the erase command.
You can remove individual files from the router’s flash memory with the delete command:
Router1#delete
Delete filename [c3620-ik9s-mz.122-13.bin]?
slot1:c3620-ik9s-mz.122-13.bin
<enter>
Delete slot1:c3620-ik9s-mz.122-13.bin? [confirm]<enter>
Router1#
As we have indicated, there are two ways to delete files from flash, depending on the type of router. The difference arose because Cisco routers use three different kinds of filesystems, called Class A, Class B, and Class C. Table 1-2 shows the filesystems that Cisco’s most common routers use.
Table 1-2. Supported filesystems of common Cisco routers
Router type | Filesystem type |
---|---|
7000 (RSP) | Class A |
7500 (RSP 2 ,4, and 8) | Class A |
12000 | Class A |
Route Switch Module (RSM) | Class A |
1600 | Class B |
2500 | Class B |
3600 | Class B |
4000 | Class B |
AS5300 | Class B |
AS5800 | Class C |
7100 | Class C |
7200 | Class C |
Table 1-3 lists some of the different filesystem commands, their meanings, and the filesystems that they work with.
Table 1-3. Filesystem commands and their meanings
Command | Filesystem | Description |
---|---|---|
Delete | All | Marks the files as deleted, but does not permanently remove them from flash. |
Squeeze | A | Permanently removes all files that have been marked as deleted. |
Format | A and C | Erases the entire flash device. |
Verify | All | Verifies that the IOS file’s checksum matches the value encoded in the image. |
Undelete | A and B | Recovers deleted files. |
Erase | A and B | Erases the entire flash device. |
The erase command is not available on all router types. On routers that use the Class C filesystem, you can remove files from the flash only with the delete command.
The delete command marks files as deleted, but does not permanently remove them:
Router1#show
PCMCIA Slot1 flash directory: File Length Name/status 1 11992088 c3620-ik9s-mz.122-13.bin [deleted] [16515072 bytes used, 0 available, 16515072 total] 16384K bytes of processor board PCMCIA Slot1 flash (Read/Write) Router1#
slot1:
You can permanently remove this file and reclaim the space on the flash device with the squeeze command. Note, however, that only routers with the type A filesystem support this command:
Router1#squeeze
Squeeze operation may take a while. Continue? [confirm]
slot1:
<enter>
squeeze in progress... Squeeze of slot1 complete Router1#
The squeeze function can take up to several minutes, so be patient. Once the squeeze command is complete, you can view the flash device to verify that the file is gone:
Router1#show slot1:
PCMCIA Slot1 flash directory:
No files in PCMCIA Slot1 flash
[0 bytes used, 16515072 available, 16515072 total]
16384K bytes of processor board PCMCIA Slot1 flash (Read/Write)
Router1#
The file is has now been permanently removed, and you can no longer recover it with the undelete command. On routers with filesystems that do not support the squeeze command, the only way to permanently remove deleted files is to use the erase command. However, the erase command deletes the entire flash system and will not permit you to delete individual files. It’s all or nothing. In the next recipe, we will look at ways to partition flash devices to reduce the impact of the erase command.
Get Cisco IOS Cookbook, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.