HCNA Routing&Switching之vrp文件系統


  什么是文件系統?

  從字面上理解文件系統就是管理和存儲文件信息的軟件;通常一個完整的文件系統能夠提供管理,調度文件的存儲空間,文件的邏輯結構,物理結構和存儲方法;實現文件從標識到實際物理地址的映射,從而實現文件的操作,存取,共享以及文件安全;對於計算機軟件來說,文件的主要作用是用來保存數據的,對於不同的數據結構其保存為文件的格式和屬性各不相同,這樣一來對於我們要想管理不同數據結構和屬性的文件就變得有點困難;從另一方面講我們也可以理解文件系統就是用來幫助我們來管理不同屬性的文件的軟件;對於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>

  提示:格式化存儲會導致存儲設備里原有的數據丟失,格式化之前請務必先檢查里面是否有重要文件;我這里是用模擬器做到實驗,真機上可以選擇對應的存儲設備進行格式化;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM