Friday, August 1, 2025

Deleting a Cisco File Directory

Some older Cisco switches have limited flash memory and would require deleting large files such as an IOS/IOS-XE .bin to free up space.

 
Switch#copy ftp://ftp:ftp123@192.168.1.251/me360x-universalk9-mz.123-3.S5.bin flash
Destination filename [me360x-universalk9-mz.123-3.S5.bin]?
Accessing ftp://*****:*****@192.168.1.251/me360x-universalk9-mz.123-3.S5.bin...
Loading me360x-universalk9-mz.123-3.S5.bin !!!!!!!!!!!!!!!!!!!!!!!!!!!
%Error writing flash:/me360x-universalk9-mz.123-3.S5.bin (No space left on device)


Switch#dir
Directory of flash:/

    2  -rwx       12196  Jul 20 2018 09:21:37 +00:00  vlan.dat
    3  -rwx        2251  Feb 25 2013 15:28:47 +00:00  FOC1637V0NF_20130225072612345.lic
    4  -rwx    24390193   Mar 5 2013 10:53:32 +00:00  me360x-universalk9-mz.456-1.S1.bin
    5  -rwx        4774  Feb 25 2013 13:38:53 +00:00  config.old
    6  drwx         512   Mar 1 1993 00:13:28 +00:00  me360x-universalk9-mz.789-2.S1
   14  -rwx        2072   Oct 2 2018 10:51:46 +00:00  multiple-fs
   15  -rwx       22731   Oct 2 2018 10:51:46 +00:00  config.text
   16  -rwx        3786   Oct 2 2018 10:51:46 +00:00  private-config.text

57931776 bytes total (6690816 bytes free)


You can't delete a directory if there are files within it. You'll need to issue a delete /recursive command to delete the entire directory and all its files.

 
Switch#delete flash:/me360x-universalk9-mz.789-2.S1
Delete filename [me360x-universalk9-mz.789-2.S1]?
Delete flash:/me360x-universalk9-mz.789-2.S1? [confirm]
%Error deleting flash:/me360x-universalk9-mz.789-2.S1 (Is a directory)

Switch#delete ?
  /force      Force delete
  /recursive  Recursive delete
  flash:      File to be deleted
  nvram:      File to be deleted

Switch#delete /recursive flash:me360x-universalk9-mz.789-2.S1      // USE /force TO SKIP CONFIRM
Delete filename [me360x-universalk9-mz.789-2.S1]?
Examine files in directory flash:/me360x-universalk9-mz.789-2.S1? [confirm]
Examine files in directory flash:/me360x-universalk9-mz.789-2.S1/html? [confirm]
Delete flash:/me360x-universalk9-mz.789-2.S1/html/foo.html? [confirm]
Delete flash:/me360x-universalk9-mz.789-2.S1/html? [confirm]
Delete flash:/me360x-universalk9-mz.789-2.S1/me360x-mfpga.bit? [confirm]
Delete flash:/me360x-universalk9-mz.789-2.S1/me360x-universalk9-mz.789-2.S1.bin? [confirm]
Delete flash:/me360x-universalk9-mz.789-2.S1/controlfpga.bin? [confirm]
Delete flash:/me360x-universalk9-mz.789-2.S1/info? [confirm]
Delete flash:/me360x-universalk9-mz.789-2.S1/psoc.dld? [confirm]
Delete flash:/me360x-universalk9-mz.789-2.S1? [confirm]


Switch#dir
Directory of flash:/

    2  -rwx       12196  Jul 20 2018 09:21:37 +00:00  vlan.dat
    3  -rwx        2251  Feb 25 2013 15:28:47 +00:00  FOC1637V0NF_20130225072612345.lic
    4  -rwx    24390193   Mar 5 2013 10:53:32 +00:00  me360x-universalk9-mz.456-1.S1.bin
    5  -rwx        4774  Feb 25 2013 13:38:53 +00:00  config.old
   14  -rwx        2072   Oct 2 2018 10:51:46 +00:00  multiple-fs
   15  -rwx       22731   Oct 2 2018 10:51:46 +00:00  config.text
   16  -rwx        3786   Oct 2 2018 10:51:46 +00:00  private-config.text

57931776 bytes total (33289728 bytes free)