# Managing Flash Cards on SRP Modules

Each SRP module contains a flash card that stores system files. On the E120 and E320 routers, each SRP module can have an additional flash card; the second card is reserved for the storage of core dumps.

In this documentation, the flash card on the primary SRP module is referred to as the primary flash card; the flash card on the redundant SRP module is referred to as the redundant flash card.

If you have two SRP modules installed in a router, you can use flash cards of different capacities on the SRP modules. The effective capacity of the higher-capacity flash card equals that of the lower-capacity flash card.

## Flash Features

The software contains a number of features that optimize the way the router restores its configuration if it is shut down improperly:

- The router tracks improper shutdowns.
- After an improper shutdown, the router runs an investigation of the file allocation table (FAT) the next time it reboots.
- The router creates backups of critical files.
- When you install a new flash card or restart the router after shutting it down incorrectly, a utility scans the flash card to detect corrupt sectors. If the utility finds files or directories that contain corrupt sectors, it removes the files and directories, because they can no longer be used. The utility also fixes problems with unused sectors. If the utility cannot correct a corrupt sector, it marks the sectors so that they cannot be reused. Errors in the boot block, FAT, or root directory are fatal and cannot be corrected by the scan utility.
- In a router that contains two SRP modules, if the scanning utility detects corrupt sectors in flash on the primary SRP module during rebooting, the primary SRP module reboots again. Both SRP modules now have standby status and reboot. The first SRP module to complete rebooting becomes the primary. Because the former redundant module started to reboot first, it likely becomes the primary. When the former primary module has rebooted and the scan utility has fixed corrupt sectors in its flash card, the SRP modules will synchronize. Any files or directories removed by the scan utility are restored during the synchronization.
- If you reboot the router before it has completely written configuration updates to the flash card, the router starts with the last saved configuration. If you reboot the router after it has written the configuration updates to the flash card, but before it has applied those updates to actual configuration data, the configuration update process resumes immediately following the reboot and is completed before any application accesses its configuration data.

## Flash Features on the E120 Router and the E320 Router

The E120 and E320 routers can have a second flash card installed with its SRP modules. Device names are reserved for the E120 and E320 routers flash card slots: disk0, disk1, standby-disk0, and standby-disk1. For backward compatibility, you can use the name standby, which is equivalent to standby-disk0. You can use the second card (disk1 or standby-disk1) only for storage of core dump (.dmp) files. When the a card is installed and mounted as disk1 or standby-disk1, all .dmp files are automatically stored on this card. You must use the card mounted as disk0 or standby-disk0 for all other file types. Core dump files are stored on disk0 or standby-disk0 only when a second card is not installed.

The copy, dir, delete, and rename commands all recognize the device names, as in the following examples. Disk1 and standby-disk1 accept only dump files. This means that you can copy only .dmp files to the second disk, delete only .dmp files from the second disk, and rename only .dmp files on the second disk.

    host1#copy reset05.dmp server2:reset05.dmp
    host1#copy disk0:051802.dmp server2:reset05.dmp

    host1#delete disk1:reset05.dmp
    host1#delete standby:reset05.dmp
    host1#delete standby-disk0:reset05.dmp
    host1#delete standby-disk1:reset05.dmp

    host1#rename standby-disk1:foo.dmp standby-disk1:bar.dmp
    host1#rename foo.dmp /outgoing/bar.dmp

    host1#dir
    Please wait...

    active/standby file systems are synchronized

       unshared                                                             in
         file                   size         size         date (UTC)        use
    --------------            ---------    --------   -------------------   ---
    disk0:reboot.hty             654336      654336   03/01/2005 16:08:28
    disk0:system.log               3644        3644   11/30/2004 20:48:18
    disk0:special.rel         159256660    61695156   02/18/2005 10:31:48
    disk0:lm4_12.dmp          344200394   344200394   02/12/2005 12:12:12
    standby-disk0:lm4_13.dmp  344200394   344200394   02/13/2005 13:13:13
    disk1:lm4_14.dmp          344200394   344200394   02/14/2005 14:14:14
    standby-disk1:lm4_15.dmp  344200394   344200394   02/15/2005 15:15:15
    disk0:boston.scr                833         833   02/22/2005 17:46:18
    disk0:bulkstats.scr             170         170   02/13/2006 17:34:30
    ram:bulkstats1.sts              737         737   03/07/2006 09:07:52

                  Disk capacity
                  -------------
              Capacity      Free      Reserved
    Device    (bytes)      (bytes)    (bytes)
    ------   ----------   ---------   --------
    disk0:   1025482752   342066375   68157440
    ram:        5767168     5734400          0

