Using the IOS Filesystem for Images

The upgrade procedure described in the previous sections is for a Class B IOS filesystem. Class B filesystems are probably the most common, but they aren't universalparticularly on high-end routers. There are also Class A and Class C filesystems ; the filesystem you have depends on the router you're using. Table 2-4 shows which filesystem a number of different routers use.

Table 2-4. Flash filesystem types

Filesystem type

Router

Class A

7000 series, C12000, and LightStream 1010

Class B

1003, 1004, 1005, 2500, 2600, 3600, 4000, AS5200, 800

Class C

3810, disk0 of SC3640

As far as a user is concerned, the filesystems differ primarily in the commands that they support. Table 2-5 lists the filesystem commands and what they do.

Table 2-5. Filesystem commands

Command

Filesystem

Description

cd

All

Changes the working directory.

delete

All

Deletes a file. On Class A filesystems , this command marks the file for deletion; the squeeze command purges deleted files from the filesystem. On Class B filesystems, the files disappear from directory listings (unless you use /all), but there is no way to reclaim the space, short of erasing the entire filesystem. On Class C filesystems, the file is deleted immediately.

dir

All

Displays the directory's contents. The /all option shows deleted and undeleted files.

erase

A, B

Erases the entire filesystem.

format

A, C

Formats the filesystem.

fsck

C

Verifies the filesystem's consistency.

mkdir

C

Makes a new subdirectory.

more

All

Displays a file's contents.

pwd

All

Displays the current directory.

rename

C

Renames a file.

rmdir

C

Deletes a directory.

show file descriptors

All

Shows open file descriptors.

show file information

All

Shows file size, location, etc.

show file system

All

Shows available filesystems on the device.

squeeze

A

Makes more room by moving files to the beginning of the flash memory, removing deleted files, and removing files with errors. Note that while this is a class A filesystem command, it is also IOS-dependent. Not all versions have this command.

tftp-server

All

Sets the device to act as a TFTP server.

undelete

A, B

Recovers any deleted files. Erased files cannot be undeleted.

verify

All

Verifies that a file's checksum is correct.

All filesystems use a notation similar to a URL to specify filenames and locations. File specifications look like this:

prefix:path/filename
prefix://server-name/path/filename
prefix://username:password@server-name/path/filename

The prefix indicates where the file is located; Table 2-6 lists the valid prefixes. The path indicates the directory where the file is found. If the prefix is ftp, rcp, or tftp, the URL refers to a file located on a server; you must supply a server name and, if necessary, a username and a password.

Table 2-6. Valid prefixes

Prefix

File location

bootflash

Boot flash memory.

flash

Flash memory.

ftp

FTP server.

null

Bit bucket; files copied to a null destination are discarded. The null prefix is useful for testing connectivity and determining file size.

nvram

Nonvolatile memory.

rcp

RCP server.

slot0

First PCMCIA flash memory card.

slot1

Second PCMCIA flash memory card.

system

Volatile system memory. Often used for access to the currently running system configuration.

You can view and copy files on remote servers using the TFTP, RCP, and FTP protocols, but you cannot delete files from them. For example, the following command uses TFTP to view the file config1 on the server myserver:

Router1# more tftp://myserver/config1
!
!
version 12.0
...

 

2.4.1. Upgrading Flash Memory Using the Filesystem Commands

The following example upgrades a 3640 router using flash, slot0 (PCMCIA flash card), and the IOS filesystem. The router is initially running IOS 11.2, which doesn't have the filesystem commands; we will upgrade to a version that does. The new IOS image was shipped to us on a flash card, which we have inserted into slot0 on the router. Now that the card is in, we can see the two images by using the show flash and show slot0 commands:

Router#show flash
System flash directory:
File Length Name/status
 1 5061960 c3640-ajs40-mz.112-23.P
[5062024 bytes used, 11715192 available, 16777216 total]
16384K bytes of processor board System flash (Read/Write)

Router#show slot0
PCMCIA Slot0 flash directory:
File Length Name/status
 1 8611616 c3640-js-mz_120-5_t1.bin
[8611680 bytes used, 8165536 available, 16777216 total]
16384K bytes of processor board PCMCIA Slot0 flash (Read/Write)

We have to use the show commands because IOS 11.2 doesn't have commands like dir. The first command shows the contents of the router's flash memory; the second shows the contents of the card we inserted into slot0.

Now we tell the router to load the image in slot0 instead of the image in the flash memory. We use the boot command to tell the router where the image is located; by default, the router loads the first image it finds in flash memory. The boot command modifies the router's running configuration; we copy the running configuration to the startup configuration, then reboot. Upon reboot, the router loads the image from the flash card in slot0:

Router#conf terminal
Router(config)#boot system flash slot0:c3640-js-mz_120-5_t1.bin
Router#copy run start
Router#reload

After the router reboots, the show version command shows we are running the new image:

