Showing results for 
Search instead for 
Did you mean: 
Join Customer Connection to register!

Remove folder from within TAR file

Dear community


We would like to remove the folder from within a TAR file, so that the bin file is located at the root of the TAR archive. A typical TAR file has following structure:

|lots of files
|info |info

Folders are in blue, files are green. So as far as i tested, i can remove the html folder and the dc_default_profiles.txt without any impact. But as soon as i remove one of the 2 info files, i get following error trying to apply the image:

ERROR: Image is not a valid IOS image archive.

So, how can i achieve to get the bin file to root, without the error when applying the image? I somehow have to merge the 2 info files im afraid. Content of the root info file:

system_type: 0x00000000: c2960x-universalk9-mz.152-2.E6
image_family: C2960X
stacking_number: 1.56

And the one in the folder:

version_suffix: universalk9-152-2.E6
version_directory: c2960x-universalk9-mz.152-2.E6
image_system_type_id: 0x00000000
image_name: c2960x-universalk9-mz.152-2.E6.bin
ios_image_file_size: 21289472
total_image_file_size: 26911232
image_feature: IP|LAYER_2|SSH|3DES|MIN_DRAM_MEG=128
image_family: C2960X
stacking_number: 1.56
board_ids: 0x00008888 0x000088a2 0x000088a6 0x000088a5 0x000088a3 0x00000208 0x00000209 0x000001fa 0x000001f8 0x000001f9 0x000001f7 0x0000020a 0x000001fe 0x000001fc 0x000001fd 0x000001fb 0x00000200 0x00000201 0x00000243 0x00000244 0x00000246 0x00000245 0x00000247 0x00000248 0x00000249 0x0000024b 0x0000024a 0x0000024c 0x0000024d 0x0000024e 0x00000250 0x0000024f 0x00000251 0x00000252 0x00000253 0x00000255 0x00000254 0x00000256 0x0000025b 0x0000025a 

Has anyone ever tried to achieve something like this? I know there will be that one question: "Why u wanna do dis?"

Seb Rupik
VIP Advisor

HI there,

When you use the archive download-sw command why don't you use the /image-only argument, this will remove all other files/ folders. 

If you just want the .bin file at root, why not download the .bin image and position it manually with the copy command?




We already tried the /imageonly switch. This just skips the HTML folder but still extracts the bin file to a folder:

Deleting `flash:c2960x-universalk9-mz.152-2.E6' to create required space
Extracting images from archive into flash...
extracting c2960x-universalk9-mz.152-2.E6/info (786 bytes)
extracting c2960x-universalk9-mz.152-2.E6/c2960x-universalk9-mz.152-2.E6.bin (21279744 bytes)
extracting info (109 bytes)

We use Autoinstall. We can only give the path to a TAR file. The switch then uses archive download-sw in the background. So we cant use the copy command. So the question remains. How can we modify the TAR file to get the BIN file to the root location?



Leo Laohoo
VIP Community Legend

@mario.jost wrote:

How can we modify the TAR file to get the BIN file to the root location? 

If you're using AutoInstall, there is no way to specify /imageonly.  

I tested it manually. Just made the point that /imageonly does not help with the path issue. Great input.


So far i couldn't manage to get the custom TAR file going. I tried, creating a TAR file with a switch, so it would create all necessary files itself. But it expects a folder to create an archive:

swTST01#archive tar /create flash1:c2960x-universalk9-mz.152-2.E7.tar flash1:c2960x-universalk9-mz.152-2.E7.bin
Unable to look up files and subdirs in flash1:c2960x-universalk9-mz.152-2.E7.bin

So I guess this is more "hardcoded" into the archive functionality than i thought. I will post updates here, if i found a solution for this.

Leo Laohoo
VIP Community Legend

Just thought of something ...
AutoInstall support "post installation script". So what happens if the post installation script deletes the HTML folder after the IOS upgrade?

Dear Leo

This is a great input. I actually created a TCL script that does what i want. I tested it manually with success, but when i try to call it in from within the configuration (do tclsh tftp://TFTPserver/cleanup.tcl) file, i get following error:

Launching Tcl shell is not allowed from the config mode.
Exit to exec mode and try again.

If i let go of the "do" and exit out of config mode, the script stops altogether without even trying to run the TCL script. So how am i supposed to start this post install script? is there another DHCP Option that i need to use for this? I couldn't find anything specific searching for this.

I tested an ugly but working approach, where i configure a kronjob within the initial configuration file:

kron policy-list CLEANUP
cli tclsh tftp://TFTPserver/cleanup.tcl
kron occurrence CLEANUP in 1 oneshot
policy-list CLEANUP

This, then runs the TCL script after 1 Minute. Within the script, i cleanup the kron configuration:

ios_config "no kron policy-list CLEANUP"
exec "write"

Since the kron occurence is oneshot, it cleans itself from the running-config after execution automagically.