Friday, October 24, 2014

Router IOS Upgrade via tftpdnld and format flash Command

There were some IT stuff that my company's warehouse got rid of not so long ago. I was lucky to have picked up a couple of Cisco 64 MB Compact Flash (CF) cards. So I tested them out and inserted them in one of my lab router to update its Internetwork Operating Software (IOS).

I've used the handy tftpdnld command in ROM Monitor (ROMmon) mode. I was able to get to ROMmon by booting up the router without its CF card. I also connected an RJ45 cable to port F0/0 (sometimes other ports doesn't work) on the 1841, set my laptop to 10.1.1.1/24 and ran a TFTP client. The commands in ROMmon mode are case sensitive.

rommon 1 > tftpdnld

Missing or illegal ip address for variable IP_ADDRESS
Illegal IP address.

usage: tftpdnld [-hr]
  Use this command for disaster recovery only to recover an image via TFTP.
  Monitor variables are used to set up parameters for the transfer.
  (Syntax: "VARIABLE_NAME=value" and use "set" to show current variables.)
  "ctrl-c" or "break" stops the transfer before flash erase begins.

  The following variables are REQUIRED to be set for tftpdnld:
            IP_ADDRESS: The IP address for this unit
        IP_SUBNET_MASK: The subnet mask for this unit
       DEFAULT_GATEWAY: The default gateway for this unit
           TFTP_SERVER: The IP address of the server to fetch from
             TFTP_FILE: The filename to fetch

  The following variables are OPTIONAL:
          TFTP_VERBOSE: Print setting. 0=quiet, 1=progress(default), 2=verbose
      TFTP_RETRY_COUNT: Retry count for ARP and TFTP (default=18)
          TFTP_TIMEOUT: Overall timeout of operation in seconds (default=7200)
         TFTP_CHECKSUM: Perform checksum test on image, 0=no, 1=yes (default=1)
               FE_PORT: 0= (default), 1
         FE_SPEED_MODE: 0=10/hdx, 1=10/fdx, 2=100/hdx, 3=100/fdx,
                        4=Auto (default)

  Command line options:
   -h: this help screen
   -r: do not write flash, load to DRAM only and launch image

rommon 1 > IP_ADDRESS=10.1.1.2    // I USED THE 10.x.x.x NETWORK TO AVOID CONFLICT WITH MY WIFI 192.168.1.0/24 SUBNET
rommon 2 > IP_SUBNET_MASK=255.255.255.0
rommon 3 > DEFAULT_GATEWAY=10.1.1.1
rommon 4 > TFTP_SERVER=10.1.1.1
rommon 5 > TFTP_FILE=c1841-adventerprisek9-mz.124-24.T2.bin
rommon 6 > tftpdnld    // NOT CASE SENSITIVE

          IP_ADDRESS: 10.1.1.2
      IP_SUBNET_MASK: 255.255.255.0
     DEFAULT_GATEWAY: 10.1.1.1
         TFTP_SERVER: 10.1.1.1
           TFTP_FILE: c1841-adventerprisek9-mz.124-24.T2.bin
        TFTP_MACADDR: 00:0a:b8:f8:83:92
        TFTP_VERBOSE: Progress
    TFTP_RETRY_COUNT: 18
        TFTP_TIMEOUT: 7200
       TFTP_CHECKSUM: Yes
             FE_PORT: 0
       FE_SPEED_MODE: Auto Detect

Invoke this command for disaster recovery only.
WARNING: all existing data in all partitions on flash will be lost!
Do you wish to continue? y/n:  [n]:  y
.
Receiving c1841-adventerprisek9-mz.124-24.T2.bin from 10.1.1.1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

<OUTPUT TRUNCATED>

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.................. [TIMED OUT]
TFTP: Operation terminated.


For some reason the TFTP timed out in the end. So I boot up my 1841 with a working IOS and saw the CF that I picked up wasn't formatted properly. I used the format flash: command to format the CF card and in order to be compatible with the router.


R1#show flash
Unformatted Partition, please format it.

R1#
Unknown file system detected.
Use format command to format the card as DOS File System.

R1#format ?
  flash:  Filesystem to be formatted

R1#format flash: ?
  <cr>

R1#format flash:
Format operation may take a while. Continue? [confirm]
Format operation will destroy all data in "flash:".  Continue? [confirm]
Enter volume ID (up to 64 chars)[default flash:]:

Primary Partition created...Size 61 MB

Drive communication & 1st Sector Write OK...
Writing Monlib sectors....
Monlib write complete

Format: All system sectors written. OK...

Format: Total sectors in formatted partition: 125408
Format: Total bytes in formatted partition: 64208896
Format: Operation completed successfully.

Format of flash: complete    // JUST TOOK A FEW SECONDS TO RE-FORMAT


Since I'm in privileged EXEC mode on the router, I can perform the IOS upgrade via the copy tftp flash command.

R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#interface fastethernet0/0
R1(config-if)#ip address 10.1.1.1 255.255.255.0
R1(config-if)#no shutdown
*Oct 25 06:23:03.643: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Oct 25 06:23:04.643: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#end
R1#
*Oct 25 06:23:29.107: %SYS-5-CONFIG_I: Configured from console by console
R1#copy tftp://10.1.1.1/c1841-adventerprisek9-mz.124-24.T2.bin flash:
Destination filename [c1841-adventerprisek9-mz.124-24.T2.bin]?
Accessing tftp://10.1.1.1/c1841-adventerprisek9-mz.124-24.T2.bin...
Loading c1841-adventerprisek9-mz.124-24.T2.bin from 10.1.1.1 (via FastEthernet0/0): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[OK - 40529832 bytes]

40529832 bytes copied in 183.628 secs (220717 bytes/sec)

R1#reload

System configuration has been modified. Save? [yes/no]: n
Proceed with reload? [confirm]

*Oct 25 06:28:17.659: %SYS-5-RELOAD: Reload requested  by console. Reload Reason: Reload Command.

<OUTPUT TRUNCATED>

R1>enable
R1#dir    // ALTERNATIVE TO show flash
Directory of flash:/

    1  -rw-    40529832  Oct 25 2014 06:26:48 +00:00  c1841-adventerprisek9-mz.124-24.T2.bin

64004096 bytes total (23474176 bytes free)

R1#show version | include IOS
Cisco IOS Software, 1841 Software (C1841-ADVENTERPRISEK9-M), Version 12.4(24)T2, RELEASE SOFTWARE (fc2)

No comments:

Post a Comment