Friday, 9 August 2013

IOS Tip: %Error deleting flash0:xxxx (Can't delete a directory that has files in it)


Have you seen this error before? Cisco IOS doesn't allow deletion of directories which contain sub-directories/files. This won't work with "delete" or "rmdir" command.

2951-router#delete /force flash0:CME9.1.0GUI
%Error deleting flash0:CME9.1.0GUI (Can't delete a directory that has files in it)









To make it working, you need to use "/recursive" keyword with "delete" command. It will start deleting using bottom-top approach from most deeper file in reverse direction..

2951-router#delete /force /recursive flash0:CME9.1.0GUI

IOS Tip: How to Move Directories within IOS Flash Memory

Have you ever uploaded a directory to Router Flash Memory (e.g. CME GUI Dir) and found that it was uploaded to wrong path? How to move it back to right path?

Let's consider a directory named CME9.1.0GUI. I wanted to upload it to "flash0:/" however, I discovered that its uploaded to "flash0:phone_loads/".

One option to put it back in the right path is to delete the directory from the wrong path and re-upload it. This can be easy when uploading from LAN or small directories over WAN. But not for big directories over WAN.

Another option is to use "rename" command. When you rename the directory, it will ask for the destination path of the renamed directory. This means that "rename" command is doing two functions which are copying the directory to new path and renaming it.

2951-router#rename flash0:phone_loads/CME9.1.0GUI flash0:CME9.1.0GUI        
Destination filename [CME9.1.0GUI]?
 

2951-router#dir
Directory of flash0:/

    1  -rw-    89934456  May 28 2013 22:07:24 +07:00  c2951-universalk9-mz.SPA.152-4.M3.bin
    2  -rw-        3064  May 28 2013 22:17:54 +07:00  cpconfig-29xx.cfg
  240  drw-           0   Aug 9 2013 04:34:26 +07:00  phone_loads
    3  drw-           0  May 28 2013 22:18:12 +07:00  ccpexp
  239  -rw-        2464  May 28 2013 22:19:54 +07:00  home.shtml
  241  drw-           0   Aug 9 2013 04:34:58 +07:00  ringtones
  242  drw-           0   Aug 9 2013 04:35:46 +07:00  CME9.1.0GUI
  246  -rw-      496521   Aug 9 2013 05:04:12 +07:00  music-on-hold.au


PS: This is applicable for any memory in IOS not only Flash.

Design Question: "dialplan-pattern" or "voice translation rule" ???

No doubt that voice translation rules are very powerful and provide many advantages in addition to digit manipulation. But let's consider a common scenario where you have CME and would like to convert extensions to E164 numbers for PSTN dialing.

One of the common ways to do this using "dialplan-pattern" command in CME. This is usually preferred over voice translation rules due to simplicity. Single command instead of voice-rule, voice-profile, assign profile to dial-peer or voice-port.

From design perspective, it is very dangerous to use "dialplan-pattern" feature. In fact I would say never use this feature. Let's look deeper.

The way how "dialplan-pattern" works that it will create an additional dial-peer for each Ephone-DN with destenation pattern as E164 number. For example, if you added a DN with number 6004 and your expansion pattern is 789.... , CME will create two virtual-dialpeers for numbers 6004 and 7896004 (you can see this using "show dial-peer voice summary" command).

Creating Ephone-DN with secondary number and having "dialplan-pattern" feature will result in 4 virtual dial-peers created (two for primary/secondary and two for E164-priamry/E164-secondary).

This means that number of virtual dialpeers is multiplied by two. For an office with 20 employees and 20 phones, you will have 40 virtual dialpeers (if only primary numbers are assigned) or 80 virtual dialpeers (if primary/secondary numbers are assigned) !!!!

Ok, till this point we didn't understand why this is a problem? What's wrong in having 80 or 100 virtual dial-peers ??

1. Dial-peers are stored in the RAM of the router for operation. Each dial peer consumes approximately 6KB of memory

By misusing this feature, you are adding overhead to your router's RAM without feeling it and bringing it very close to crash.

2. Assuming your are incorporating other features in your router (e.g. 2951 with default 512 MB RAM) such as zone-based firewalls, VPN, NAT, etc, you won't be able to add more than 10 ephone-DNs (assuming that secondary numbers are used). You will start getting error:

"Error: Can't Add Dial Peer"
 
3. On router reboot, although dial-peers configuration is saved in startup config, the router won't apply them to running config due to lack of RAM. This means that your router will boot with missing config (if you connect console due to reload, you will see the same error message in above point).

All of this can be resolved simply by using single voice translation rule applied to voice-port. So what do you think !!!