3. File System Management

3.1. The File System

The SR OS file system is used to store files used and generated by the system, for example, image files, configuration files, logging files and accounting files.

The file commands allow you to copy, create, move, and delete files and directories, navigate to a different directory, display file or directory contents and the image version.

Although some of the storage devices on routers are not actually compact flash devices (for example, cf1: on the 7950 XRS is an internal SSD), we refer to all storage devices as compact flash.

3.1.1. Compact Flash Devices

The file system is based on a DoS file system (with an optional Reliance file system). In the 7750 SR and 7450 ESS, each control processor can have up to three compact flash devices numbered one through three. In the 7950 XRS, each CCM has an SSD and up to two compact flash devices. The names for these devices are:

  1. cf1:
  2. cf2:
  3. cf3:

The above device names are relative device names as they refer to the devices local to the control processor with the current console session. As in the DoS file system, the colon (“:”) at the end of the name indicates it is a device.

The three compact flash devices on the 7450 ESS and 7750 SR OS are removable and have an administrative state (shutdown/no shutdown).

The cf2: and cf3: compact flash devices on the 7950 XRS routers are removable and have an administrative state (shutdown/no shutdown). cf1: is an internal SSD.

Note:

To prevent corrupting open files in the file system, you should only remove a compact flash that is administratively shutdown. The SR OS gracefully closes any open files on the device, so it can be safely removed.

3.1.2. URLs

The arguments for the SR OS file commands are modeled after standard universal resource locater (URL). A URL refers to a file (a file-url) or a directory (a directory-url).

The SR OS supports operations on both the local file system and on remote files. For the purposes of categorizing the applicability of commands to local and remote file operations, URLs are divided into three types of URLs: local, ftp and tftp. The syntax for each of the URL types are listed in Table 26.

Table 26:  URL Types and Syntax  

URL Type

Syntax

Notes

local-url

[cflash-id:\]path

cflash-id is the compact flash device name.

Values: cf1:, cf2:, cf3:

ftp-url

ftp://[username[:password]@]host/path

An absolute ftp path from the root of the remote file system.

username is the ftp user name

password is the ftp user password

host is the remote host

path is the path to the directory or file

ftp://[username[:password]@]host/./path

A relative ftp path from the user’s home directory. Note the period and slash (“./”) in this syntax compared to the absolute path.

tftp-url

tftp://host[/path]/filename

tftp is only supported for operations on file-urls.

On the 7750 SR and 7950 XRS, if the host portion of the URL is an IPv6 address, then the address should be enclosed in square brackets. For example:

ftp://user:passw@[3ffe::97]/./testfile.txt

tftp://[2001:db8:3333:4444:5555:6666:7777:8888]/./testfile.txt

The system accepts either forward slash (/) or backslash (\) characters to delimit directory and/or filenames in URLs. Similarly, the SR OS SCP client application can use either slash or backslash characters, but not all SCP clients treat backslash characters as equivalent to slash characters. In particular, UNIX systems will often times interpret the backslash character as an escape character. This can cause problems when using an external SCP client application to send files to the SCP server. If the external system treats the backslash like an escape character, the backslash delimiter will get stripped by the parser and will not be transmitted to the SCP server.

For example, a destination directory specified as “cf1:\dir1\file1” will be transmitted to the SCP server as “cf1:dir1file1” where the backslash escape characters are stripped by the SCP client system before transmission. On systems where the client treats the backslash like an escape character, a double backslash (\\) or the forward slash (/) can typically be used to properly delimit directories and the filename.

3.1.3. Wildcards

The platform SR OS supports the standard DoS wildcard characters. The asterisk (*) can represent zero or more characters in a string of characters, and the question mark (?) can represent any one character.

Example:
A:ALA-1>file cf3:\ # copy test*.cfg
siliconvalleycf1:\testfile.cfg
1 file(s) copied.
A:ALA-1>file cf3:\ # cd siliconvalley
A:ALA-1>file cf3:\siliconvalley\ # dir
Volume in drive cf1 on slot A has no label.
Directory of cf3:\siliconvalley\
05/10/2006 11:32p <DIR> . 05/10/2006
11:14p <DIR> ..
05/10/2006 11:32p 7597 testfile.cfg
1 File(s) 7597 bytes.
2 Dir(s) 1082368 bytes free.
A:ALA-1>file cf3:\siliconvalley\ #

