24-File System Management Operation

Download


Chapter 1  File System Management

1.1  File Attribute Configuration

1.1.1  Introduction to File Attributes

An app file is an executable file, with bin as the extension. A configuration file is used to store and restore configuration, with cfg as the extension. A Web file is used for Web-based network management, with web as the extension.

An app file, a configuration file, or a Web file can be of one of these three attributes: main, backup and none, as described in Table 1-1.

Table 1-1 Descriptions on file attributes

Attribute name

Description

Feature

Identifier

main

The main attribute identifies main startup files. The main startup file is used first for a switch to startup.

In the Flash, there can be only one app file, one configuration file and one Web file with main attribute.

(*)

backup

The backup attribute identifies backup startup files. The backup startup file is used after a switch fails to startup using the main startup file.

In the Flash, there can be only one app file, one configuration file and one Web file with the backup attribute.

(b)

none

Files that are neither of main attribute nor backup attribute are of none attribute.

None

 

&  Note:

A file can have both the main and backup attributes. Files of this kind are labeled as *b.

 

If a newly created file is configured to be of the main attribute, the existing file in the Flash that is of the same attribute loses its attribute. This ensures that there can be only one app file, one configuration file and one Web file with the main attribute in the Flash memory. It is the same with the files in the Flash memory that are of the backup attribute.

File operations and file attribute operations are independent of each other. For example, if you delete a file with the main attribute from the Flash memory, the main attribute is not deleted. It becomes the attribute of a valid file that is later downloaded to the Flash memory and has the same name as the previously deleted one.

After the BootROM of a switch is upgraded, the previous default app startup file will have the main attribute.

1.1.2  Configuring File Attributes

You can configure and view the main attribute and backup attribute of the files used for the next startup of a switch, and switch the main and backup attribute of the files.

Perform the configuration listed in Table 1-2 in user view. The display commands can be executed in any view.

Table 1-2 Configure file attributes

Operation

Command

Description

Configure the app file with the main attribute for the next startup

boot boot-loader file-url

Optional

Configure the app file with the backup attribute for the next startup

boot boot-loader backup-attribute file-url

Optional

Configure the Web file and it attribute (main or backup)

boot web-package webfile { backup | main}

Optional

Configure the name and attribute (main or backup) of the configuration file for the next startup

startup saved-configuration cfgfile [ backup | main ]

Optional

By default, a configuration file is of the main attribute.

Configure the system to start without loading the configuration file

undo startup saved-configuration [ unit unit-id ]

Optional

Switch the file attributes between main and backup for files that are of specific attribute

boot attribute-switch { all | app | configuration | web }

Optional

Specify to prompt for the customized password before entering the BOOT menu

startup bootrom-access enable

Optional

By default, a user cannot access the BOOT menu with a customized password.

Display the information about the app file used as the startup file

display boot-loader [ unit unit-id ]

The two commands can be executed in any view.

Display the information about the startup configuration file

display startup [ unit unit-id ]

 

  Caution:

l      Before configuring the main or backup attribute for a file, make sure the file already exists. For example, to configure the main or backup attribute for a Web file, you need to make sure the file exists on the switch.

l      The configuration of the main or backup attribute of a Web file takes effect immediately without restarting the switch.

l      Currently, a configuration file has the extension of cfg and resides in the root directory of a switch.

 

1.2  File System Configuration

1.2.1  Introduction to Configuration File Management

The configuration file management module provides a friendly user interface. It stores user configurations in the form of command line text. It also enables users to check switch configurations easily.

Upon powered on, a switch loads the configuration file known as saved-configuration file, which resides in the Flash, for initialization. If the Flash contains no configuration file, the system initializes using the default parameters. Comparing to saved-configuration file, the configuration file which is currently adopted by a switch is known as the current-configuration.

A configuration file conforms to the following conventions:

l           The content of a configuration files is a series of commands.

l           Only the non-default configuration parameters are saved.

