04-File System Management Configuration
Chapters Download (159.13 KB)
Table of Contents
Displaying Directory Information
Displaying the Current Working Directory
Changing the Current Working Directory
Displaying the Contents of a File
Restoring a File from the Recycle Bin
Managing the Space of a Storage Medium
Displaying and Maintaining the NAND Flash Memory
Setting File System Prompt Modes
File System Operations Example
2 Configuration File Management
Format and Content of a Configuration File
Coexistence of Multiple Configuration Files
Startup with the Configuration File
Saving the Current Configuration
Modes in Saving the Configuration
Setting Configuration Rollback
Configuring Parameters for Saving the Current Running Configuration
Saving the Current Running Configuration Automatically
Saving the Current Running Configuration Manually
Setting Configuration Rollback
Specifying a Startup Configuration File for the Next System Startup
Backing Up the Startup Configuration File
Deleting the Startup Configuration File for the Next Startup
Restoring the Startup Configuration File
Displaying and Maintaining Device Configuration
When managing a file system, go to these sections for information you are interested in:
l Setting File System Prompt Modes
l File System Operations Example
A major function of the file system is to manage storage media. It allows you to perform operations such as directory create and delete, and file copy and display. If an operation, delete or overwrite for example, causes problems such as data loss or corruption, the file system will prompt you to confirm the operation by default.
File system operations fall into Directory Operations, File Operations, Batch Operations, Storage Medium Operations, and Setting File System Prompt Modes.
When you specify a file, you must enter the filename in one of the following formats.
Filename formats:
Format |
Description |
Length |
Example |
file-name |
Specifies a file under the current working directory. |
1 to 91 characters |
a.cfg indicates a file named a.cfg under the current working directory |
path/file-name |
Specifies a file in the specified folder under the current working directory. path indicates the name of the folder. You can specify multiple folders, indicating a file under a multi-level folder. |
1 to 135 characters |
test/a.cfg indicates a file named a.cfg in the test folder under the current working directory. |
drive:/[path]/file-name |
Specifies a file in the specified storage medium on the device. drive represents the storage medium name, which is usually flash or usb. |
1 to 135 characters |
flash:/test/a.cfg indicates a file named a.cfg in the test folder under the root directory of the flash memory. |
Directory operations include creating/removing a directory, displaying the current working directory, displaying the specified directory or file information, and so on.
To do… |
Use the command… |
Remarks |
Display directory or file information |
dir [ /all ] [ file-url ] |
Required Available in user view |
To do… |
Use the command… |
Remarks |
Display the current working directory |
pwd |
Required Available in user view |
To do… |
Use the command… |
Remarks |
Change the current working directory |
cd { directory | .. | / } |
Required Available in user view |
To do… |
Use the command… |
Remarks |
Create a directory |
mkdir directory |
Required Available in user view |
To do… |
Use the command… |
Remarks |
Remove a directory |
rmdir directory |
Required Available in user view |
l The directory to be removed must be empty, meaning that before you remove a directory, you must delete all the files and the subdirectory under this directory. For file deletion, refer to the delete command; for subdirectory deletion, refer to the rmdir command.
l After you execute the rmdir command successfully, the files in the recycle bin under the directory will be automatically deleted.
File operations include displaying the specified directory or file information; displaying file contents; renaming, copying, moving, removing, restoring, and deleting files.
You can create a file by copying, downloading or using the save command.
To do… |
Use the command… |
Remarks |
Display file or directory information |
dir [ /all ] [ file-url ] |
Required Available in user view |
To do… |
Use the command… |
Remarks |
Display the contents of a file |
more file-url |
Required Currently only a .txt file can be displayed. Available in user view |
To do… |
Use the command… |
Remarks |
Rename a file |
rename fileurl-source fileurl-dest |
Required Available in user view |
To do… |
Use the command… |
Remarks |
Copy a file |
copy fileurl-source fileurl-dest |
Required Available in user view |
To do… |
Use the command… |
Remarks |
Move a file |
move fileurl-source fileurl-dest |
Required Available in user view |
To do… |
Use the command… |
Remarks |
Move a file to the recycle bin or delete it permanently |
delete [ /unreserved ] file-url |
Required Available in user view |
l The files in the recycle bin still occupy storage space. To delete a file in the recycle bin, you need to execute the reset recycle-bin command in the directory that the file originally belongs. It is recommended to empty the recycle bin timely with the reset recycle-bin command to save storage space.
l The delete /unreserved file-url command deletes a file permanently and the action cannot be undone. Execution of this command equals that you execute the delete file-url command and then the reset recycle-bin command in the same directory.
To do… |
Use the command… |
Remarks |
Restore a file from the recycle bin |
undelete file-url |
Required Available in user view |
To do… |
Use the command… |
Remarks |
Enter the original working directory of the file to be deleted |
cd { directory | .. | / } |
Optional If the original directory of the file to be deleted is not the current working directory, this command is required. Available in user view |
Delete the file under the current directory and in the recycle bin |
reset recycle-bin [ /force ] |
Required Available in user view |
A batch file is a set of executable commands. Executing a batch file equals executing the commands in the batch file one by one.
The following steps are recommended to execute a batch file:
1) Edit the batch file on your PC.
2) Download the batch file to the device. If the suffix of the file is not .bat, use the rename command to change the suffix to .bat.
3) Execute the batch file.
Follow the steps below to execute a batch file:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Execute a batch file |
execute filename |
Required |
Execution of a batch file does not guarantee the successful execution of every command in the batch file. If a command has error settings or the conditions for executing the command are not satisfied, the system will skip the command to the next one.
When some space of a storage medium becomes inaccessible due to abnormal operations for example, you can use the fixdisk command to restore the space of the storage medium. The execution of the format command will format the storage medium, and all the data on the storage medium will be deleted.
Use the following commands to manage the storage medium space:
To do… |
Use the command… |
Remarks |
Restore the space of a storage medium |
fixdisk device |
Optional Available in user view |
Format a storage medium |
format device |
Optional Available in user view |
When you format a storage medium, all the files stored on it are erased and cannot be restored. In particular, if there is a startup configuration file on the storage medium, formatting the storage medium results in loss of the startup configuration file.
Featured with high storage capacity, low cost, and fast write speed, the NAND flash memory has become a preferred memory of new products. The physical space of the NAND flash memory is logically divided into multiple blocks, each of which is subdivided into multiple pages. The NAND flash memory is erased on a block basis and read on a page basis; the memory spaces are allocated on a page basis.
It is common to have bad blocks when an NAND flash memory is shipped from the factory. Bad block ratio varies with products of different vendors. The frequently used area of the memory goes bad easily. Bad blocks cannot be used to store data, and the file system has to skip the bad blocks when it allocates storage spaces to files. You can get the locations of bad blocks and repair them through command lines.
Follow these steps to display and repair bad blocks:
To do… |
Use the command… |
Remarks |
Display the number and location of bad blocks in the NAND flash memory |
display nandflash badblock-location |
Required Available in any view |
Repair bad blocks |
fixdisk device |
Required Available in user view |
After files are written to the NAND flash memory, you can use the following two commands together to check the content of these files.
Follow these steps to check files:
To do… |
Use the command… |
Remarks |
Display the space distribution of the specified file in the NAND flash memory |
display nandflash file-location filename |
Available in any view |
Display data on the specified physical page |
display nandflash page-data page-value |
The file system provides the following two prompt modes:
l alert: In this mode, the system warns you about operations that may bring undesirable consequences such as file corruption or data loss.
l quiet: In this mode, the system does not prompt confirmation for any operation.
To prevent undesirable consequence resulting from misoperations, the alert mode is preferred.
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Set the operation prompt mode of the file system |
file prompt { alert | quiet } |
Optional The default is alert. |
# Display the files and the subdirectories under the current directory.
<Sysname> dir
Directory of flash:/
0 drw- - Feb 16 2006 11:45:36 logfile
1 -rw- 1218 Feb 16 2006 11:46:19 config.cfg
2 drw- - Feb 16 2006 15:20:27 test
3 -rw- 184108 Feb 16 2006 15:30:20 aaa.bin
515712 KB total (2521 KB free)
# Create a new folder called mytest under the test directory.
<Sysname> cd test
<Sysname> mkdir mytest
%Created dir flash:/test/mytest.
# Display the current working directory.
<Sysname> pwd
flash:/test
# Display the files and the subdirectories under the test directory.
<Sysname> dir
Directory of flash:/test/
0 drw- - Feb 16 2006 15:28:14 mytest
515712 KB total (2519 KB free)
# Return to the upper directory.
<Sysname> cd ..
# Display the current working directory.
<Sysname> pwd
flash:
The device provides the configuration file management function with a user-friendly command line interface (CLI) for you to manage the configuration files conveniently.
This section covers these topics:
l Saving the Current Configuration
l Setting Configuration Rollback
l Specifying a Startup Configuration File for the Next System Startup
l Backing Up the Startup Configuration File
l Deleting the Startup Configuration File
l Restoring the Startup Configuration File
l Displaying and Maintaining Device Configuration
A configuration file saves the device configurations in command lines in text format. You can view configuration information conveniently through configuration files.
The configuration of a device falls into two types:
l Startup configuration, a configuration file used for initialization when the device boots. If this file does not exist, the system boots using null configuration, that is, using the default parameters.
l Current configuration, which refers to the currently running configuration of the system. The current configuration may include the startup configuration if the startup configuration is not modified during system operation, and it also includes the new configuration added during the system operation. The current configuration is stored in the temporary storage medium of the device, and will be removed when the device reboots if not saved.
A configuration file is saved as a text file. It is saved following these rules:
l The content of a configuration file is command lines, and only non-default configuration settings are saved.
l Commands in a configuration file are listed in sections by views, usually in the order of system view, interface view, routing protocol view, and user interface view. Sections are separated with one or multiple blank lines or comment lines that start with a pound sign #.
l Ends with a return.
Multiple configuration files can be stored on a storage medium of a device. You can save the configuration used in different environments as different configuration files. In this case, when the device moves between these networking environments, you just need to specify the corresponding configuration file as the startup configuration file for the next boot of the device and restart the device, so that the device can adapt to the network rapidly, saving the configuration workload.
A device boots using only one configuration file. However, you can specify two startup configuration files, main and backup startup configuration file, for the next startup of the device as needed. When the device boots, the system uses the main startup configuration file, and if the main startup configuration file is corrupted or lost, the system will use the backup startup configuration file for device boot and configuration. The devices supporting the configuration of the main and backup startup configuration files, compared with the devices that do not support this feature, are more secure and reliable.
At a moment, there are at most one main startup configuration file and one backup startup configuration file. You can specify neither of the two files (displayed as NULL), or specify the two files as the same configuration file.
You can specify the main and backup startup configuration files for the next boot of the device in the following two methods:
l Specify them when saving the current configuration. For detailed configuration, refer to Saving the Current Configuration.
l Specify them when specifying the startup configuration file for the next system startup. For detailed configuration, refer to Specifying a Startup Configuration File for the Next System Startup.
The device takes the following steps when it boots:
1) If you have specified a startup configuration file for system startup, and this file exists, the device will initialize its configuration based on this file.
2) If the specified startup configuration file does not exist, the device will boot with null configuration.
You can modify the current configuration on your device using command line interface. However, the current configuration is temporary. To make the modified configuration take effect at the next boot of the device, you must save the current configuration to the startup configuration file before the device reboots.
l Fast saving mode. This is the mode when you use the save command without the safely keyword. The mode saves the file more quickly but is likely to lose the existing configuration file if the device reboots or the power fails during the process.
l Safe mode. This is the mode when you use the save command with the safely keyword. The mode saves the file more slowly but can retain the configuration file in the device even if the device reboots or the power fails during the process.
The fast saving mode is suitable for environments where power supply is stable. The safe mode, however, is preferred in environments where stable power supply is unavailable or remote maintenance is involved.
Follow the steps below to save the current configuration:
To do… |
Use the command… |
Remarks |
Save the current configuration to the specified file, but the configuration file will not be set as the file for the next startup |
save file-url |
Required Use either command Available in any view. |
Save the current configuration to the root directory of the storage medium and specify the file as the startup configuration file that will be used at the next system startup |
save [ safely ] [ backup | main ] |
l The configuration file must be with extension .cfg.
l For the device that supports the main keyword, the execution of the save [ safely ] and save [ safely ] main commands has the same effect: The system will save the current configuration and specify the configuration file as the main startup configuration file to be used at the next system startup.
l During the execution of the save [ safely ] [ backup | main ] command, the startup configuration file to be used at the next system startup may be lost if the device reboots or the power supply fails. In this case, the device will boot with the null configuration, and after the device reboots, you need to re-specify a startup configuration file for the next system startup (refer to Specifying a Startup Configuration File for the Next System Startup).
Configuration rollback allows you to revert to a previous configuration state based on a specified configuration file. The specified configuration file must be a valid .cfg file, namely, it can be generated by using either the backup function (manually or automatically) or the save command, and even the compatible configuration file of another device. You are recommended to use the configuration file that is generated by using the backup function (manually or automatically). Configuration rollback is applied in the following situations:
l The current configurations are wrong; and there are too many wrong configurations to locate or to correct one by one. Rolling back the current configuration to a correct one is needed.
l The application environment has changed and the device has to run in a configuration state based on a previous configuration file without being rebooted.
Set configuration rollback following these steps:
1) Specify the filename prefix and path for saving the current configuration.
2) Save the current running configuration with the specified filename (filename prefix + serial number) to the specified path. The current running configuration can be saved in two ways: the system saves the current running configuration at a specified interval; or you can save the current running configuration as needed.
3) Roll back the current running configuration to the configuration state based on a saved configuration file. When the related command is entered, the system first compares and then processes the differences between the current running configuration and the specified replacement configuration file:
l The rollback operation does not execute the commands that are the same in the replacement configuration file and in the current configuration file.
l The rollback operation removes the commands only present in the current configuration file but not in the replacement configuration file; namely, the corresponding undo form commands are executed.
l The rollback operation executes the commands only present in the replacement configuration file but not in the current configuration file.
l The rollback operation removes the commands that are different in the replacement configuration file and in the current configuration file, and then executes them according to the replacement configuration file.
Complete these tasks to configure the configuration rollback:
Task |
Remarks |
Configuring Parameters for Saving the Current Running Configuration |
Required |
Required Use either approach |
|
Required |
Before the current running configuration is saved manually or automatically, the file path and filename prefix must be configured. After that, the system saves the current running configuration with the specified filename (filename prefix_serial number.cfg) to the specified path. The filename of a saved configuration file is like 20080620archive_1.cfg, or 20080620archive_2.cfg. The saved configuration files are numbered automatically, from 1 to 1,000 (with increment of 1). If the serial number reaches 1,000, it restarts from 1. If you change the path or filename prefix, or reboot the device, the saved file serial number restarts from 1, and the system recounts the saved configuration files. If you change the path of the saved configuration files, the files in the original path become common configuration files, and are not processed as saved configuration files.
The number of saved configuration files has an upper limit. After the maximum number of files is saved, the system deletes the oldest files when the next configuration file is saved.
Follow these steps to configure parameters for saving the current running configuration:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Configure the path and filename prefix of a saved configuration file |
archive configuration location directory filename-prefix filename-prefix |
Required By default, the path and filename of the saved configuration file are not configured, and the system does not save the configuration file at a specified interval. |
Set the maximum number of configuration files that can be saved |
archive configuration max file-number |
Optional The default number is 5. |
l If the undo archive configuration location command is executed, the current running configuration can neither be saved manually nor automatically, and the configuration by executing the archive configuration interval and archive configuration max commands restores to the default, meanwhile, the saved configuration files are cleared.
l The value of the file-number argument is determined by the memory space. You are recommended to set a comparatively small value for the file-number argument if the available memory space is small.
You can configure the system to save the current running configuration at a specified interval, and use the display archive configuration command to view the filenames and save time of the saved configuration files, so as to roll back the current configuration to a previous configuration state.
Configure an automatic saving interval according to the storage medium performance and the frequency of configuration modification:
l If the configuration of the device does not change frequently, you are recommended to save the current running configuration manually as needed
l Because the S5810 uses a low-speed storage medium, you are recommended either to save the current running configuration manually, or to configure automatic saving with an interval longer than 1,440 minutes (24 hours).
Follow these steps to automatically save the current running configuration:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Enable the automatic saving of the current running configuration, and set the interval |
archive configuration interval minutes |
Optional Disabled by default |
The path and filename prefix of a saved configuration file must be specified before you configure the automatic saving period.
Automatic saving of the current running configuration occupies system resources, and frequent saving greatly affects system performance. Therefore, if the system configuration does not change frequently, you are recommended to disable the automatic saving of the current running configuration and save it manually.
If the modification to the configuration fails, or is complicated, you can save the current running configuration manually before you modify it. Therefore, if it really fails, the device can revert to the configuration state before the modification.
Follow the step below to save the current running configuration manually:
To do… |
Use the command… |
Remarks |
Save the current running configuration manually |
archive configuration |
Required Available in user view |
The path and filename prefix of a saved configuration file must be specified before you save the current running configuration manually; otherwise, the operation fails.
Follow these steps to set configuration rollback:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Set configuration rollback |
configuration replace file filename |
Required |
Do not unplug and plug a card during configuration rollback (that is, the system is executing the configuration replace file command). In addition, configuration rollback may fail if one of the following situations is present (if a command cannot be rolled back, the system skips it and processes the next one):
l The complete undo form of a command is not supported, namely, you cannot get the actual undo form of the command by simply putting the keyword undo in front of the command, so the complete undo form of the command cannot be recognized by the device.
l The configuration cannot be removed, such as hardware-related commands
l Commands in different views are dependent on each other
l If the replacement configuration file is not a complete file generated by using the save or archive configuration command, or the file is copied from a different type of device, the configuration cannot be rolled back. Ensure that the replacement configuration file is correct and compatible with the current device.
A startup configuration file is the configuration file to be used at the next system startup. You can specify a configuration file as the startup configuration file to be used at the next system startup in the following two ways:
l Use the save command. If you save the current configuration to the specified configuration file in the interactive mode, the system automatically sets the file as the configuration file to be used at the main next system startup.
l Use the command dedicated to specify a startup configuration file, which is described in the following table:
Follow the step below to specify a configuration file as the startup configuration file for the next system startup:
To do… |
Use the command… |
Remarks |
Specify a startup configuration file for the next system startup |
startup saved-configuration cfgfile [ backup | main ] |
Required Available in user view |
A configuration file must use .cfg as its extension name and the startup configuration file must be saved under the root directory of the storage medium.
The backup function allows you to copy the startup configuration file to be used at the next system startup from the device to the TFTP server for backup.
The backup operation backs up the startup configuration file to the TFTP server for startup configuration file.
Follow the step below to back up the startup configuration file to be used at the next system startup:
To do… |
Use the command… |
Remarks |
Back up the configuration file to be used at the next system startup to the specified TFTP server |
backup startup-configuration to dest-addr [dest- filename ] |
Required Available in user view |
Before the backup operation, you should:
l Ensure that the server is reachable, the server is enabled with TFTP service, and the client has permission to read and write.
l Use the display startup command (in user view) to see whether you have set the startup configuration file, and use the dir command to see whether this file exists. If the file is set as NULL or does not exist, the backup operation will fail.
You can delete the startup configuration file to be used at the next system startup using commands. On a device that has the main and backup startup configuration files, you can choose to delete either the main or backup startup configuration file. However, in the case that the main and backup startup configuration files are the same, if you perform the delete operation for once, the system will not delete the configuration file but only set the corresponding startup configuration file (main or backup, according to which one you specified in the command) to NULL.
You may need to delete the startup configuration file for the next startup for one of these reasons:
l After you upgrade system software, the existing configuration file does not match the new system software.
l The configuration file is corrupted (often caused by loading a wrong configuration file).
After the startup configuration file is deleted, the system will use the null configuration when the device reboots.
Follow the step below to delete the startup configuration file for the next startup:
To do… |
Use the command… |
Remarks |
Delete the startup configuration file for the next startup from the storage medium |
reset saved-configuration [ backup | main ] |
Required Available in user view |
This command will permanently delete the configuration file from the device. Use it with caution.
The restore function allows you to copy a configuration file from a TFTP server to the device and specify the file as the startup configuration file to be used at the next system startup.
Follow the step below to restore the startup configuration file to be used at the next system startup:
To do… |
Use the command… |
Remarks |
Restore the startup configuration file to be used at the next system startup |
restore startup-configuration from src-addr src-filename |
Required Available in user view |
l The restore operation restores the main startup configuration file.
l Before restoring a configuration file, you should ensure that the server is reachable, the server is enabled with TFTP service, and the client has read and write permission.
l After the command is successfully executed, you can use the display startup command (in user view) to verify that the filename of the configuration file to be used at the next system startup is the same with that specified by the filename argument, and use the dir command to verify that the restored startup configuration file exists.
To do… |
Use the command… |
Remarks |
Display the information about configuration rollback |
display archive configuration |
Available in any view |
Display the currently running configuration file saved on the storage medium of the device |
display saved-configuration [ by-linenum ] |
Available in any view |
Display the configuration files for this and the next system startup |
display startup |
Available in any view |
Display the validated configuration in current view |
display this [ by-linenum ] |
Available in any view |
Display the current configuration |
display current-configuration [ [ configuration [ configuration ] | interface [ interface-type ] [ interface-number ] ] [ by-linenum ] [ | { begin | include | exclude } text ] ] |
Available in any view |