Because the device names are reserved, if you upgrade from a release where you previously used those names for remote hostnames, an error message appears when you try to use that remote hostname:

%ambiguous file name, reserved disk device name "disk1" must be removed from host table

To prevent corruption of flash cards, always issue the halt command before you remove an SRP module. See Removing an SRP Module. Issue the halt command before you remove a flash card installed as disk 0 or standby disk 0. Flash cards installed and mounted as disk1 or standby disk1 can be safely removed by issuing the no mount command for the card and then ejecting the card. Always reboot the router using the rebooting procedure. See Booting the System . Do not reboot the router by switching it off and on.

## Installing and Removing Flash Cards

For information about replacing flash cards, see ERX Hardware Guide, Chapter 4, Installing Modules, or E120 and E320 Hardware Guide, Chapter 4, Installing Modules.

Before you remove the second flash card (disk1) on the SRP 120 module or the SRP 320 module, you must first unmount the card with the no mount command. This command causes the file system to reject all subsequent requests for opening files on the flash card and closes all open files. When this is accomplished, the disk is marked as safely unmounted and a status message indicates that is safe to eject the disk. A status message is displayed when you issue the mount or no mount command:

- When you issue the mount command:
  % Device is mounted% Device is already mounted% Device is not present
- When you issue the no mount command:
  % Device is dismounted% Device is already dismounted% Device is not present% Command failed, files are open on device

  | Caution: When you eject a mounted disk 0 while the router is in an operational state, the SRP module initiates a reload. When you eject a mounted disk 1, data on the disk can be corrupted, but the router does not reboot.

mount

- Use to mount the disk. If the disk was not safely unmounted previously, then before mounting the file system and permitting user access the command initiates disk and file system integrity checks. These checks are the same ones that are automatically performed when a disk is installed and the SRP module is reloaded.
- This command applies only to the flash card installed in slot 1 on an SRP 320 module. The command is rejected if you specify disk0, because that card is required for system operation and cannot be unmounted.
- Example
  host1#mount disk1
- The no version prepares the flash card for safe removal. The router subsequently behaves as if the second flash card is no longer present. To access the second card, you must either eject and re-insert the card, or issue the mount command for the card. You can use the force keyword to force the dismount even when files on the flash disk are open for modification.
- See mount.

## Synchronizing Flash Cards

| Note: The information in this section does not apply to the ERX310 router, which does not support SRP module redundancy.

When the router contains two SRP modules, the contents of the modules’ flash cards need to be synchronized. Synchronization prevents the redundant flash card from overwriting saved files on the primary flash card if the primary SRP module fails and the redundant SRP module takes control.

By default, autosynchronization is enabled on the router. Autosynchronization runs as a background process every 5 minutes, tracking changes in image, configuration, and script files, and keeping the two SRP modules synchronized. You can also synchronize the SRP modules manually by issuing the synchronize command.

Before synchronization, the router does the following:

- Verifies that critical files on the primary SRP module are present. If files are missing, the router does not proceed with the synchronization.
- Verifies whether there is enough space on the redundant flash card to copy all the new or changed files from the primary flash card.

Depending on the outcome of the space verification, the router proceeds as follows:

- If the card has enough space, the router copies new or changed files from the primary flash card to the redundant flash card without deleting any files on the redundant flash card. If the router is interrupted while it is synchronizing with this method, the synchronization resumes when it has recovered from the interruption.
- If the card does not have enough space, the router deletes any files on the redundant flash card that do not appear on the primary flash card, then copies new or changed files from the primary flash card to the redundant flash card. If the router is interrupted while it is synchronizing with this method, it does not resume the synchronization when it has recovered from the interruption.

