Manage Cisco IOS files
IOS image and configuration files can become corrupted through intentional attacks, unintentional user errors, and device failure. To prevent these problems, you have to be able to save, back up, and restore configuration and IOS images. Today’s review covers file management operations.
Cisco IOS devices provide a feature called the Cisco IOS Integrated File System (IFS). This system enables you to create, navigate, and manipulate directories on a Cisco device. The directories available depend on the platform.
Example 25-1 shows output from the show file systems command.
Router# show file systems
File Systems:
Size(b) Free(b) Type Flags Prefixes
- - opaque rw archive:
- - opaque rw system:
- - opaque rw tmpsys:
- - opaque rw null:
- - network rw tftp:
262136 251594 nvram rw nvram:
- - opaque wo syslog:
- - opaque rw xmodem:
- - opaque rw ymodem:
- - network rw rcp:
- - network rw http:
- - network rw ftp:
- - network rw scp:
- - opaque ro tar:
- - network rw https:
- - opaque ro cns:
1002143744 683163648 usbflash rw usbflash1:
* 255537152 183939072 usbflash rw usbflash0: flash:
Router#
The columns show the amount of available and free memory in bytes and the type of file system and its permissions. Permissions include read-only (ro), write-only (wo), and read and write (rw). Although several file systems are listed, of interest to us are the TFTP, flash, and NVRAM file systems.
Notice that the flash file system has an asterisk (*) preceding it, which indicates that this is the current default file system. For the 1900 router in Example 25-1, the file system is booted from USB flash. The alias flash: is associated with usbflash0 so that you can use flash: in your commands, such as show flash:.
As shown in Example 25-2, the dir command will list the main directory of the default file systems, whereas show flash: will list the entire contents of the default file system.
Router# dir
Directory of usbflash0:/
1 -rw- 68831808 Jun 5 2013 18:43:02 +00:00 c1900-universalk9-mz.SPA.152-4.M3.bin
2 -rw- 3064 Jun 5 2013 18:54:10 +00:00 cpconfig-19xx.cfg
3 drw- 0 Nov 6 2013 12:40:56 +00:00 ipsdir
10 drw- 0 Jun 5 2013 18:54:32 +00:00 ccpexp
246 -rw- 2464 Jun 5 2013 18:56:14 +00:00 home.shtml
247 -rw- 813 Nov 6 2013 12:44:22 +00:00 realm-cisco.pub.key
248 -rw- 2465 Nov 7 2013 11:22:20 +00:00 pre_autosec.cfg
255537152 bytes total (183939072 bytes free)
Router# show flash
-#- --length-- -----date/time------ path
1 68831808 Jun 5 2013 18:43:02 +00:00 c1900-universalk9-mz.SPA.152-4.M3.bin
2 3064 Jun 5 2013 18:54:10 +00:00 cpconfig-19xx.cfg
3 0 Nov 6 2013 12:40:56 +00:00 ipsdir
4 462 Nov 6 2013 13:14:52 +00:00 ipsdir/iosips-sig-delta.xmz
5 14978 Nov 6 2013 12:55:56 +00:00 ipsdir/iosips-sig-typedef.xmz
6 38523 Nov 6 2013 12:55:58 +00:00 ipsdir/iosips-sig-category.xmz
7 304 Nov 6 2013 12:53:40 +00:00 ipsdir/iosips-seap-delta.xmz
8 835 Nov 6 2013 12:53:40 +00:00 ipsdir/iosips-seap-typedef.xmz
9 500751 Nov 6 2013 12:56:28 +00:00 ipsdir/iosips-sig-default.xmz
10 0 Jun 5 2013 18:54:32 +00:00 ccpexp
11 0 Jun 5 2013 18:54:32 +00:00 ccpexp/external
<output omitted>
245 72 Jun 5 2013 18:56:12 +00:00 ccpexp/version.txt
246 2464 Jun 5 2013 18:56:14 +00:00 home.shtml
247 813 Nov 6 2013 12:44:22 +00:00 realm-cisco.pub.key
248 2465 Nov 7 2013 11:22:20 +00:00 pre_autosec.cfg
183939072 bytes available (71598080 bytes used)
Router#
Of particular interest is the first listing, which is the filename for the IOS image.
Notice that the configuration files stored in NVRAM are not shown in the output. To see these, first change directories (cd) to the NVRAM directory (nvram:). Then list the contents with the dir command, as shown in Example 25-3.
Router# cd nvram:
Router# dir
Directory of nvram:/
253 -rw- 1269 <no date> startup-config
254 ---- 5 <no date> private-config
255 -rw- 1269 <no date> underlying-config
1 -rw- 2945 <no date> cwmp_inventory
4 ---- 0 <no date> rf_cold_starts
5 ---- 76 <no date> persistent-data
6 -rw- 17 <no date> ecfm_ieee_mib
7 -rw- 559 <no date> IOS-Self-Sig#1.cer
8 -rw- 559 <no date> IOS-Self-Sig#2.cer
9 -rw- 0 <no date> ifIndex-table
262136 bytes total (251594 bytes free)
Router#
Note
You can also simply use the command dir nvram: to list the contents of the nvram: directory.
The file we are most interested in as CCNA exam candidates is the startup-config file.
File locations are specified in Cisco IFS using the URL convention shown in the example in Figure 25-1.
In Figure 25-1, the parts of the URL tftp://192.168.20.254/configs/backup-config can be dissected as follows:
tftp: is the prefix specifying the protocol.
Everything after the double slash (//) defines the file location.
192.168.20.254 is the location of the TFTP server.
configs is the master directory on the TFTP server.
backup-config is a sample filename.
The TFTP URL shown in Figure 25-1 is an example of a remote URL. Examples of URLs for accessing the local Cisco IFS include the following:
flash:configs/backup-config
system:running-config (this accesses RAM)
nvram:startup-config
Knowing the URL structure is important because you use it when copying configuration files from one location to another. The Cisco IOS Software copy command enables you to move configuration files from one component or device to another, such as RAM, NVRAM, or a TFTP server. Figure 25-2 shows the command syntax.
The source URL is where you are copying from. The destination URL is where you are copying to. For example, you are already familiar with the abbreviated command copy run start; however, in its most verbose form, this command specifies the file locations:
Router# copy system:running-config nvram:startup-config
The command states, “Copy the running configuration from the system’s RAM to NVRAM and save it with the filename startup-config.”
Example 25-4 demonstrates how to copy the current running configuration to a new local directory named configs that you would create.
Router# mkdir configs
Create directory filename [configs]? <Enter>
Created dir usbflash0:/configs
Router# copy system:running-config configs/backup-config
Destination filename [/configs/backup-config]? <Enter>
1269 bytes copied in 0.648 secs (1958 bytes/sec)
Other examples include copying from RAM to TFTP:
Router# copy system:running-config tftp:
Or simply:
Router# copy run tftp
Copying from TFTP to RAM:
Router# copy tftp: system:running-config
Or simply:
Router# copy tftp run
Copying from TFTP to the startup configuration file:
Router# copy tftp: nvram:startup-config
Or simply:
Router# copy tftp nvram
The copy commands using TFTP require more configurations (covered in the next section) after you enter them to carry out the instruction.
As any network grows, storing Cisco IOS Software images and configuration files on the central TFTP server gives you control over the number and revision level of Cisco IOS images and configuration files that must be maintained. Figure 25-3 shows a sample topology with a TFTP server.
Make sure that a TFTP server is configured and running on the network. Then follow these steps to copy a Cisco IOS Software image from flash memory to the network TFTP server:
Step 1 Ping the TFTP server to ensure that you have access to it:
R1# ping 172.16.1.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 31/31/32 ms
R1#
Step 2 Copy the current system image file from the router to the network TFTP server, using the copy flash: tftp: command in privileged EXEC mode. You then are prompted. The command requires that you enter the IP address of the remote host and the name of the source and destination system image files:
R1# copy flash: tftp:
Source filename []? c1900-universalk9-mz.SPA.152-4.M3.bin
Address or name of remote host []? 172.16.1.100
Destination filename [c1900-universalk9-mz.SPA.152-4.M3.bin]? <Enter>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<Output omitted>
68831808 bytes copied in 113.061 secs (608802 bytes/sec)
R1#
During the copy process, exclamation points (!) indicate the progress. Each exclamation point signifies that one User Datagram Protocol (UDP) segment has successfully transferred.
Verify with the dir or show flash: command that the router has sufficient disk space to accommodate the new Cisco IOS Software image, as shown in Example 25-5.
R1# dir
Directory of usbflash0:/
1 -rw- 68831808 Jun 5 2013 18:43:02 +00:00 c1900-universalk9-mz.SPA.152-4.M3.bin
2 -rw- 3064 Jun 5 2013 18:54:10 +00:00 cpconfig-19xx.cfg
3 drw- 0 Nov 6 2013 12:40:56 +00:00 ipsdir
10 drw- 0 Jun 5 2013 18:54:32 +00:00 ccpexp
246 -rw- 2464 Jun 5 2013 18:56:14 +00:00 home.shtml
247 -rw- 813 Nov 6 2013 12:44:22 +00:00 realm-cisco.pub.key
248 -rw- 2465 Nov 7 2013 11:22:20 +00:00 pre_autosec.cfg
249 drw- 0 Feb 8 2014 19:49:08 +00:00 configs
255537152 bytes total (183926784 bytes free)
R1#
The show flash: or dir commands help you determine the following:
The total amount of flash memory on the router
The amount of flash memory available
The names of all the files stored in the flash memory and the amount of flash occupied
Example 25-6 shows the commands necessary to copy an image stored on the TFTP server to flash.
R1# copy tftp flash
Address or name of remote host []? 172.16.1.100
Source filename []? c1900-universalk9-mz.SPA.152-4.M3.bin
Destination filename [c1900-universalk9-mz.SPA.152-4.M3.bin]? <Enter>
Loading c1900-universalk9-mz.SPA.152-4.M3.bin from 172.16.1.100: !!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[OK - 68831808 bytes]
68831808 bytes copied in 9.656 secs (7128397 bytes/sec)
R1#
The command asks for the IP address of the TFTP server and then the IOS image filename stored on the TFTP server that you want to copy over. When asked for the destination filename, you could change it, but this is not recommended because the name has specific meanings, as reviewed yesterday.
For today’s exam topics, refer to the following resources for more study.
3.134.99.32