As in a DoS file system, the wildcard characters can only be used in some of the file commands.

Another example of wildcard usage:

A:21# show router mpls lsp l-63-8*
===============================================================================
MPLS LSPs (Originating)
===============================================================================
LSP Name                           To                  Fastfail     
Adm   Opr 
Config                 
-------------------------------------------------------------------------------
l-63-8-cc                          192.0.2.8           No           
Up    Dwn 
l-63-8-cw                          192.0.2.8           No           
Up    Dwn 
-------------------------------------------------------------------------------
LSPs : 2
===============================================================================
A:21#

All the commands can operate on the local file system. Table 27 indicates which commands also support remote file operations.

Table 27:  File Command Local and Remote File System Support 

Command

local-url

ftp-url

tftp-url

attrib

X

cd

X

X

copy

X

X

X

delete

X

X

dir

X

X

md

X

move

X

X

rd

X

repair

scp

source only

type

X

X

X

version

X

X

X

shutdown

3.2. File Management Tasks

The following sections are basic system tasks that can be performed.

Note that when a file system operation is performed with the copy, delete, move, rd, or scp commands that can potentially delete or overwrite a file system entry, a prompt appears to confirm the action. The force keyword performs the copy, delete, move, rd, and scp actions without displaying the confirmation prompt.

3.2.1. Modifying File Attributes

The system administrator can change the read-only attribute in the local file. Enter the attrib command with no options to display the contents of the directory and the file attributes.

Use the CLI syntax displayed below to modify file attributes:

CLI Syntax:
file>
attrib [+r | -r] file-url

The following shows an example of the command syntax:

Example:
# file
file cf3:\ # attrib
file cf3:\ # attrib +r BOF.SAV
file cf3:\ # attrib

The following example shows the file configuration:

     A:ALA-1>file cf3:\ # attrib
     cf3:\bootlog.txt
     cf3:\bof.cfg
     cf3:\boot.ldr
     cf3:\bootlog_prev.txt
     cf3:\BOF.SAV
A:ALA-1>file cf3:\ # attrib +r BOF.SAV
A:ALA-1>file cf3:\ # attrib
     cf3:\bootlog.txt 
     cf3:\bof.cfg
     cf3:\boot.ldr
     cf3:\bootlog_prev.txt
R    cf3:\BOF.SAV

3.2.2. Creating Directories

Use the md command to create a new directory in the local file system, one level at a time.

Enter the cd command to navigate to different directories.

Use the CLI syntax displayed below to modify file attributes:

CLI Syntax:
file>
md file-url

The following is an example of the command syntax:

Example:
file cf1:\ # md test1file cf1:\ # cd test1 file cf1:\test1\ # md test2 file cf1:\test1\ # cd test2 file cf1:\test1\test2\ # md test3 file cf1:\test1\test2\ # cd test3 file cf1:\test1\test2\test3 #

3.2.3. Copying Files

Use the copy command to upload or download an image file, configuration file, or other file types to or from a flash card or a TFTP server.

The scp command copies files between hosts on a network. It uses SSH for data transfer, and uses the same authentication and provides the same security as SSH.

The source file for the scp command must be local. The file must reside on the router. The destination file has to be of the format: user@host:file-name. The destination does not need to be local.

Use the CLI syntax displayed below to copy files:

CLI Syntax:
file>
copy source-file-url dest-file-url [force]
scp local-file-url destination-file-url [router router- name | service-id] [force]

The following displays an example of the copy command syntax:

Example:
A:ALA-1>file cf1:\ # copy 104.cfgcf1:\test1\test2\test3\test.cfg
Example:
A:ALA-1>file cf1:\ # scp file1 admin@192.168.0.1:cf1:\file1
Example:
A:ALA-1>file cf1:\ # scp file2 user2@192.168.0.1:/user2/file2
Example:
A:ALA-1>file cf1:\ # scp cf2:/file3 admin@192.168.0.1:cf1:\file3

3.2.4. Moving Files

Use the move command to move a file or directory from one location to another.

Use the CLI syntax displayed below to move files:

CLI Syntax:
file>
move old-file-url new-file-url [force]