If an SRP synchronization is in progress or has failed and the router is recovering, the router prevents the redundant SRP module from taking the primary role while the primary is rebooting and for 30 seconds after the primary module has rebooted. These conditions prevent a redundant SRP module with corrupted or missing files from becoming the primary and overwriting files or directories on the primary module.

synchronize

- Use to force the file system of the redundant SRP module to synchronize with the flash file system of the primary SRP module.
- If you synchronize the redundant SRP module with the primary SRP module and the redundant module is armed with a release different from the one it is currently running, the redundant SRP module is automatically rebooted to load the armed release.
- Optionally, you can use the low-level-check keyword to force the router to validate all files or only configuration files in NVS, and to synchronize all files that failed the checksum test during the flash-disk-compare command as well as any other files that are unsynchronized. See Validating and Recovering Redundant SRP File Integrity for details.

  | Note: In most cases, use the synchronize command instead of the synchronize low-level-check command. The synchronize low-level-check command is provided for troubleshooting, and is intended to be used under direction from JTAC.

- Examples
  host1#synchronize host1#synchronize low-level-check all host1#synchronize low-level-check configuration
- There is no no version.
- See synchronize.

### Synchronizing Flash Cards of Different Capacities

If the capacity of the primary flash card is equal to or smaller than that of the redundant flash card, the router copies all the files from the primary flash card to the redundant flash card. However, if the capacity of the primary flash card exceeds that of the redundant flash card, the router creates a hidden synchronization reserve file on the primary flash card, provided enough space is available for the file.

The purpose of the synchronization file is to prevent the creation of data that cannot fit on the redundant flash card. The file contains no useful data, and does not appear when you view the files in NVS. The size of the file is equal to the difference in capacities of the two flash cards. For example, if the primary flash card has a capacity of 224 MB, and the redundant flash card has a capacity of 220 MB, the size of the synchronization file is 4 MB, and only 220 MB of space is available on the primary flash card.

If the primary flash card does not have enough space to create the synchronization reserve file, the synchronize command fails, and you see a warning message on the console. To resolve this issue, either delete unwanted files from the primary flash card or replace the redundant flash card with a higher-capacity flash card.

### Disabling Autosynchronization

If autosynchronization is enabled while you are copying long scripts or installing new software releases, it detects a disparity between the modules during the middle of the process. This feature causes significant unnecessary synchronization, resulting in prolonged copy times.

If you have installed a redundant SRP module, perform the following steps before copying long scripts:

1. Turn off autosynchronization with the disable-autosync command.
2. Perform the installation or copy the script.
3. Reenable autosynchronization with the no disable-autosync command.
4. Manually synchronize the modules with the synchronize command.

Refer to the commands and guidelines in the previous section and in the sections that follow.

disable-autosync

- Use to turn off automatic synchronization between the primary and redundant SRP modules.
- Example
  host1(config)#disable-autosync
- Use the no version to revert to the default situation, in which automatic synchronization runs as a background process every 5 minutes.
- See disable-autosync.

## Validating and Recovering Redundant SRP File Integrity

| Note: The information in this section does not apply to the ERX310 router, which does not support SRP module redundancy.

Even when flash cards on the primary and redundant SRP modules are synchronized, differences can exist in the content of files that reside on the primary flash card and the redundant flash card. You can use the flash-disk compare command to detect these differences so you can validate and, if necessary, recover the file integrity of the redundant SRP module.

The flash-disk compare command validates only those files that are synchronized between the primary and redundant SRP modules. It does not compare files that are normally excluded from the synchronization process, such as log files and core dump files. The command uses a simple checksum error detection algorithm to compare the contents of a file residing on the flash card of the primary SRP module with the contents of the same file residing on the flash card of the redundant SRP module.

To validate and recover redundant SRP file integrity:

1. Ensure that the file systems on the primary flash card and the redundant flash card are synchronized. (See Synchronizing Flash Cards for details.)
2. Issue the flash-disk compare command, specifying whether to perform the checksum validation for all files in NVS or only for configuration files.
   host1#flash-disk compare all host1#flash-disk compare configuration

   The flash-disk compare configuration command, which validates only configuration files, excludes larger files such as software releases and scripts from the validation process. As a result, this command takes less time to complete than the flash-disk compare all command, which validates all NVS files.

