- Table of Contents
-
- 01-Fundamentals Configuration Guide
- 00-Preface
- 01-CLI Configuration
- 02-Login Management Configuration
- 03-FTP and TFTP Configuration
- 04-File System Management
- 05-Configuration File Management Configuration
- 06-Software Upgrade Configuration
- 07-ISSU Configuration
- 08-Device Management Configuration
- 09-Automatic Configuration
- 10-Management with BootWare
- Related Documents
-
Title | Size | Download |
---|---|---|
04-File System Management | 118.87 KB |
Contents
Displaying the contents of a file
Computing the digest of a file
Displaying directory information
Displaying the current working directory
Changing the current working directory
Mounting/unmounting a storage medium
Setting the file system operation mode
File and directory management examples
Managing the file system
This chapter describes how to manage the file system of your switch, including the storage media, directories, and files.
Supported storage media
The switch supports the following storage media:
· Flash memory built in an MPU.
· USB disk connected to the USB port of an MPU.
· CF card inserted in the CF card slot of an MPU.
These storage media support FAT 16 and FAT 32 file systems.
The CF card and USB disk are hot-swappable.
An MPU has two USB ports, but only the upper one can be used.
H3C recommends that you use a Kingston 1-GB USB disk. The device does not support non-standard USB devices, such as removable hard disks, USB hubs, MP3, and MP4.
Storage medium naming rules
The name of a storage medium follows the following rules:
· If a storage medium is the only storage medium of its type on the device, it is named by its type. For example, if the device has only one Flash, the name of the Flash is flash.
· If there are multiple storage media of the same type on the switch, the physical device name of a storage medium on the active MPU is the medium type name (for example, flash or cfa0), and the physical device name of a storage medium on the standby MPU comprises the slot number and the medium type (for example, slot1#flash or slot1#cfa0). If the switch is operating in IRF mode, the physical device name of any other storage medium comprises the chassis number, slot number, and the medium type (for example, chassis1#slot1#flash or chassis1#slot1#cfa0).
· If a storage medium is partitioned, the name of a partition comprises the physical device name and the partition number. The sequence numbers of partitions are displayed in numbers such as 0, 1 and 2, for example cfa0.
File name formats
When you specify a file name, enter the file name in one of the formats shown in Table 1. When you specify a directory name, follow the rules for the drive and path arguments.
Format |
Description |
Length |
Example |
file-name |
Specifies a file in the current working directory. |
1 to 91 characters |
a.cfg indicates a file named a.cfg in the current working directory. If the current working directory is on the active MPU, a.cfg represents file a.cfg on the active MPU; if the current working directory is on the standby MPU, a.cfg represents file a.cfg on the standby MPU. |
path/file-name |
Specifies a file in the specified folder in the current working directory. path represents the folder name. 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 in the current working directory. |
drive:/[path]/file-name (standalone mode) |
Specifies a file in the specified storage medium on the switch. drive represents the storage medium name. The storage medium on the active MPU is usually flash or cf; the storage medium on the standby MPU is usually slotX#flash or slotX#cf, where X represents the number of the slot where the standby MPU resides. For example, slot1#flash. You can use the display device command to view the correspondence between a board and its slot number. |
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 on the active MPU. To read and write the a.cfg file under the root directory of the flash on the standby MPU (with the slot number 1), enter slot1#flash:/a.cfg for the filename. |
drive:/[path]/file-name (IRF mode) |
Specifies a file in the specified storage medium on the switch. drive represents the storage medium name. The storage medium on the active MPU of the master is usually flash or cf; the storage medium on a subordinate switch is usually chassisX#slotY#flash or chassisX#slotY#cf, where X represents the member ID of the subordinate switch and Y represents the number of the slot where the MPU of the subordinate switch resides. You can use the display device command to view the correspondence between a switch and its member ID. |
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 on the active MPU of the IRF. To read and write the a.cfg file under the root directory of the Flash on the standby MPU that resides in slot 0 of member device 1, enter chassis1#slot0#flash:/a.cfg for the filename. |
Managing files
You can display directory or file information; display file contents; rename, copy, move, remove, restore, and delete files.
The copy operation enables you to create a file. You can also create a file by performing the download operation or using the save command.
Displaying file information
Perform this task in user view.
Task |
Command |
Display file or directory information. |
dir [ /all ] [ file-url | /all-filesystems ] |
Displaying the contents of a file
Perform this task in user view.
Task |
Command |
Remarks |
Display the contents of a file. |
more file-url [ | { begin | exclude | include } regular-expression ] |
Only a .txt file can be displayed. |
Renaming a file
Perform this task in user view.
Task |
Command |
Rename a file. |
rename fileurl-source fileurl-dest |
Copying a file
Perform this task in user view.
Task |
Command |
Copy a file. |
copy fileurl-source fileurl-dest |
Moving a file
Perform this task in user view.
Task |
Command |
Move a file. |
move fileurl-source fileurl-dest |
Deleting/restoring a file
You can delete a file permanently or just move it to the recycle bin. A file moved to the recycle bin can be restored, but a permanently deleted file cannot.
A file in the recycle bin occupies storage space. To release the occupied space, execute the reset recycle-bin command in the directory that holds the file. To save storage space, periodically empty the recycle bin with the reset recycle-bin command.
Perform this task in user view:
Task |
Command |
Delete a file by moving it to the recycle bin. |
delete file-url |
Restore a file from the recycle bin. |
undelete file-url |
Delete a file permanently. |
delete /unreserved file-url |
Task |
Command |
Move a file to the recycle bin or delete it permanently. |
delete [ /unreserved ] file-url |
Emptying the recycle bin
Step |
Command |
Remarks |
1. Enter the original working directory of the file to be deleted. |
cd { directory | .. | / } |
Skip this step if the original directory of the file is the current working directory. Available in user view. |
2. Empty the recycle bin. |
reset recycle-bin [ /force ] |
Available in user view. |
Computing the digest of a file
The digest of a file can be used to verify the integrity of the file. For example, you can compute the digest of the software image file of a device, and compare the digest with that on the website of the device vendor to verify whether the file is valid.
To compute the digest of a file, perform the following command in user view:
Task |
Command |
Compute the digest of a file. |
crypto-digest sha256 file file-url |
Managing directories
You can create or remove a directory, and display the current working directory, the specified directory, and file information.
Displaying directory information
Perform this task in user view.
Task |
Command |
Display directory or file information. |
dir [ /all ] [ file-url | /all-filesystems ] |
Displaying the current working directory
Perform this task in user view.
Task |
Command |
Display the current working directory. |
pwd |
Changing the current working directory
Perform this task in user view.
Task |
Command |
Change the current working directory. |
cd { directory | .. | / } |
Creating a directory
Perform this task in user view.
Task |
Command |
Create a directory. |
mkdir directory |
Removing a directory
To remove a directory, you must delete all the files and the subdirectory in this directory. To delete a file, use the delete command; to delete a subdirectory, use the rmdir command.
The rmdir command automatically deletes the files in the recycle bin in the current directory.
Perform this task in user view.
Task |
Command |
Remove a directory. |
rmdir directory |
Managing storage media
Storage media management includes space assignment, storage media mounting and unmounting, and space partitioning.
Managing the storage space
If part of a storage medium is inaccessible, use the fixdisk command to examine the medium for any damage and repair the medium.
To format a storage medium that has been partitioned, you must format all the partitions individually, instead of formatting the medium as a whole.
|
CAUTION: · After a storage medium is formatted, all the files on it are erased and cannot be restored. If a startup configuration file exists on the storage medium, formatting the storage medium results in loss of the startup configuration file. · H3C recommends that you use the default format for the storage medium after the medium is partitioned. Changing the format might result in lower read and write efficiency. |
To manage the space of a storage medium, perform one of the following tasks in user view:
Task |
Command |
Remarks |
Restore the space of a storage medium. |
fixdisk device |
N/A |
Format a storage medium. |
format device [ FAT16 | FAT32 ] |
FAT16 and FAT32 are not applicable to a Flash. |
Mounting/unmounting a storage medium
You can mount or unmount a hot-swappable storage medium (excluding Flash), such as a CF card.
By default, a storage medium is automatically mounted when connected to the device. However, when a storage medium is connected to a lower version system, the system cannot recognize the storage medium. To perform read and write operations to the storage medium, you must mount it.
An unmounted device is in disconnected state, and can be removed safely. If you remove a storage medium without unmounting it, files on the storage medium or even the storage medium might be damaged.
An unmounted storage medium can be used only when it is mounted again.
Restrictions and guidelines
|
CAUTION: To avoid file system corruption, do not install or remove storage media or perform active/standby switchover while the system is mounting or unmounting the storage media. |
Before removing a mounted storage medium from the system, unmount it to avoid damaging the storage medium.
To mount/unmount a storage medium, you must mount/unmount all the partitions individually, instead of mounting/unmounting the medium as a whole.
Before you remove a USB disk, complete these tasks:
· Make sure the system has recognized the USB disk and the USB disk LED is not blinking.
· Use the umount command to unmount it.
Configuration procedure
Perform one of the following tasks in user view as appropriate:
To mount or unmount a storage medium:
Task |
Command |
Remarks |
Mount a storage medium. |
mount device |
By default, a storage medium is automatically mounted and in mounted state when connected to the system. |
Unmount a storage medium. |
umount device |
By default, a storage medium is automatically mounted and in mounted state when connected to the system. |
Enabling/disabling USB ports
Step |
Command |
Remarks |
1. Enter system view. |
system-view |
N/A |
2. Enable or disable all USB ports. |
·
Disable
all USB ports: ·
Enable all USB ports: |
By default, all USB ports are enabled. |
Partitioning a storage medium
A CF card or a USB disk can be divided into several different logical devices called "partitions." Operations on a partition do not affect the other partitions.
The following partitioning modes are available for CF cards and USB disks:
· Simple—Specify the number of partitions. The system divides the storage medium into the specified number of partitions with the same size.
· Interactive—The system partitions the storage medium according to user input. Each partition must be 32 MB at least.
Restrictions and guidelines
It is normal that the configured partition size and the actual partition size have an error less than 5% of the total memory.
Before you partition a CF card or USB disk:
· Back up the files in the storage medium. The partition operation clears all data in the medium.
· If you are partitioning a USB disk, make sure the disk is not write protected. Otherwise, the partition operation will fail, and you must remount or re-install the disk to restore access to the USB disk.
H3C recommends that the first partition be equal to or larger than 128 MB.
After you partition a CF card or USB disk:
· Reconfigure paths of application files to include the correct partition information.
· If the device starts up from the CF card, save the startup system software image file and the configuration file in the first partition of the CF card.
· To guarantee the startup system software image and configuration files sufficient storage space, set the path for log files to a partition other than the first partition. By default, the system automatically saves log files to the second partition. If the path does not exist, use the info-center logfile switch-directory command to change the path to avoid log loss. For more information about this command, see Network Management and Monitoring Command Reference.
· To avoid file system corruption, unmount all the partitions before removing a storage medium.
Configuration procedure
Perform this task in user view.
Task |
Command |
Remarks |
Partition a storage medium. |
fdisk device [ partition-number ] |
By default, a CF card has two partitions, cfa0:/ and cfa1:/. |
Performing batch operations
A batch file comprises a set of executable commands. Executing a batch file is the same as executing the commands one by one. However, execution of a batch file does not guarantee successful execution of every command in the batch file. If a command has error settings or the conditions for executing the command are not met, the system skips this command.
You can edit a batch file on your PC, and then download or upload it to the device. If the suffix of the file is not .bat, use the rename command to change the suffix to .bat.
To execute a batch file:
Step |
Command |
1. Enter system view. |
system-view |
2. Execute a batch file. |
execute filename |
Setting the file system operation mode
The device supports the following file system operation modes:
· alert—The system prompts for confirmation when your operation might cause problems such as file corruption and data loss. This mode provides an opportunity to cancel a disruptive operation.
· quiet—The system does not prompt for confirmation.
To set the file system operation mode:
Step |
Command |
Remarks |
1. Enter system view. |
system-view |
N/A |
2. Set the file system operation mode. |
file prompt { alert | quiet } |
Optional. The default is alert. |
File and directory management examples
# Display the files and the subdirectories in 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
129794 KB total (112775 KB free)
# Create a new folder called mytest in 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 in the test directory.
<Sysname> dir
Directory of flash:/test/
0 drw- - Feb 16 2006 15:28:14 mytest
2540 KB total (2519 KB free)
# Return to the upper directory.
<Sysname> cd ..
# Display the current working directory.
<Sysname> pwd