什么是文件系统?
从字面上理解文件系统就是管理和存储文件信息的软件;通常一个完整的文件系统能够提供管理,调度文件的存储空间,文件的逻辑结构,物理结构和存储方法;实现文件从标识到实际物理地址的映射,从而实现文件的操作,存取,共享以及文件安全;对于计算机软件来说,文件的主要作用是用来保存数据的,对于不同的数据结构其保存为文件的格式和属性各不相同,这样一来对于我们要想管理不同数据结构和属性的文件就变得有点困难;从另一方面讲我们也可以理解文件系统就是用来帮助我们来管理不同属性的文件的软件;对于vrp系统来讲,它也有自己的文件系统,其作用就是用来管理保存vrp系统配置文件以及系统启动所需要的系统文件等;
常用管理vrp文件系统的命令
示例:查看当前路径下的文件
<Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,464 KB free) <Huawei>
提示:dir后面不跟任何路径,默认就是查看flash:/下的文件列表;其中文件属性用4个字符表示,第一位的“-”表示文件,如果是d则表示对应文件是一个目录;后面三为分别是文件的权限,分别是读权限(r),写权限(w)以及执行权限(x),如果对应位数“-”则表示没有该文件没有对应的权限;这个和Linux系统中的文件属性表示差不多;
示例:切换目录
<Huawei>pwd flash: <Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,464 KB free) <Huawei>cd dhcp <Huawei>pwd flash:/dhcp <Huawei>
示例:创建目录
<Huawei>cd / <Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,464 KB free) <Huawei>mkdir test Info: Create directory flash:/test......Done <Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 15:03:17 test 1 drw- - Jun 27 2021 14:52:35 dhcp 2 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 3 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 4 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,460 KB free) <Huawei>
示例:删除空目录
<Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 15:03:17 test 1 drw- - Jun 27 2021 14:52:35 dhcp 2 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 3 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 4 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,460 KB free) <Huawei>rmdir test Remove directory flash:/test? (y/n)[n]:y %Removing directory flash:/test...Done! <Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,464 KB free) <Huawei>
提示:这个命令只能删除空目录,非空目录是删除不了的;所谓非空目录表示只要对应目录下有文件或目录;即我们用dir命令能够看到对应目录有文件(包含目录文件);
示例:拷贝文件
<Huawei>mkdir xxx Info: Create directory flash:/xxx......Done <Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 drw- - Jun 27 2021 15:15:13 xxx 3 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 4 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,460 KB free) <Huawei>copy statemach.efs xxx/ Copy flash:/statemach.efs to flash:/xxx/statemach.efs? (y/n)[n]:y 100% complete Info: Copied file flash:/statemach.efs to flash:/xxx/statemach.efs...Done <Huawei>copy statemach.efs xxx/aaa.txt Copy flash:/statemach.efs to flash:/xxx/aaa.txt? (y/n)[n]:y 100% complete Info: Copied file flash:/statemach.efs to flash:/xxx/aaa.txt...Done <Huawei>
提示:copy文件的命令格式是先跟源文件,后跟目标;如果对应目标是一个目录,则拷贝过来的文件名称不变,如果目标指定了文件名称,则拷贝过来会更改其名称为指定的名称;
示例:移动文件
<Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 drw- - Jun 27 2021 15:16:07 xxx 3 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 4 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,452 KB free) <Huawei>dir xxx/ Directory of flash:/xxx/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 -rw- 2,263 Jun 27 2021 15:16:07 aaa.txt 1 -rw- 2,263 Jun 27 2021 15:15:58 statemach.efs 1,090,732 KB total (784,452 KB free) <Huawei>move xxx/aaa.txt ./ Move flash:/xxx/aaa.txt to flash:/aaa.txt? (y/n)[n]:y %Moved file flash:/xxx/aaa.txt to flash:/aaa.txt. <Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 2,263 Jun 27 2021 15:16:07 aaa.txt 2 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 3 drw- - Jun 27 2021 15:18:58 xxx 4 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 5 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,452 KB free) <Huawei>dir xxx/ Directory of flash:/xxx/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 -rw- 2,263 Jun 27 2021 15:15:58 statemach.efs 1,090,732 KB total (784,452 KB free) <Huawei>
示例:重命名文件名称
<Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 2,263 Jun 27 2021 15:16:07 aaa.txt 2 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 3 drw- - Jun 27 2021 15:18:58 xxx 4 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 5 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,452 KB free) <Huawei>rename aaa.txt 123.com Rename flash:/aaa.txt to flash:/123.com? (y/n)[n]:y Info: Rename file flash:/aaa.txt to flash:/123.com ......Done <Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 -rw- 2,263 Jun 27 2021 15:16:07 123.com 1 drw- - Jun 27 2021 14:52:35 dhcp 2 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 3 drw- - Jun 27 2021 15:18:58 xxx 4 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 5 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,452 KB free) <Huawei>
示例:删除文件
<Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 -rw- 2,263 Jun 27 2021 15:16:07 123.com 1 drw- - Jun 27 2021 14:52:35 dhcp 2 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 3 drw- - Jun 27 2021 15:18:58 xxx 4 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 5 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,452 KB free) <Huawei>delete 123.com Delete flash:/123.com? (y/n)[n]:y Info: Deleting file flash:/123.com...succeed. <Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 drw- - Jun 27 2021 15:18:58 xxx 3 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 4 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,448 KB free) <Huawei>
提示:这个删除不是真正的把文件删除,它这个删除相当于把对应目录移动至回收站;
示例:恢复文件
<Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 drw- - Jun 27 2021 15:18:58 xxx 3 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 4 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,448 KB free) <Huawei>undelete 123.com Undelete flash:/123.com? (y/n)[n]:y %Undeleted file flash:/123.com. <Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 -rw- 2,263 Jun 27 2021 15:16:07 123.com 1 drw- - Jun 27 2021 14:52:35 dhcp 2 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 3 drw- - Jun 27 2021 15:18:58 xxx 4 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 5 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,448 KB free) <Huawei>
示例:永久删除文件
<Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 -rw- 2,263 Jun 27 2021 15:16:07 123.com 1 drw- - Jun 27 2021 14:52:35 dhcp 2 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 3 drw- - Jun 27 2021 15:29:05 xxx 4 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 5 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,448 KB free) <Huawei>delete /unreserved 123.com Warning: The contents of file flash:/123.com cannot be recycled. Continue? (y/n)[n]:y Info: Deleting file flash:/123.com... Deleting file permanently from flash will take a long time if needed...succeed. <Huawei>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 drw- - Jun 27 2021 15:29:05 xxx 3 -rw- 2,263 Jun 27 2021 14:52:31 statemach.efs 4 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 1,090,732 KB total (784,452 KB free) <Huawei>undelete 123.com Error: File can't be found <Huawei>
提示:可以看到加上unreserved以后,恢复文件就提示找不到文件;说明对应文件没有被移动至回收站,而是直接删除;
配置文件管理
提示:默认情况我们在交换机或路由器上写的配置都是保存在内存中的,一旦设备掉电重启我们写的配置就会丢失;配置文件的最要作用就是保存我们的配置信息,但设备重启后保证我们的配置信息不会丢失;其工作原理如上图,当前配置都是保存在内存中,一旦我们执行保存命令以后,当前配置信息就或保存进saved配置文件中,并将其作为下次设备启动时代配置文件;
配置文件查询
示例:查看当前配置文件信息
<Huawei>display current-configuration [V200R003C00] # snmp-agent local-engineid 800007DB03000000000000 snmp-agent # clock timezone China-Standard-Time minus 08:00:00 # portal local-server load portalpage.zip # drop illegal-mac alarm # set cpu-usage threshold 80 restore 75 # aaa authentication-scheme default authorization-scheme default accounting-scheme default domain default domain default_admin local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$ local-user admin service-type http # firewall zone Local priority 15 # interface GigabitEthernet0/0/0 # interface GigabitEthernet0/0/1 # interface GigabitEthernet0/0/2 # interface NULL0 # user-interface con 0 authentication-mode password user-interface vty 0 4 user-interface vty 16 20 # wlan ac # return <Huawei>
提示:以上配置是vrp系统默认的配置信息,该信息会随vrp系统的启动而被加载到内存中,当作vrp系统的配置启动;
示例:查看存储的配置信息
<Huawei>dis saved-configuration There is no correct configuration file in FLASH <Huawei>
提示:默认没有保存配置信息,查看就会提示没有对应的文件存在;
保存配置文件
示例:保存当前配置至saved-configuration中
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sys test [test]int lo 1 [test-LoopBack1]ip add 1.1.1.1 32 [test-LoopBack1]q [test]save ^ Error: Unrecognized command found at '^' position. [test]q <test>save The current configuration will be written to the device. Are you sure to continue? (y/n)[n]:y It will take several minutes to save configuration file, please wait....... Configuration file had been saved successfully Note: The configuration file will take effect after being activated <test>dis saved-configuration [V200R003C00] # sysname test # snmp-agent local-engineid 800007DB03000000000000 snmp-agent # clock timezone China-Standard-Time minus 08:00:00 # portal local-server load portalpage.zip # drop illegal-mac alarm # set cpu-usage threshold 80 restore 75 # aaa authentication-scheme default authorization-scheme default accounting-scheme default domain default domain default_admin local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$ local-user admin service-type http # firewall zone Local priority 15 # interface GigabitEthernet0/0/0 # interface GigabitEthernet0/0/1 # interface GigabitEthernet0/0/2 # interface NULL0 # interface LoopBack1 ip address 1.1.1.1 255.255.255.255 # user-interface con 0 authentication-mode password user-interface vty 0 4 user-interface vty 16 20 # wlan ac # return <test>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 drw- - Jun 27 2021 15:42:03 xxx 3 -rw- 2,263 Jun 27 2021 15:40:10 statemach.efs 4 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 5 -rw- 267 Jun 27 2021 15:52:01 private-data.txt 6 -rw- 559 Jun 27 2021 15:52:01 vrpcfg.zip 1,090,732 KB total (784,448 KB free) <test>
提示:save命令必须退出到用户视图才可执行,系统视图不可执行save命令;从上面的演示可以看出,当我们执行了save 命令以后,saved-configuration中就有就配置信息了;并且生成了vrpcfg.zip文件;
查看系统启动文件信息
示例:查看当前系统启动的配置参数
<test>dis startup MainBoard: Startup system software: null Next startup system software: null Backup system software for next startup: null Startup saved-configuration file: flash:/vrpcfg.zip Next startup saved-configuration file: flash:/vrpcfg.zip Startup license file: null Next startup license file: null Startup patch package: null Next startup patch package: null Startup voice-files: null Next startup voice-files: null <test>
提示:Startup system software是当前系统文件存放地;Next startup system software是下次启动系统文件存放地;next startup system software主要用于升级vrp系统;默认真机上可以看到对应启动的系统软件;Startup saved-configuration file是当前系统启动的配置文件;Next Startup saved-configuration file是下次系统启动的配置文件;
修改系统启动配置文件
示例:修改系统下次启动配置文件为123.cfg
<test>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 drw- - Jun 27 2021 15:42:03 xxx 3 -rw- 2,263 Jun 27 2021 15:40:10 statemach.efs 4 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 5 -rw- 267 Jun 27 2021 15:52:01 private-data.txt 6 -rw- 559 Jun 27 2021 15:52:01 vrpcfg.zip 1,090,732 KB total (784,444 KB free) <test>copy vrpcfg.zip 123.cfg Copy flash:/vrpcfg.zip to flash:/123.cfg? (y/n)[n]:y 100% complete Info: Copied file flash:/vrpcfg.zip to flash:/123.cfg...Done <test>dir Directory of flash:/ Idx Attr Size(Byte) Date Time(LMT) FileName 0 drw- - Jun 27 2021 14:52:35 dhcp 1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip 2 drw- - Jun 27 2021 15:42:03 xxx 3 -rw- 2,263 Jun 27 2021 15:40:10 statemach.efs 4 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip 5 -rw- 559 Jun 27 2021 16:11:06 123.cfg 6 -rw- 267 Jun 27 2021 15:52:01 private-data.txt 7 -rw- 559 Jun 27 2021 15:52:01 vrpcfg.zip 1,090,732 KB total (784,436 KB free) <test>startup saved-configuration flash:/123.cfg This operation will take several minutes, please wait.... Info: Succeeded in setting the file for booting system <test>dis start MainBoard: Startup system software: null Next startup system software: null Backup system software for next startup: null Startup saved-configuration file: flash:/vrpcfg.zip Next startup saved-configuration file: flash:/123.cfg Startup license file: null Next startup license file: null Startup patch package: null Next startup patch package: null Startup voice-files: null Next startup voice-files: null <test>
提示:配置文件必须以.cfg或.zip结尾;
比较当前配置和保存的配置
示例:比较当前配置和下次启动配置的不同
<test>sys Enter system view, return user view with Ctrl+Z. [test]int lo2 [test-LoopBack2]undo ip add [test-LoopBack2]q [test]q <test>compare configuration The current configuration is not the same as the next startup configuration file. ====== Current configuration line 39 ====== # user-interface con 0 authentication-mode password user-interface vty 0 4 user-interface vty 16 20 # wlan ac # return ====== Configuration file line 39 ====== ip address 3.3.3.3 255.255.255.255 # user-interface con 0 authentication-mode password user-interface vty 0 4 user-interface vty 16 20 <test>
配置文件重置
示例:清楚下次启动加载的配置文件
<test>dis start MainBoard: Startup system software: null Next startup system software: null Backup system software for next startup: null Startup saved-configuration file: flash:/vrpcfg.zip Next startup saved-configuration file: flash:/123.cfg Startup license file: null Next startup license file: null Startup patch package: null Next startup patch package: null Startup voice-files: null Next startup voice-files: null <test>reset saved-configuration This will delete the configuration in the flash memory. The device configurations will be erased to reconfigure. Are you sure? (y/n)[n]:y Clear the configuration in the device successfully. <test>dis start MainBoard: Startup system software: null Next startup system software: null Backup system software for next startup: null Startup saved-configuration file: null Next startup saved-configuration file: null Startup license file: null Next startup license file: null Startup patch package: null Next startup patch package: null Startup voice-files: null Next startup voice-files: null <test>
存储设备修复
<test>fixdisk flash: Fixdisk flash: will take long time if needed %Fixdisk flash: completed. <test>
存储设备格式化
<test>format flash: All data(include configuration and system startup file) on flash: will be lost , proceed with format? (y/n)[n]:y %Format flash: completed. <test>
提示:格式化存储会导致存储设备里原有的数据丢失,格式化之前请务必先检查里面是否有重要文件;我这里是用模拟器做到实验,真机上可以选择对应的存储设备进行格式化;