3. Review the flash-disk compare output to determine whether any files failed the checksum validation.

   If the flash-disk compare command detects differences in the content of one or more files, the router reports a checksum test failure.

4. If one or more files failed the checksum validation, determine whether the corrupted files reside on the primary SRP module or on the redundant SRP module.
5. If the corrupted file resides on the primary SRP module, issue the srp switch command to force a switch from the primary SRP module to the redundant SRP module.

   This action ensures that the error-free version of the file will be on the SRP module that takes control after the switch.

6. Issue the synchronize command with the low-level-check keyword to force the router to:
   - Validate all files in NVS (when you use the all keyword) or only configuration files in NVS (when you use the configuration keyword).
   - Synchronize all files that failed the checksum test during the flash-disk compare command, as well as any other unsynchronized files.
     host1#synchronize low-level-check all host1#synchronize low-level-check configuration

     This action resolves any file discrepancies between the primary and redundant SRP modules and restore SRP file integrity.

     | Note: Both the flash-disk compare and synchronize low-level-check commands perform CPU-intensive processing that can take several minutes to complete. For best results, do not run these commands simultaneously on the same router. In addition, do not run multiple instances of the flash-disk-compare command simultaneously on the same router.

flash-disk compare

- Use to perform a checksum validation that compares the contents of the NVS file system on the primary SRP module with the contents of the NVS file system on the redundant SRP module.
- The command validates only those files that are synchronized between the primary and redundant SRP modules; it does not validate log files, core dump files, and other files that are excluded from the system synchronization process.
- Specify one of the following keywords:
  - all—Compares all files in NVS; this option can take several minutes to complete.
  - configuration—Compares only configuration files; this option takes less time to complete because it compares only a subset of the files in the NVS file system.
- If all files pass the validation test, the router reports that all checksums matched and displays the total number of files and total number of bytes of information compared.
- If one or more files fail the validation test, the router reports a checksum test failure and does not display the total number of files and bytes compared.
- If one or more of the following conditions exist, the command fails and the router displays a message that explains why it cannot perform the checksum test:
  - The file systems on the primary flash card and the redundant flash card are not synchronized.
  - The router does not contain a redundant SRP module.
  - The redundant SRP module is offline.
- Example 1—Shows output when all files passed the validation test

      host1#flash-disk compare all
      WARNING: This command may take several minutes to complete.
      Proceed? [confirm]
      WARNING: No changes should be made to the system while this command is in
               progress.
      Please wait.........................................................
      All file checksums matched.
      Number of Files = 866
      Number of Bytes = 61660650

- Example 2—Shows output when one or more configuration files failed the validation test

      host1#flash-disk compare configuration
      WARNING: This command may take several minutes to complete.
      Proceed? [confirm]
      WARNING: No changes should be made to the system while this command is in
               progress.
      Please wait......
      At least one configuration file failed checksum test.

- There is no no version.
- See flash-disk compare.

synchronize

- Use to force the NVS file system of the redundant SRP module to synchronize with the NVS file system of the primary SRP module.
- If you synchronize the redundant SRP module with the primary SRP module and the redundant module is armed with a release different from the one it is currently running, the redundant SRP module is automatically rebooted to load the armed release.
- Optionally, you can use the low-level-check keyword to force the router to validate all files or only configuration files in NVS, and to synchronize all files that failed the checksum validation test during the flash-disk-compare command as well as any other files that are unsynchronized.
- When you use the low-level-check keyword, you must also specify one of the following keywords:
  - all—Validates all files in NVS, and synchronizes all files that failed the checksum test as well as any other unsynchronized files; this option can take several minutes to complete.
  - configuration—Validates all configuration files in NVS, and synchronizes all files that failed the checksum test as well as any other unsynchronized files; this option takes less time to complete because it validates only a subset of the files in the NVS file system.
- If one or more of the following conditions exist when you use the low-level-check keyword, the command fails and the router displays a message that explains why it cannot perform the synchronization:
  - The router does not contain a redundant SRP module.
  - The redundant SRP module is offline.
  - The armed releases are different on the primary SRP and redundant SRP.