Router>show version
Cisco Internetwork Operating System Software
IOS (tm) 3600 Software (C3640-JS-M), Version 12.0(5)T1, RELEASE SOFTWARE
(fc1)
Copyright (c) 1986-1999 by cisco Systems, Inc.
Compiled Tue 17-Aug-99 22:32 by cmong
Image text-base: 0x600088F0, data-base: 0x60F24000

ROM: System Bootstrap, Version 11.1(20)AA2, EARLY DEPLOYMENT RELEASE
SOFTWARE (fc1)

Router uptime is 0 minutes
System returned to ROM by reload
System image file is "slot0:c3640-js-mz_120-5_t1.bin"

Now we can use the filesystem commands:

Router#dir flash:
Directory of flash:/
 1 -rw- 5061960  c3640-ajs40-mz.112-23.P
16777216 bytes total (11715192 bytes free)

Router#dir slot0:
Directory of slot0:/
 1 -rw- 8611616  c3640-js-mz_120-5_t1.bin
16777216 bytes total (8165536 bytes free)

Next, we want to copy the image from the PCMCIA card to the router's flash memoryit's not a good idea to rely on booting from the flash card. We can use the filesystem commands to perform this copy:

Router#copy slot0:c3640-js-mz_120-5_t1.bin flash:c3640-js-mz_120-5_t1.bin
Destination filename [c3640-js-mz_120-5_t1.bin]?
Erase flash: before copying?[confirm]n
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
Verifying checksum... OK (0xB648)
8611616 bytes copied in 38.440 secs (226621 bytes/sec)

Check the flash contents:

Router#dir flash:
Directory of flash:/
 1 -rw- 5061960  c3640-ajs40-mz.112-23.P
 2 -rw- 8611616  c3640-js-mz_120-5_t1.bin
16777216 bytes total (3103512 bytes free)

Now, we can either delete the old 11.2 image or tell the router which image to boot. If we don't use the boot command to specify an image, the router will load the first available image, which will be the old 11.2 image. (Note that this wouldn't have been an issue if we had told the router it could erase flash memory before copying. However, that would have left us without a backup image to boot if the new image failed.) So we issue two more boot commands: the first to tell the router not to boot the image in slot0, and the second to specify the image we want. We then copy the running configuration into the startup configuration. Finally, we reboot and remove the slot0 memory card.

Router#config terminal
Router(config)#no boot system flash slot0:c3640-js-mz_120-5_t1.bin
Router(config)#boot system flash c3640-js-mz_120-5_t1.bin
Router(config)#^Z
Router#copy run start
Router#reload

When it reboots, the router loads the right image from its flash memory:

Router>show version
Cisco Internetwork Operating System Software
IOS (tm) 3600 Software (C3640-JS-M), Version 12.0(5)T1, RELEASE SOFTWARE
(fc1)
Copyright (c) 1986-1999 by cisco Systems, Inc.
Compiled Tue 17-Aug-99 22:32 by cmong
Image text-base: 0x600088F0, data-base: 0x60F24000

ROM: System Bootstrap, Version 11.1(20)AA2, EARLY DEPLOYMENT RELEASE
SOFTWARE (fc1)
ROM: 3600 Software (C3640-AJS40-M), Version 11.2(23)P, RELEASE SOFTWARE
(fc1)

Router uptime is 0 minutes
System returned to ROM by power-on
System image file is "flash:c3640-js-mz_120-5_t1.bin"

Let's delete the old image anyway:

Router#delete c3640-ajs40-mz.112-23.P
Delete filename [c3640-ajs40-mz.112-23.P]?
Delete flash:c3640-ajs40-mz.112-23.P? [confirm]y
Router#dir /all flash:
Directory of flash:/

 1 -rw- 5061960  [c3640-ajs40-mz.112-23.P]
 2 -rw- 8611616  c3640-js-mz_120-5_t1.bin

16777216 bytes total (3103512 bytes free)

Notice that our deleted file is still there; it won't be deleted permanently until we give the erase command. On a Class A filesystem, we could use the squeeze command to erase the deleted file. With this filesystem, though, we are stuck with the deleted file until we give the erase command, which erases the entire filesystem. In this case, we would have to reload our new image. Since there's plenty of room in flash, there is no need to clean the filesystem out now. Next time we upgrade this router, though, we will probably answer "yes" to the "Erase flash before copying" question.

Getting Started

IOS Images and Configuration Files

Basic Router Configuration

Line Commands

Interface Commands

Networking Technologies

Access Lists

IP Routing Topics

Interior Routing Protocols

Border Gateway Protocol

Quality of Service

Dial-on-Demand Routing

Specialized Networking Topics

Switches and VLANs

Router Security

Troubleshooting and Logging

Quick Reference

Appendix A Network Basics

Index



Cisco IOS in a Nutshell
Cisco IOS in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596008694
EAN: 2147483647
Year: 2006
Pages: 1031
Authors: James Boney

Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net