This is an annoying problem:

Switch#write
startup-config file open failed (Not enough space)

Switch#dir nvram:
Directory of nvram:/

%Error opening nvram:/ (Function not implemented)

1048576 bytes total (1034573 bytes free)

Cisco Catalyst switches simulate NVRAM on their flash. Once in a blue moon, this simulated NVRAM will become corrupted. In order to clear up the corruption, I changed the size of the NVRAM and rebooted:

aus-bone-02#show boot 
BOOT path-list      : flash:c3750me-i5k91-mz.122-58.SE2/c3750me-i5k91-mz.122-58.SE2.bin
Config file         : flash:/config.text
Private Config file : flash:/private-config.text
Enable Break        : no
Manual Boot         : no
HELPER path-list    : 
Auto upgrade        : yes
Auto upgrade path   : 
NVRAM/Config file
      buffer size:   1048576
Timeout for Config
          Download:    0 seconds
Config Download 
       via DHCP:       disabled (next boot: disabled)

Notice that the size of the simulated NVRAM is 1,048,576 bytes. We'll change it back to the default (512K).

Switch#config t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#boot buffersize 524288
Switch(config)#^Z
Switch#show boot
BOOT path-list      : flash:c3750me-i5k91-mz.122-58.SE2/c3750me-i5k91-mz.122-58.SE2.bin
Config file         : flash:/config.text
Private Config file : flash:/private-config.text
Enable Break        : no
Manual Boot         : no
HELPER path-list    : 
Auto upgrade        : yes
Auto upgrade path   : 
NVRAM/Config file
      buffer size:   524288
Timeout for Config
          Download:    0 seconds
Config Download 
       via DHCP:       disabled (next boot: disabled)

After reload:

Switch#dir nvram:
Directory of nvram:/

  500  -rw-        8807                      startup-config
  501  ----        2072                      private-config
    1  ----          35                      persistent-data

524288 bytes total (512333 bytes free)