- Examples
  host1#synchronize host1#synchronize low-level-check all host1#synchronize low-level-check configuration
- There is no no version.
- See synchronize.

## Reformatting the Primary Flash Card

You can reformat the primary flash card. To do so:

1. Access Boot mode.
   1. From Privileged Exec mode, enter the reload command. Information about the reloading process is displayed.
   2. When the countdown begins, press the mb key sequence (case-insensitive).

      The CLI enters Boot mode (:boot## prompt). If you do not press the mb key sequence, the reloading process continues and returns the CLI to the normal User Exec mode.

2. Issue the flash-disk initialize command.

flash-disk initialize

- Use to reformat the flash card.
- You can perform a low-level format of the flash card.
- On the E120 and E320 routers only, you can use this command to format a second flash card installed as disk1. You can issue this command in Boot mode for either flash card. In Privileged Exec mode, you can use the disk1 keyword to access the unmounted second flash card while the router is in an operational state.
- This command is available for disk1 in Privileged Exec mode only on SRP 320 modules. This command is not accepted for disk0 in Privileged Exec mode.
- Example 1

      host1#halt primary-srp
      host1#reload
      WARNING: Execution of this command will cause the system to reboot.
      Proceed with reload? [confirm]
      Reload operation commencing, please wait...
      [ Press mb]
      :boot##flash-disk initialize

- Example 2—On an SRP 320 module

      host1#no mount disk1
      % Device is dismounted
      host1#flash-disk initialize disk1
      WARNING: Execution of this command will cause the contents of disk1 to be erased.
      Proceed with Flash disk initialization? [confirm]
      Please wait..............................

- There is no no version.
- See flash-disk initialize.

## Copying the Image on the Primary SRP Module

| Note: The information in this section does not apply to the ERX310 router, which does not support SRP module redundancy.

You can copy the contents of NVS on the primary SRP module to a spare flash card. To do so:

1. Access Boot mode.
   1. From Privileged Exec mode, enter the reload command. Information about the reloading process is displayed.
   2. When the countdown begins, press the mb key sequence (case-insensitive).

      This CLI enters Boot mode (:boot## prompt).
      If you do not press the mb key sequence, the reloading process continues and returns the CLI to the normal User Exec mode.

2. Issue the flash-disk duplicate command.
3. Follow the instructions on the screen. When prompted, insert the original or spare flash card in the primary SRP module.

flash-disk duplicate

- Use to copy the contents of the primary flash card to a spare flash card.
- The primary and spare flash cards must be from the same manufacturer and must have the same size.

  | Note: This command is available only in Boot mode.

- When you issue the flash-disk duplicate command, insert the original and spare flash cards when prompted. The router copies the flash card contents incrementally, so you may need to exchange the flash cards several times.
- Example

      host1#halt primary-srp
      host1#reload
      WARNING: Execution of this command will cause the system to reboot.
      Proceed with reload? [confirm]
      Reload operation commencing, please wait...
      [ Press mb]
      :boot##flash-disk duplicate

- There is no no version.
- See flash-disk duplicate.

## Scanning Flash Cards

You can find both structural errors in the data in NVS and physical errors in the flash card. You can also remove files with errors, and attempt to repair structural or physical errors.

check-disk

- Use to find and repair structural inconsistencies and damage in the DOS file system in NVS on the primary SRP module.
- If the router contains primary and redundant modules, only NVS on the primary SRP module is scanned.
- On the E120 and E320 routers only, you can use this command to check and repair a second flash card installed as disk1. You can issue this command in Boot mode for either flash card. In Privileged Exec mode, you can use the disk1 keyword to access the unmounted second flash card while the router is in an operational state.
- This command is available for disk1 in Privileged Exec mode only on SRP 320 modules. This command is not accepted for disk0 in Privileged Exec mode.
- Example

      :boot## check-disk disk0
      Copyright (c) 1993-1996 RST Software Industries Ltd. Israel. All rights reserved
      ver: 2.6 FCS
      Disk Check In Progress ...
              total disk space (bytes) :                    512,122,880
              bytes in each allocation unit :               8,192
              total allocation units on disk :              62,515
              bad allocation units :                        1
              available bytes on disk :                     120,651,776
              available clusters on disk :                  14,728
              maximum available contiguous chain (bytes) :  120,651,776
              available space fragmentation (%) :           0
              clusters allocated :                          47,786
      Done Checking Disk.

- There is no no version.
- See check-disk.

flash-disk scan

- Use to find and repair files with physical errors in NVS. These errors are created if the router is not powered down or reset correctly.
- If the router contains primary and redundant modules, only NVS on the primary SRP module is scanned.
- Use the repair keyword to fix nonfatal errors found on the disk. If the repair fails, the router no longer uses the corrupted areas.
- On the E120 and E320 routers only, you can use this command to find and repair files on a second flash card installed as disk1. You can issue this command in Boot mode for either flash card. In Privileged Exec mode, you can use the disk1 keyword to access the unmounted second flash card while the router is in an operational state.
- This command is available for disk1 in Privileged Exec mode only on SRP 320 modules. This command is not accepted for disk0 in Privileged Exec mode.
- Example

  In this example, the user scans NVS and finds one file with an error. The user then issues the flash-disk scan with the repair keyword to remove the file. Finally, the user scans NVS again, and finds no files with errors.

      :boot##flash-disk scan
      Proceed with Flash disk scan? [confirm]
      Srp PCMCIA Card Scan...
      Boot Block OK
      File Allocation Table OK
      Root Directory OK
      Checking File Space
      Please Wait...
      Checking Free Space
      Please Wait...
      PCMCIA Card Scan Detected Errors in:
      \\images\ct1Diag\ct1Diag3c440e9e.cmp

      PCMCIA Card Scan successful!

      :boot##flash-disk scan repair
      WARNING: Execution of this command may cause the contents of the Flash disk to be modified.
      Proceed with Flash disk scan? [confirm]
      Srp PCMCIA Card Scan...
      Boot Block OK
      File Allocation Table OK
      Root Directory OK
      Checking File Space
      Please Wait...
      Checking Free Space
      Please Wait...
      PCMCIA Card Scan Removed:
      \\images\ct1Diag\ct1Diag3c440e9e.cmp

      PCMCIA Card Scan successful!

      :boot##flash-disk scan
      Proceed with Flash disk scan? [confirm]
      Srp PCMCIA Card Scan...
      Boot Block OK
      File Allocation Table OK
      Root Directory OK
      Checking File Space
      Please Wait...
      Checking Free Space
      Please Wait...
      PCMCIA Card Scan successful!

- There is no no version.
- See flash-disk scan.

## Monitoring Flash Cards

Use the show nvs command to monitor the status of NVS on the primary SRP module. Use the show flash command to view information about the flash card.

show flash

- Use to display information about the flash card.
- Field descriptions
  - Active System Controller—Information for flash cards on the active SRP module
  - disk0—Flash card installed in slot 0 of the SRP module
  - disk1—Flash card installed in slot 1 of the SRP module; available only on SRP modules for the E120 and E320 routers
  - Manufacturer—Name of manufacturer of the installed flash card
  - Capacity—Total capacity of the flash card, in bytes
  - Standby System Controller—Information for flash cards on the standby SRP module
- Example

      host1#show flash

                Active System Controller:
                -------------------------
      Device    Manufacturer     Capacity    Status
      ------   --------------   ----------   -------
       disk0   SILICONSYSTEMS   1047126528   mounted
       disk1   STI              1024966656   mounted

                   Standby System Controller:
                   --------------------------
         Device        Manufacturer     Capacity    Status
      -------------   --------------   ----------   -------
      standby-disk0   SILICONSYSTEMS   1047674880   mounted
      standby-disk1   SILICONSYSTEMS   1047674880   mounted

- See show flash.

show nvs

- Use to monitor NVS status.
- Field descriptions
  - total nvs file sizes—Sum of sizes of all files in NVS, in bytes
  - total nvs file errors—Number of read and write errors in all files in NVS
  - nvs flash in use—NVS used, in bytes
  - available nvs flash—NVS available, in bytes
- Example

      host1#show nvs
      total nvs file sizes =  228864
      total nvs file errors = 0
      nvs flash in use =      1265152
      available nvs flash =   35435008

- See show nvs.