The following displays an example of the command syntax:

Example:
A:ALA-1>file cf1:\test1\test2\test3\ # move test.cfg
cf1:\test1
cf1:\test1\test2\test3\test.cfg
A:ALA-1>file cf1:\test1\test2\test3\ # cd ..
A:ALA-1>file cf1:\test1\test2\ # cd ..
A:ALA-1>file cf1:\test1\ # dir
Directory of cf1:\test1\
    05/04/2006 07:58a      <DIR>          .
    05/04/2006 07:06a      <DIR>          ..
    05/04/2006 07:06a      <DIR>          test2
    05/04/2006 07:58a               25278 test.cfg
     1 File(s)                  25278 bytes.
     3 Dir(s)                 1056256 bytes free.
A:ALA-1>file cf1:\test1\ #

3.2.5. Deleting Files and Removing Directories

Use the delete and rd commands to delete files and remove directories. Directories can be removed even if they contain files and/or subdirectories. To remove a directory that contains files and/or subdirectories, use the rd rf command. When files or directories are deleted, they cannot be recovered.

The force option deletes the file or directory without prompting the user to confirm.

Use the CLI syntax displayed below to delete files and then remove directories:

CLI Syntax:
file#
delete file-url [force]
rd file-url [force]

The following displays an example of the command syntax:

A:ALA-1>file cf1:\test1\ # delete test.cfg
A:ALA-1>file cf1:\test1\ # delete abc.cfg
A:ALA-1>file cf1:\test1\test2\ # cd test3
A:ALA-1>file cf1:\test1\test2\test3\ # cd ..
A:ALA-1>file cf1:\test1\test2\ # rd test3
A:ALA-1>file cf1:\test1\test2\ # cd ..
A:ALA-1>file cf1:\test1\ # rd test2
A:ALA-1>file cf1:\test1\ # cd ..
A:ALA-1>file cf1:\ # rd test1
A:ALA-1>file cf1:\ #

Use the CLI syntax displayed below to remove a directory without first deleting files or subdirectories:

CLI Syntax:
file
rd file-url rf

3.2.6. Displaying Directory and File Information

Use the dir command to display a list of files on a file system. The type command displays the contents of a file. The version command displays the version of a *.tim or iom.tim file. (iom.tim file is used for the XCM on the 7950 XRS).

Use the CLI syntax displayed below to display directory and file information:

CLI Syntax:
file>
dir [file-url]
type file-url
version file-url

The following shows an example of the command syntax:

A:ALA-1>file cf1:\ # dir
 Volume in drive cf1 on slot A has no label.
Directory of cf1:\
01/01/1980  12:00a                7597 test.cfg
01/01/1980  12:00a                 957 b.
08/19/2001  02:14p              230110 BOOTROM.SYS
01/01/1980  12:00a                 133 NVRAM.DAT
04/03/2003  05:32a                1709 103.ndx
01/28/2003  05:06a                1341 103.cftg.ndx
01/28/2003  05:06a               20754 103.cftg
04/05/2003  02:20a      <DIR>          test
              15 File(s)                 338240 bytes.
               3 Dir(s)                 1097728 bytes free.
A:ALA-1>file cf1:\ # type fred.cfg
# Saved to /cflash1/fred.cfg
# Generated THU FEB 21 01:30:09 2002 UTC
exit all
config
#------------------------------------------
# Chassis Commands
#------------------------------------------
card 2 card-type faste-tx-32
exit
#------------------------------------------
# Interface Commands
#------------------------------------------
# Physical port configuration
interface faste 2/1
    shutdown
    mode network
exit
interface faste 2/2
    shutdown
exit
interface faste 2/3
    shutdown
exit
interface faste 2/4
A:ALA-1>file cf1:\ # version boot.tim
TiMOS-L-1.0.B3-8
A:ALA-1>file cf1:\ #

3.2.7. Repairing the File System

Use the repair command to check a compact flash device for errors and repair any errors found.

Use the CLI syntax displayed below to check and repair a compact flash device:

CLI Syntax:
file
repair [cflash-id]

The following example shows the command syntax:

A:ALA-1>file cf3:\ # repair 
Checking drive cf3: on slot A for errors...
Drive cf31: on slot A is OK.