You want to erase files from your router's flash.
To delete all of the files from your router's flash memory, use the erase command:
Router1#erase slot1: Erasing the slot1 filesystem will remove all files! Continue? [confirm] Erasing device... eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ...erased Erase of slot1: complete Router1#
You can remove individual files from the router's flash memory with the delete command:
Router1#delete slot1:c3620-ik9s-mz.122-13.bin Delete filename [c3620-ik9s-mz.122-13.bin]? Delete slot1:c3620-ik9s-mz.122-13.bin? [confirm] 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.
|Router type||Filesystem type|
|7000 (RSP)||Class A|
|7500 (RSP 2 ,4, and 8)||Class A|
|Route Switch Module (RSM)||Class A|
Table 1-3 lists some of the different filesystem commands, their meanings, and the filesystems that they work with.
|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 slot1: 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#
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 slot1: Squeeze operation may take a while. Continue? [confirm] 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.