l           The commands are grouped into sections by command view. The commands that are of the same command view are grouped into one section. Sections are separated by empty lines or comment lines. (A line is a comment line if it starts with the character “#”.)

l           The sections are listed in this order: system configuration section, physical port configuration section, logical interface configuration section, routing protocol configuration section, and so on.

l           A configuration file ends with a “return”.

1.2.2  Introduction to File System

To facilitate management on the Flash memory, Ethernet switches provide the file system module. The file system allows users to access and manage files and directories through creating/deleting a directory, displaying the current work directory, and displaying the contents of a directory.

By default, a switch prompts for confirmation before executing the commands which have potential risks (for example, deleting and overwriting files).

1.2.3  Introduction to Operation and Configuration Tasks on the File System

Table 1-3 Operation and configuration tasks on the file system

Configuration task

Description

Related section

Directory operation

Optional

Section 1.2.4  Directory Operations

File operation

Optional

Section 1.2.5  File Operations

Flash operation

Optional

Section 1.2.6  Flash Operations

Prompt mode configuration

Optional

Section 1.2.7  Prompt Mode Configuration

 

1.2.4  Directory Operations

The file system provides directory-related functions, such as:

l           Creating/deleting a directory

l           Displaying the information about the files or the directories in the current work directory or a specified directory

Table 1-4 describes the directory-related operations.

Perform the following configuration in user view.

Table 1-4 Directory operations

Operation

Command

Description

Create a directory

mkdir directory

Optional

Delete a directory

rmdir directory

Optional

Only empty directories can be deleted.

Display the current work directory

Pwd

Optional

Display the information about specific directories and files

dir [ /all ] [ file-url ]

Optional

Enter a specified directory

cd directory

Optional

The default directory is the root directory of the Flash.

 

&  Note:

In the output information of the dir /all command, deleted files (that is, those in the recycle bin) are embraced in brackets.

 

1.2.5  File Operations

The file system also provides file-related functions, such as:

l           Deleting a file

l           Restoring a deleted file

l           Deleting a file completely

l           Managing a configuration file

l           Renaming a file

l           Copying a file

l           Moving a file

l           Displaying the content of a file

l           Displaying the information about a file

l           Checking file system

Table 1-5 describes the file-related operations.

Perform the following configuration in user view. Note that the execute command should be executed in system view, and the display command can be executed in any view.

Table 1-5 File operations

Operation

Command

Description

Delete a file

delete [ /unreserved ] file-url

delete { running-files | standby-files } [ /unreserved ]

Optional

A deleted file can be restored if you delete it by executing the delete command with the /unreserved keyword not specified. You can use the undelete command to restore a deleted file of this kind.

Restore a deleted file

undelete file-url

Optional

Delete a file in the recycle bin

reset recycle-bin [ file-url ] [ /force ]

Optional

Delete a configuration file in the Flash

reset saved-configuration [ backup | main ]

Optional

Save the current configuration to a specified configuration file and specify the configuration file to be of the main or backup attribute

save [ cfgfile | [safely ] [ backup | main ] ]

Optional

This command can be executed in any view.

Rename a file

rename fileurl-source fileurl-dest

Optional

Copy a file

copy fileurl-source fileurl-dest

Optional

Move a file

move fileurl-source fileurl-dest

Optional

Display the content of a file

more file-url

Optional

Currently, the file system only supports displaying the contents of a file in texts.

Display the information about a directory or a file

dir [ /all ] [ file-url ]

Optional

Execute the specified batch process file

execute filename

Optional

This command should be executed in system view.

Display the startup configuration of a switch

display saved-configuration [ unit unit-id ] [ by-linenum ]

Optional

These commands can be executed in any view.

Display the current configuration of a switch

display current-configuration [ configuration [ configuration-type ] | interface [ interface-type ] [ interface-number ] | vlan [ vlan-id ] ] [ by-linenum [ | { begin | include | exclude } regular-expression ]

Display the information about the configuration file with which a switch starts

display startup [ unit unit-id ]

Display the operating configuration of the current view

display this [ by-linenum ]

 

  Caution:

l      For deleted files whose names are the same, only the latest deleted file can be restored.

l      The files which are deleted using the delete command with the /unreserved keyword not specified are actually moved to the recycle bin and thus still take storage space. You can clear the recycle bin to make room for other files by using the reset recycle-bin command.

l      The dir /all command displays files in the recycle bin in square brackets.

l      If the configuration files are deleted, the switch adopts the default configuration parameters when it starts the next time.

 

You can consider clearing the configuration files in the Flash when:

l           The configuration files in the Flash are not compatible with the system software. (This may occur after you upgrade the system software of the switch.)

l           The configuration files are corrupted. (This is usually because a wrong configuration file is loaded.)

As for the save command listed in Table 1-5, the safely keyword determines the ways to save the current configuration, as described in the following.

l           If you execute this command with the safely keyword not specified, the system saves the current configuration in the fast mode. In this mode, the configuration gets lost if the switch restarts or is powered off when the saving operation is being processed.

l           If you execute this command with the safely keyword specified, the system saves the current configuration in the safe mode. Although this mode takes more time than the fast mode, the configuration can be saved to the Flash even if the switch restarts or is powered off when the saving operation is being processed.

The fast mode is recommended under the circumstances where the power systems are reliable, while the safe mode is recommended when power system is unreliable or you are performing a remote maintenance operation.

 

&  Note:

l      If you execute the save command with the cfgfile argument not specified, the current configuration is saved in the configuration file with which the switch latest starts. If the switch starts using the default configuration, the current configuration is saved in the default configuration file.

l      To make a switch to adopt the current configuration when it starts the next time, save the current configuration using the save command before restarting the switch.

 

1.2.6  Flash Operations

You can operate the Flash memory as listed in Table 1-6.

Table 1-6 Operations on storage device

Operation

Command

Description

Format the storage device

format device

Required

Restore space on the Flash memory

fixdisk device

Required

 

The format operation leads to the loss of all files, including the configuration files, on the Flash memory and is irretrievable.

 

1.2.7  Prompt Mode Configuration

You can set the prompt mode of the current file system to alert or quiet. In alert mode, the file system will give a prompt for confirmation if a potentially dangerous command is executed to delete/cover a file and so on. In quiet mode, such prompt will not be displayed.

Table 1-7 Configuration on prompt mode of file system

Operation

Command

Description

Enter system view

system-view

Configure the prompt mode of the file system

file prompt { alert | quiet }

Required

By default, the prompt mode of the file system is alert.

 

1.2.8  Configuration Example

# Display all the files in the root directory of the file system on the local unit.

<H3C> dir /all

Directory of unit1>flash:/

   1 (*)   -rw-   3840337  Jul 31 2005 15:15:48   abc.bin

   2       -rwh         4  Apr 01 2000 23:55:27   snmpboots

   3       -rwh       151  Apr 01 2000 23:58:05   private-data.txt

4       drw-         -  Apr 02 2000 01:30:14   test

   5       -rw-       981  Apr 02 2000 00:01:52   config.cfg

   6       -rw-         0  Apr 01 2000 23:57:31   taskswitch.log

7239 KB total (3481 KB free)

(*) -with main attribute   (b) -with backup attribute

(*b) -with both main and backup attribute

# Copy the file flash:/config.cfg to flash:/test/, with 1.cfg as the name of the new file.

<H3C>copy flash:/config.cfg flash:/test/1.cfg

Copy unit1>flash:/config.cfg to unit1>flash:/test/1.cfg?[Y/N]:y

..

%Copy file unit1>flash:/config.cfg to unit1>flash:/test/1.cfg...Done.

# Display the file information after the copy operation.

<H3C>dir /all

Directory of unit1>flash:/

   1 (*)   -rw-   3840337  Jul 31 2005 15:15:48   abc.bin

   2       -rwh         4  Apr 01 2000 23:55:27   snmpboots

   3       -rwh       151  Apr 01 2000 23:58:05   private-data.txt

   4       -rw-       981  Apr 02 2000 00:01:52   config.cfg

   5       drw-         -  Apr 02 2000 01:30:14   test

   6       -rw-         0  Apr 01 2000 23:57:31   taskswitch.log

7239 KB total (3480 KB free)

(*) -with main attribute   (b) -with backup attribute

(*b) -with both main and backup attribute

<H3C>dir flash:/test

Directory of unit1>flash:/

   1       drw-         -  Apr 02 2000 01:30:14   test

7239 KB total (3480 KB free)

(*) -with main attribute   (b) -with backup attribute

(*b) -with both main and backup attribute