Index: head/zh_TW.UTF-8/books/handbook/book.xml =================================================================== --- head/zh_TW.UTF-8/books/handbook/book.xml +++ head/zh_TW.UTF-8/books/handbook/book.xml @@ -249,6 +249,7 @@ + @@ -263,6 +264,7 @@ + @@ -447,6 +449,7 @@ + @@ -768,7 +771,7 @@ - 新增了像是:USB 隨身碟、檔案系統快照 (Snapshot)、檔案系統配額 (Quota) 、檔案及網路的備援檔案系統、以及如何對硬碟分割區作加密等詳解。 + 新增了像是:USB 隨身碟、檔案系統快照 (Snapshot)、檔案系統配額 (Quota) 、檔案與網路為基礎的檔案系統、以及如何對硬碟分割區作加密等詳解。 @@ -816,7 +819,7 @@ - 內容架構重新組織成三大部分: 入門系統管理 以及 附錄 + 內容架構重新組織成三大部分:入門系統管理 以及 附錄 @@ -1321,7 +1324,7 @@ - 歡迎使用 FreeBSD! + 歡迎使用 FreeBSD! 4.4BSD-Lite @@ -1604,7 +1607,7 @@ Sandvine Sandvine - - Sandvine 使用 FreeBSD 作為它們的高性能即時網路處理平台,來建立它門的智慧網路策​​略控制產品。 + - Sandvine 使用 FreeBSD 作為它們的高性能即時網路處理平台,來建立它們的智慧網路策略控制產品。 @@ -1971,7 +1974,7 @@ 第三方程式 - 除了基礎發行版之外,FreeBSD 提供了擁有上千個常用的程式的移植軟體的套件集,在撰寫本文的同時,已有超過 24,000 個 Port! Port 的範圍從 HTTP 伺服器到遊戲、語系、編輯器,幾乎所有東西都在裡面。完整的 Port 套件集需要將近 500 MB。要編譯一個 Port 您只需要切換目錄到您想安裝的程式目錄,然後輸入 make install,接著系統便會處理剩下的動作。您編譯的每個 Port 完整原始發行版內容是動態下載的,所以您只需要有足夠的磁碟空間來編譯您想要的 Port。幾乎所有 Port 都提供以預先編譯好的套件,您可以透過簡單的指令來安裝 (pkg install),提供那些不想要自行從原始碼編譯的人使用。更多有關套件與 Port 的資訊可於 取得。 + 除了基礎發行版之外,FreeBSD 提供了擁有上千個常用的程式的移植軟體的套件集,在撰寫本文的同時,已有超過 24,000 個 Port!Port 的範圍從 HTTP 伺服器到遊戲、語系、編輯器,幾乎所有東西都在裡面。完整的 Port 套件集需要將近 500 MB。要編譯一個 Port 您只需要切換目錄到您想安裝的程式目錄,然後輸入 make install,接著系統便會處理剩下的動作。您編譯的每個 Port 完整原始發行版內容是動態下載的,所以您只需要有足夠的磁碟空間來編譯您想要的 Port。幾乎所有 Port 都提供已經預先編譯好的套件,您可以透過簡單的指令來安裝 (pkg install),提供那些不想要自行從原始碼編譯的人使用。更多有關套件與 Port 的資訊可於 取得。 @@ -2074,7 +2077,7 @@ 安裝 - 自從 FreeBSD 9.0-RELEASE 開始, FreeBSD 提供一個易用,文字介面的安裝程式 bsdinstall。 本章描述如何用 bsdinstall 來安裝 FreeBSD。 + 自從 FreeBSD 9.0-RELEASE 開始,FreeBSD 提供一個易用,文字介面的安裝程式 bsdinstall。 本章描述如何用 bsdinstall 來安裝 FreeBSD。 一般來說,本章所寫的安裝說明是針對 i386AMD64 架構。如果可以用於其他平台,將會列表說明。 安裝程式和本章所敘述的內容可能會有些微差異,所以請將本章視為通用的指引,而不是完全照著來做。 @@ -2125,7 +2128,7 @@ 安裝 FreeBSD 的硬體需求隨 FreeBSD 的版本和硬體架構而不同。 FreeBSD 發行版支援的硬體架構和裝置會列在 FreeBSD 發佈資訊 頁面。FreeBSD 下載頁面 也有建議如何正確的選擇在不同架構使用的映像檔。 - FreeBSD 安裝程序需要至少 64 MB 的 RAM 以及 1.5 GB 的硬碟空間。然而,這樣少的記憶體及磁碟空間只適合在客製的應用上,如嵌入式設備,一般用途的桌面系統會需要更多的資源,2-4 GB RAM 與至少 8 GB 的硬碟空間是不錯的起點。 + FreeBSD 安裝程序需要至少 96 MB 的 RAM 以及 1.5 GB 的硬碟空間。然而,如此少的記憶體及磁碟空間只適合在客製的應用上,如嵌入式設備。一般用途的桌面系統會需要更多的資源,2-4 GB RAM 與至少 8 GB 的硬碟空間是不錯的起點。 每一種架構的處理器需求概述如下: @@ -2272,29 +2275,29 @@ 還有另一種安裝檔是給使用 UEFI (Unified Extensible Firmware Interface) 開機的電腦使用,這些安裝檔的名稱會含有 uefi - 檔案類型: + 檔案類型: - -bootonly.iso: 這是最精簡的安裝檔,檔案中只含安裝程式。 安裝時需要網際網路連線來下載所需的檔案以完成 FreeBSD 安裝。這個檔案應使用 CD 燒錄應用程式燒錄到 CD 使用。 + -bootonly.iso:這是最精簡的安裝檔,檔案中只含安裝程式。 安裝時需要網際網路連線來下載所需的檔案以完成 FreeBSD 安裝。這個檔案應使用 CD 燒錄應用程式燒錄到 CD 使用。 - -disc1.iso: 這個檔案含有所有安裝 FreeBSD 所需的檔案,包含原始碼及 Port 套件集。這個檔案應使用 CD 燒錄應用程式燒錄到 CD 使用。 + -disc1.iso:這個檔案含有所有安裝 FreeBSD 所需的檔案,包含原始碼及 Port 套件集。這個檔案應使用 CD 燒錄應用程式燒錄到 CD 使用。 - -dvd1.iso: 這個檔案含有所有安裝 FreeBSD 所需的檔案,包含原始碼及 Port 套件集,也內含熱門的 Binary 套件可安裝視窗管理程式以及一些應用程式,如此便可從媒體安裝完整的系統,無須連線到網際網路。這個檔案應使用 DVD 燒錄應用程式燒錄到 DVD 使用。 + -dvd1.iso:這個檔案含有所有安裝 FreeBSD 所需的檔案,包含原始碼及 Port 套件集,也內含熱門的 Binary 套件可安裝視窗管理程式以及一些應用程式,如此便可從媒體安裝完整的系統,無須連線到網際網路。這個檔案應使用 DVD 燒錄應用程式燒錄到 DVD 使用。 - -memstick.img: 這個檔案含有所有安裝 FreeBSD 所需的檔案,包含原始碼及 Port 套件集。這個檔案應依據以下操作指示寫入到 USB 隨身碟使用。 + -memstick.img:這個檔案含有所有安裝 FreeBSD 所需的檔案,包含原始碼及 Port 套件集。這個檔案應依據以下操作指示寫入到 USB 隨身碟使用。 - 映像檔下載完成之後,下載同一個目錄之中的 CHECKSUM.SHA256。FreeBSD 提供 sha2561 可用來計算映像檔的 校驗和 (Checksum),使用方式為 sha256 imagefilename,其他作業系統也會有類似的程式。 + 映像檔下載完成之後,下載同一個目錄之中的 CHECKSUM.SHA256。FreeBSD 提供 sha2561 可用來計算映像檔的 校驗碼 (Checksum),使用方式為 sha256 imagefilename,其他作業系統也會有類似的程式。 - 比對計算後的 checksum 與 CHECKSUM.SHA256 檔案中的值,checksum 應該要完全相符,若 checksum 不相符,則代表該映像檔是損壞的,必須再下載一次。 + 比對計算後的校驗碼與 CHECKSUM.SHA256 檔案中的值,校驗碼應該要完全相符,若校驗碼不相符,則代表該映像檔是損壞的,必須再下載一次。 寫入映象檔到 <acronym>USB</acronym> @@ -2360,14 +2363,14 @@ 在這個警告訊息之前可以隨時中止安裝,若有任何設定錯誤的疑慮,只需在此時關閉電腦,將不會對系統磁碟做任何更改。 - 本節將介紹如何使用根據 指示所準備的安裝媒體來開機。要使用可開機的 USB,請在開啟電腦前插入 USB 隨身碟。要使用 CDDVD,則可開啟電腦後在第一時間插入媒體。如何設定系統使用插入的媒體開機依不同的系統架構會有所不同。 + 本節將介紹如何使用根據 指示所準備的安裝媒體來開機。要使用可開機的 USB,請在開啟電腦前插入 USB 隨身碟。要使用 CDDVD,則可開啟電腦後在第一時間插入媒體。如何設定系統使用插入的媒體開機依不同的系統架構會有所不同。 在 <trademark>i386</trademark> 及 amd64 開機 這兩種架構提供了 BIOS 選單可選擇開機的裝置,依據要使用的安裝媒體類型,選擇 CD/DVDUSB 裝置做為第一個開機裝置。大多數的系統也會提供快速鍵可在啟動時選擇開機裝置,而不需要進入BIOS,通常這個按鍵可能是 F10, F11, F12Escape 其中之一。 - 若電腦仍載入了現有的作業系統,而不是 FreeBSD 安裝程式,原因可能為: + 若電腦仍載入了現有的作業系統,而不是 FreeBSD 安裝程式,原因可能為: @@ -2397,7 +2400,7 @@ 大多數 SPARC64 系統會自動從磁碟開機,要從 CD 安裝 FreeBSD 需要進入 PROM - 要進入 PROM,需重新開機系統然後等候開機訊息出現。訊息會依機型而有所不同,但大致結果會如: + 要進入 PROM,需重新開機系統然後等候開機訊息出現。訊息會依機型而有所不同,但大致結果會如: Sun Blade 100 (UltraSPARC-IIe), Keyboard Present Copyright 1998-2001 Sun Microsystems, Inc. All rights reserved. @@ -2428,23 +2431,23 @@ - 啟動多使用者模式 (Boot Multi User): 這個選項會繼續 FreeBSD 開機程序,若開機計時器已經暫停,可按 1、大寫或小寫 BEnter 鍵。 + 啟動多使用者模式 (Boot Multi User):這個選項會繼續 FreeBSD 開機程序,若開機計時器已經暫停,可按 1、大寫或小寫 BEnter 鍵。 - 啟動單使用者模式 (Boot Single User): 這個模式用來修正已安裝的 FreeBSD,如 所述。可按 2、大寫或小寫 S 進入這個模式。 + 啟動單使用者模式 (Boot Single User):這個模式用來修正已安裝的 FreeBSD,如 所述。可按 2、大寫或小寫 S 進入這個模式。 - 離開到載入程式提示 (Escape to loader prompt): 這個選項會開機進入修復提示,這個模式含有有限數量的低階指令,這個模式詳細說明於 。可按 3Esc 進入這個提示。 + 離開到載入程式提示 (Escape to loader prompt):這個選項會開機進入修復提示,這個模式含有有限數量的低階指令,這個模式詳細說明於 。可按 3Esc 進入這個提示。 - 重新開機 (Reboot): 重新開啟系統。 + 重新開機 (Reboot):重新開啟系統。 - 設定開機選項 (Configure Boot Options): 開啟內部選單,詳細說明於 + 設定開機選項 (Configure Boot Options):開啟內部選單,詳細說明於 @@ -2464,19 +2467,19 @@ - ACPI 支援 (ACPI Support): 若系統在開機時卡住,可嘗試切換這個選項為關 (Off)。 + ACPI 支援 (ACPI Support):若系統在開機時卡住,可嘗試切換這個選項為關 (Off)。 - 安全模式 (Safe Mode): 若系統在 ACPI 支援 (ACPI Support) 設為關 (Off) 時開機時仍然會卡住,可嘗試將此選項設為開 (On)。 + 安全模式 (Safe Mode):若系統在 ACPI 支援 (ACPI Support) 設為關 (Off) 時開機時仍然會卡住,可嘗試將此選項設為開 (On)。 - 單使用者 (Single User): 切換這個選項為開 (On) 來修正已存在的 FreeBSD 如 所述,問題修正後,將其設回關 (Off)。 + 單使用者 (Single User):切換這個選項為開 (On) 來修正已存在的 FreeBSD 如 所述,問題修正後,將其設回關 (Off)。 - 詳細資訊 (Verbose): 切換這個選項為開 (On) 來查看開機程序中更詳細的訊息,這在診斷硬體問題時非常有用。 + 詳細資訊 (Verbose):切換這個選項為開 (On) 來查看開機程序中更詳細的訊息,這在診斷硬體問題時非常有用。 @@ -2535,7 +2538,7 @@ 設定鍵盤配置時,可使用上與下方向鍵來選擇最接近已連接到系統的鍵盤的鍵盤對應表 (Keymap),然後按下 Enter 儲存選項。 - Esc 會離開這個選單然後使用預設的鍵盤對應表,若不清選要使用那種鍵盤對應表,United States of America ISO-8859-1 是也是保險的選項。 + Esc 會離開這個選單然後使用預設的鍵盤對應表,若不清楚要使用那種鍵盤對應表,United States of America ISO-8859-1 是也是保險的選項。 在 FreeBSD 10.0-RELEASE 以及之後的版本,已經加強了這個選單,會顯示完整的鍵盤對應表選項,並預先選擇預設值。另外,當選擇其他鍵盤對應用時,在繼續之前會顯示對話框讓使用者測試鍵盤對應表來確認。 @@ -2585,7 +2588,7 @@ - 決定要安裝的元件主要會根據系統的用途以及可用的磁碟空間容量。FreeBSD 核心 (Kernel) 及 Userland 統稱為 基礎系統 (Base system),是必須安裝的部份。依據系統的架構,部份元件可能不會顯示: + 決定要安裝的元件主要會根據系統的用途以及可用的磁碟空間容量。FreeBSD 核心 (Kernel) 及 Userland 統稱為 基礎系統 (Base system),是必須安裝的部份。依據系統的架構,部份元件可能不會顯示: @@ -2688,9 +2691,9 @@ /usr - 配置檔案系統時要記得硬碟的傳輸資料外軌較內軌的速度快,因此較小且大量存取的檔案系統應要較接近磁碟的外軌,而較大的分割區如 /usr 應放置在磁碟較內部,建議建立分割區的順序如下: /, swap, /var 然後 /usr + 配置檔案系統時要記得硬碟的資料傳輸的速度外軌較內軌快,因此較小且大量存取的檔案系統應要較接近磁碟的外軌,而較大的分割區如 /usr 應放置在磁碟較內部,建議建立分割區的順序如下:/, swap, /var 然後 /usr - 機器預期的用途會反映在 /var 分割區的大小,這個分割區用來保存郵件 (Mailbox)、記錄檔 (Log file) 及印表機緩衝 (Spool)。依使用者數及保存的期間,郵件及記錄檔可能成長到無法預期的大小,一般來說大部份的使用很少會在 /var 需要超過 1 GB 的可用磁碟空間。 + 機器預期的用途會反映到 /var 分割區的大小,這個分割區用來保存郵件 (Mailbox)、日誌檔 (Log file) 及印表機緩衝 (Spool)。依使用者數及保存的期間,郵件及日誌檔可能成長到無法預期的大小,一般來說大部份的使用很少會在 /var 需要超過 1 GB 的可用磁碟空間。 有時在 /var/tmp 會需要較多的空間,當新軟體安裝,套件工具會從套件中取出暫存的複本置於 /var/tmp。若在 /var/tmp 沒有足夠的空間,要安裝大型軟體套件,例如 Firefox, Apache OpenOfficeLibreOffice 會很困難。 @@ -2769,7 +2772,7 @@ - 選擇要安裝的磁碟機 (在這個例子為 ada0) 然後選擇 [ Create ] 會以選單顯示可用的分割表格式 (Partition scheme): + 選擇要安裝的磁碟機 (在這個例子為 ada0) 然後選擇 [ Create ] 會以選單顯示可用的分割表格式 (Partition scheme):
手動建立分割區 @@ -2840,7 +2843,7 @@
- 標準的 FreeBSD GPT 安裝會使用至少三種分割區: + 標準的 FreeBSD GPT 安裝會使用至少三種分割區: @@ -2860,10 +2863,10 @@ 檔案系統分割區可建立多個,且有部份人會偏好使用傳統的配置方式將 /, /var, /tmp 以及 /usr 分開存放在不同的分割區。請參考 的範例。 - 大小 (Size) 欄位可以使用常用的縮寫來輸入: K 代表 KB, M 代表 MB, G 代表 GB。 + 大小 (Size) 欄位可以使用常用的縮寫來輸入:K 代表 KB, M 代表 MB, G 代表 GB。 - 適當的對齊磁碟扇區 (Sector) 會提供最佳的效能,而且讓分割區大小為 4 KB 的偶數倍數可協助確保對齊在磁碟機上的 512-byte 或 4K-byte 扇區。一般來說,使用分割區大小為 1M 或 1G 的偶數倍數是最簡單的方式確保每個分割區以 4K 的偶數倍數做為開始。唯一一個例外是: freebsd-boot 分割區因目前開機程式 (Boot code) 的限制,不可大於 512K。 + 適當的對齊磁碟扇區 (Sector) 會提供最佳的效能,而且讓分割區大小為 4 KB 的偶數倍數可協助確保對齊在磁碟機上的 512-byte 或 4K-byte 扇區。一般來說,使用分割區大小為 1M 或 1G 的偶數倍數是最簡單的方式確保每個分割區以 4K 的偶數倍數做為開始。唯一一個例外是:freebsd-boot 分割區因目前開機程式 (Boot code) 的限制,不可大於 512K。 若分割區內含檔案系統便會需要一個掛載點 (Mountpoint),若只要建立一個 UFS 分割區,那麼掛載點應設為 / @@ -3059,7 +3062,7 @@ 安裝時間會依據選擇的發行版、安裝媒體、電腦的速度而有所不同,接下來會有一系列訊息會告知目前的進度。 - 首先,安裝程式會格式化選擇的磁碟,然後初始化分割區。然後,若使用僅可開機 (Boot only) 的媒體則會開始下載選擇的元件: + 首先,安裝程式會格式化選擇的磁碟,然後初始化分割區。然後,若使用僅可開機 (Boot only) 的媒體則會開始下載選擇的元件:
取得發行版檔案 @@ -3071,7 +3074,7 @@
- 接著,會檢驗發行版的檔案完整性來確保沒有因下載過程中或安裝媒體的讀取過程中讀取錯誤造成的損壞: + 接著,會檢驗發行版的檔案完整性來確保沒有因下載過程中或安裝媒體的讀取過程中讀取錯誤造成的損壞:
檢驗發行版檔案 @@ -3083,7 +3086,7 @@
- 最後,檢驗過的發行版檔案會被取出儲存至磁碟: + 最後,檢驗過的發行版檔案會被取出儲存至磁碟:
解開發行版檔案 @@ -3142,7 +3145,7 @@
- 若選擇的是乙太網路介面卡,安裝程式會跳過這部份直接到 ,若選擇的是無線網路介面卡,系統則會開始掃描無線存取點 (Wireless Access Point): + 若選擇的是乙太網路介面卡,安裝程式會跳過這部份直接到 ,若選擇的是無線網路介面卡,系統則會開始掃描無線存取點 (Wireless Access Point):
掃描無線網路存取點 @@ -3178,7 +3181,7 @@
- 接下來,選擇是否要設定乙太網路或無線網路介面卡的 IPv4 位址: + 接下來,選擇是否要設定乙太網路或無線網路介面卡的 IPv4 位址:
選擇 <acronym>IPv4</acronym> 網路 @@ -3208,7 +3211,7 @@
- 若沒有可用的 DHCP 伺服器,則選擇 [ No ] 然後在這個選單中輸入以下位址資訊: + 若沒有可用的 DHCP 伺服器,則選擇 [ No ] 然後在這個選單中輸入以下位址資訊:
<acronym>IPv4</acronym> 靜態位置設定 @@ -3260,7 +3263,7 @@
- 若沒有可用的 IPv6 路由器,請選擇 [ No ] 然後在這個選單中輸入以下位址資訊: + 若沒有可用的 IPv6 路由器,請選擇 [ No ] 然後在這個選單中輸入以下位址資訊:
IPv6 靜態位置設定 @@ -3378,7 +3381,7 @@
- 這是可以在這個選單開啟的服務摘要: + 這是可以在這個選單開啟的服務摘要: @@ -3445,7 +3448,7 @@ - 這裡是要輸入的資訊摘要: + 這裡是要輸入的資訊摘要: @@ -3605,7 +3608,7 @@ 要查看開機過程顯示的訊息可按 Scroll-Lock 鍵來開啟卷軸暫存,然後可使用 PgUp, PgDn 以及方向鍵來捲動訊息。查看完成之後再按 Scroll-Lock 鍵一次來解除畫面鎖定並返回 Console。系統開機一段時間之後要查看這些訊息可在指令提示後輸入 less /var/run/dmesg.boot,查看後按下 q 鍵便可返回指令列。 - 若在 有開啟 sshd,因系統會產生 RSADSA 金鑰第一次開機可能會有點慢,之後的開機便會恢復正常速度。接著會顯示金鑰的指紋 (Fingerprint),如這個範例: + 若在 有開啟 sshd,因系統會產生 RSADSA 金鑰第一次開機可能會有點慢,之後的開機便會恢復正常速度。接著會顯示金鑰的指紋 (Fingerprint),如這個範例: Generating public/private rsa1 key pair. Your identification has been saved in /etc/ssh/ssh_host_key. @@ -3647,7 +3650,7 @@ FreeBSD 預設並不會安裝圖型化介面,請參考 取得有關安裝與設定圖型化視窗管理程式的資訊。 - 正確的將 FreeBSD 電腦關機對保護資料及避免硬體損壞有幫助。在系統尚未正常關機之前請不要關閉電源! 若使用者為 wheel 群組的成員之一,可在指令列輸入 su 然後輸入 root 密碼來成為超級使用者。接著輸入 shutdown -p now 系統便會關機,若硬體支援的話,電腦會自行關閉電源。 + 正確的將 FreeBSD 電腦關機對保護資料及避免硬體損壞有幫助。在系統尚未正常關機之前請不要關閉電源! 若使用者為 wheel 群組的成員之一,可在指令列輸入 su 然後輸入 root 密碼來成為超級使用者。接著輸入 shutdown -p now 系統便會關機,若硬體支援的話,電腦會自行關閉電源。
@@ -3668,7 +3671,7 @@ 製造商通常會建議若沒有特殊原因盡量避免升級主機板 BIOS - 若系統在開機偵測硬體時卡住或安裝時運作異常,可能主因為 ACPI,FreeBSD 在 i386, amd64 及 ia64 平台廣泛的使用了系統 ACPI 服務來協助設定系統組態,若在開機時有偵測到該功能。不幸的是,ACPI 驅動程式與系統主機板及 BIOS 韌體之間仍存在部份問題。可於開機載入程式的第三階段設定 hint.acpi.0.disabled Hint 來關閉 ACPI: + 若系統在開機偵測硬體時卡住或安裝時運作異常,可能主因為 ACPI,FreeBSD 在 i386, amd64 及 ia64 平台廣泛的使用了系統 ACPI 服務來協助設定系統組態,若在開機時有偵測到該功能。不幸的是,ACPI 驅動程式與系統主機板及 BIOS 韌體之間仍存在部份問題。可於開機載入程式的第三階段設定 hint.acpi.0.disabled Hint 來關閉 ACPI set hint.acpi.0.disabled="1" @@ -3680,7 +3683,7 @@ 所示 bsdinstall 的歡迎選單提供了 [ Live CD ] 選項,這對那些對 FreeBSD 是否為正確的作業系統尚存疑慮的人非常有幫助,這可讓這些人在安裝前測試一部份功能。 - 在使用 [ Live CD ] 之前必須注意以下幾點事項: + 在使用 [ Live CD ] 之前必須注意以下幾點事項: @@ -3812,7 +3815,7 @@ 請參考 kbdcontrol1, vidcontrol1, atkbd4, syscons4 以及 vt4 來取得更多有關 FreeBSD Console 及鍵盤驅動程式的技術說明。 - FreeBSD 中虛擬 Console 的數量設定在 /etc/ttys 檔案中的下列章節: + FreeBSD 中虛擬 Console 的數量設定在 /etc/ttys 檔案中的下列章節: # name getty type status comments # @@ -3838,7 +3841,7 @@ FreeBSD 開機選單會提供一個選項為 Boot Single User,若選擇該項目,系統將會進入所謂 單使用者模式 的特殊模式。 此模式通常用在修復系統無法開機或重設已忘掉的 root 密碼。 在當使用者模式中無法使用網路及其他虛擬 Console,但有完整 root 對系統的存取權限,而且預設是不須要輸入 root 密碼。 也因此,要能透過實體鍵盤操作才能進入此模式,在考量 FreeBSD 系統安全時須要限制可操作實體鍵盤的人員。 - 有關單使用者模式的設定可在 /etc/ttys 中的以下章節中找到: + 有關單使用者模式的設定可在 /etc/ttys 中的以下章節中找到: # name getty type status comments # @@ -4521,7 +4524,7 @@ directories - 使用 ls1 指令時,可以加上 參數, 來檢視詳細的目錄清單。 清單中欄位的資訊包含檔案對所有者、群組及其他人的權限。 在任一個目錄底下執行 ls -l,會顯示如下的結果: + 使用 ls1 指令時,可以加上 參數, 來檢視詳細的目錄清單。 清單中欄位的資訊包含檔案對所有者、群組及其他人的權限。 在任一個目錄底下執行 ls -l,會顯示如下的結果: % ls -l total 530 @@ -4559,7 +4562,7 @@ symbolic - 權限符號可稱做符號表示,使用字元的方式來取代使用數值來設定檔案或目錄的權限。 符號表示的格式依序為 (某人)(動作)(權限),可使用的符號如下: + 權限符號可稱做符號表示,使用字元的方式來取代使用數值來設定檔案或目錄的權限。 符號表示的格式依序為 (某人)(動作)(權限),可使用的符號如下: @@ -4647,7 +4650,7 @@ - 如先前同樣使用 chmod1 指令來設定,但使用的參數為這些字元。 例如,您可以使用下列指令禁止其他使用者存取檔案 FILE: + 如先前同樣使用 chmod1 指令來設定,但使用的參數為這些字元。 例如,您可以使用下列指令禁止其他使用者存取檔案 FILE % chmod go= FILE @@ -4738,7 +4741,7 @@ Changing local password for trhodes Old Password: - 於終端機 B: + 於終端機 B: # ps aux | grep passwd @@ -4988,7 +4991,7 @@ 檔案或目錄的對應是藉由給定的檔案或目錄名稱,然後加上正斜線符號 (/);之後再視需要加上其他的目錄名稱。 如果您有一個目錄 foo ,裡面有一個目錄叫作 bar,這個目錄中又包含了一個叫 readme.txt 的檔案,那麼這個檔案的全名,或者說檔案的路徑 (Path)就是 foo/bar/readme.txt。注意這與 Windows 用來分隔檔案與目錄名稱所使用的 \ 不同,且 FreeBSD 在路徑上並不使用磁碟機代號或其他磁碟機名稱,意思是,在 FreeBSD 上不會有人輸入 c:\foo\bar\readme.txt 這種路徑。 - 目錄及檔案儲存在檔案系統 (File system) 之中。 每個檔案系統都有唯一一個最上層的目錄,叫做根目錄 (Root directory)。 然後在這個根目錄下面才能有其他的目錄。其中一個檔案系統會被指定成為根檔案系統 (Root file system)/,其他的檔案系統均會掛載 (mounted) 在該根檔案系統之下,不論在 FreeBSD 有多少個磁碟,所有目錄都會成為該磁碟的一部份。 + 目錄及檔案儲存在檔案系統 (File system) 之中。 每個檔案系統都有唯一一個最上層的目錄,叫做根目錄 (Root directory)。 然後在這個根目錄下面才能有其他的目錄。其中一個檔案系統會被指定成為根檔案系統 (Root file system)/,其他的檔案系統均會掛載 (Mount) 在該根檔案系統之下,不論在 FreeBSD 有多少個磁碟,所有目錄都會成為該磁碟的一部份。 假設您有三個檔案系統,分別叫作 A, BC。 每個檔案系統都包含兩個目錄,叫做 A1, A2 (以此類推得 B1, B2C1, C2)。 @@ -5008,7 +5011,7 @@ - 一個檔案系統必須以目錄形式掛載於另一個檔案系統上。 因此,假設您將 B 掛載於 A1 之上,則 B 的根目錄就變成了 A1,而在 B 之下的任何目錄的路徑也隨之改變: + 一個檔案系統必須以目錄形式掛載於另一個檔案系統上。 因此,假設您將 B 掛載於 A1 之上,則 B 的根目錄就變成了 A1,而在 B 之下的任何目錄的路徑也隨之改變: @@ -5028,7 +5031,7 @@ - B1B2 目錄中的任何檔案必須經由路徑 /A1/B1/A1/B2 才能達到。 所有原來在 /A1 中的檔案會暫時被隱藏起來,直到 B解除掛載 (Unmounted) 後才會再顯現出來。 + B1B2 目錄中的任何檔案必須經由路徑 /A1/B1/A1/B2 才能達到。 所有原來在 /A1 中的檔案會暫時被隱藏起來,直到 B卸載 (Unmount) 後才會再顯現出來。 如果 B 掛載在 A2 之上,則會變成: @@ -5305,7 +5308,7 @@ - 掛載與缷載檔案系統 + 掛載與卸載檔案系統 檔案系統就像一顆樹。/ 就像是樹根,而 /dev/usr 以及其他在根目錄下的目錄就像是樹枝,而這些樹枝上面又還有分支,像是 /usr/local 等。 @@ -5389,7 +5392,7 @@ mounting - mount8 指令是拿來掛載檔案系統用的。基本的操作指令格式如下: + mount8 指令是拿來掛載檔案系統用的。基本的操作指令格式如下: # mount device mountpoint @@ -5505,7 +5508,7 @@ 有些程式並不是設計成一直在接收使用者的輸入的, 而是在開始執行的時候就從中斷與終端機的連線。 例如說, 網頁伺服器整天都在回應網頁方面的要求,它通常不需要您輸入任何東西。 另外,像是把信從一個站傳送到另一個站的程式,也是這種類型的應用程式。我們把這種程式稱作 Daemon。 Daemon 一詞是來自是希臘神話中的角色:祂們既不屬於善良陣營或邪惡陣營,祂們在背地裡做一些有用的事情。這也就是為何 BSD 的吉祥物,是一隻穿著帆布鞋拿著三叉耙的快樂小惡魔的原因。 - 通常來說做為 Deamon 執行的程式名字後面都會加一個字母 dBIND 是 Berkeley Internet Name Domain 的縮寫,但實際上執行的程式名稱是 namedApache 網頁伺服器的程式名稱是 httpd、行列式印表機緩衝服務(Line Printer Spooling) Daemon 是 lpd,依此類推。 但這是習慣用法,並沒有硬性規定,例如 Sendmail 主要的寄信 Daemon 是叫做 sendmail 而不是 maild + 通常來說做為 Deamon 執行的程式名字後面都會加一個字母 dBIND 是 Berkeley Internet Name Domain 的縮寫,但實際上執行的程式名稱是 namedApache 網頁伺服器的程式名稱是 httpd、行列式印表機緩衝服務 (Line Printer Spooling) Daemon 是 lpd,依此類推。 但這是習慣用法,並沒有硬性規定,例如 Sendmail 主要的寄信 Daemon 是叫做 sendmail 而不是 maild 檢視程序 @@ -5558,7 +5561,7 @@ 要與執行中的程序或 Daemon 溝通唯一的方法是透過 kill1 指令傳送信號 (Signal)。 信號有很多種,有些有特定的意義,有些則是會由應用程式來解讀,應用程式的說明文件會告訴您該程式是如何解讀信號。 使用者只能送信號給自己所擁有的程序,送信號給其他人的程序會出現權限不足的錯誤。 唯一的例外是 root使用者,他可以送信號給任何人的程序。 - 作業系統在某些情況也會送信號給應用程式。 假設有個應用程式寫得不好,企圖要存取它不該碰的記憶體的時候,FreeBSD 會送一個 Segmentation Violation 信號 (SIGSEGV) 給這個程序。 如果有一個應用程式用了 alarm3 的系統呼叫 (System call) 要求系統在過一段時間之後發出通知,時間到了的時候系統就會發出通知信號 (SIGALRM) 給該程式。 + 作業系統在某些情況也會送信號給應用程式。 假設有個應用程式寫得不好,企圖要存取它不該碰的記憶體的時候,FreeBSD 會送一個 Segmentation Violation 信號 (SIGSEGV) 給這個程序。 如果有一個應用程式用了 alarm3 的系統呼叫 (System call) 要求系統在過一段時間之後發出通知,時間到了的時候系統就會發出通知信號 (SIGALRM) 給該程式。 SIGTERMSIGKILL 這兩個信號可以拿來終止程序。 用 SIGTERM 結束程序是比較有禮貌的方式,該程序收到信號後可以把自已所使用的日誌檔關閉及其他要在結束前要做的事完成, 然後在關掉程序之前結束掉手邊的工作。 在某些情況下程序有可能會忽略 SIGTERM,如它正在做一些不能中斷的工作的話。 @@ -5593,7 +5596,7 @@ 為何要使用 <command>/bin/kill</command>? - 多數 shell 都有提供內建的 kill 指令。 也就是說這種 shell 會直接發送信號,而不是執行 /bin/kill。 但要小心不同的 shell 會有不同的語法來指定信號的名稱等。 與其嘗試去把它們通通學會,不如就單純的直接用 /bin/kill + 多數 Shell 都有提供內建的 kill 指令。 也就是說這種 shell 會直接發送信號,而不是執行 /bin/kill。 但要小心不同的 shell 會有不同的語法來指定信號的名稱等。 與其嘗試去把它們通通學會,不如就單純的直接用 /bin/kill @@ -5628,7 +5631,7 @@ environment variables - Shell 的另一項特點是使用了環境變數。 環境變數是以變數與鍵值 (variable/key) 的對應關係儲存於 Shell 的環境,任何由該 Shell 所產生的程序都可以讀取此環境變數, 因此環境變數儲存了許多程序的設定。 提供了常見的環境變數與其涵義的清單。 請注意環境變數的名稱永遠以大寫表示。 + Shell 的另一項特點是使用了環境變數。 環境變數是以變數與鍵值 (Variable/Key) 的對應關係儲存於 Shell 的環境,任何由該 Shell 所產生的程序都可以讀取此環境變數, 因此環境變數儲存了許多程序的設定。 提供了常見的環境變數與其涵義的清單。 請注意環境變數的名稱永遠以大寫表示。 常用環境變數 @@ -5716,7 +5719,7 @@ 要展開以顯示目前環境變數中的值,只要在指令列輸入環境變數之前加上 $ 字元。 舉例來說,echo $TERM 會顯示出目前 $TERM 的設定值。 - Shell 中有特殊字元用來表示特殊資料,我們將其稱作 Meta-characters。 其中最常見的 Meta-characters 是 * 字元,它代表了檔名中的任意字元。 Meta-characters 可以用在搜尋檔名,舉例來說,輸入 echo * 會和輸入 ls 得到幾乎相同的結果,這是因為 shell 會將所有符合 * 字元的檔案由 echo 顯示出來。 + Shell 中有特殊字元用來表示特殊資料,我們將其稱作 Meta-character。 其中最常見的 Meta-character 是 * 字元,它代表了檔名中的任意字元。 Meta-character 可以用在搜尋檔名,舉例來說,輸入 echo * 會和輸入 ls 得到幾乎相同的結果,這是因為 shell 會將所有符合 * 字元的檔案由 echo 顯示出來。為了避免 Shell 轉譯這些特殊字元,我們可以在這些特殊字元前放一個反斜線 (\) 字元使他們跳脫 (Escape) Shell 的轉譯。舉例來說,echo $TERM 會印出你目前終端機的設定, echo \$TERM 則會直接印出 $TERM 這幾個字。 @@ -5755,15 +5758,15 @@ UNIX Shell 不只是指令的直譯器,它是一個強大的工具可讓使用者執行指令、重新導向指令的輸出、重新導向指令的輸入並將指令串連在一起來改進最終指令的輸出結果。當這個功能與內建的指令混合使用時,可提供一個可以最佳化效率的環境給使用者。 - Shell 重新導向是將一個指令的輸出或輸入傳送給另一個指令或檔案。例如,要擷取 ls1 指令的輸出到一個檔案,可以重新導向輸出: + Shell 重新導向是將一個指令的輸出或輸入傳送給另一個指令或檔案。例如,要擷取 ls1 指令的輸出到一個檔案,可以重新導向輸出:% ls > directory_listing.txt - 目錄的內容現在會列到 directory_listing.txt 中,部份指令可以讀取輸入,例如 sort1。要排序這個清單,可重新導向輸入: + 目錄的內容現在會列到 directory_listing.txt 中,部份指令可以讀取輸入,例如 sort1。要排序這個清單,可重新導向輸入:% sort < directory_listing.txt - 輸入的內容會被排序後呈現在畫面上,要重新導向該輸入到另一個檔案,可以重新導向 sort1 的出輸: + 輸入的內容會被排序後呈現在畫面上,要重新導向該輸入到另一個檔案,可以重新導向 sort1 的出輸:% sort < directory_listing.txt > sorted.txt @@ -5771,7 +5774,7 @@ 透過使用這些檔案描述符,Shell 能夠讓輸出與輸入在各種指令間傳遞與重新導向到或自檔案。另一種重新導向的方式是使用管線運算子 (Pipe operator)。 - UNIX 的管線運算子,即 |,可允許指令的輸出可直接傳遞或導向到另一個程式。基本上,管線運算子允許指令的標準輸出以標準輸入傳遞給另一個指令,例如: + UNIX 的管線運算子,即 |,可允許指令的輸出可直接傳遞或導向到另一個程式。基本上,管線運算子允許指令的標準輸出以標準輸入傳遞給另一個指令,例如:% cat directory_listing.txt | sort | less @@ -5929,7 +5932,7 @@ --> - 安裝應用程式: 套件與 Port + 安裝應用程式:套件與 Port 概述 @@ -6446,23 +6449,23 @@ - Makefile: 內含用來說明應用程式要如何編譯、要安裝該程式到那的敘述句。 + Makefile:內含用來說明應用程式要如何編譯、要安裝該程式到那的敘述句。 - distinfo: 內含編譯 Port 必須下載的檔案名稱以及校驗碼 (Checksums)。 + distinfo:內含編譯 Port 必須下載的檔案名稱以及校驗碼 (Checksum)。 - files/: 此目錄含有編譯與安裝程式到 FreeBSD 時所需的修補檔。此目錄也可能含有其他用來編譯 Port 的檔案。 + files/:此目錄含有編譯與安裝程式到 FreeBSD 時所需的修補檔。此目錄也可能含有其他用來編譯 Port 的檔案。 - pkg-descr: 提供程式更詳細的說明。 + pkg-descr:提供程式更詳細的說明。 - pkg-plist: Port 安裝的所有檔案清單,也同時會告訴 Port 系統解除安裝時要移除那一些檔案。 + pkg-plist:Port 安裝的所有檔案清單,也同時會告訴 Port 系統解除安裝時要移除那一些檔案。 @@ -6822,20 +6825,20 @@ 在一台電腦,poudriere 可使用多組設定在多個 Jail 編譯來自不同 Port 樹的 Port。用來定義這些組合的自訂設定稱作 sets,可在安裝 ports-mgmt/poudriereports-mgmt/poudriere-devel 後參考 poudriere8 中的 CUSTOMIZATION 章節來取得詳細的資訊。 - 在此處示範的基本設定放了單一個 jail-, port- 以及 set- 特定的 make.conf/usr/local/etc/poudriere.d。在此範例使用的檔案名稱由 Jail 名稱、Port 名稱以及 set 名稱所組成: 10amd64-local-workstation-make.conf。系統 make.conf 與這個新的檔案在編譯時期會被合併為編譯 Jail 要使用的 make.conf + 在此處示範的基本設定放了單一個 jail-, port- 以及 set- 特定的 make.conf/usr/local/etc/poudriere.d。在此範例使用的檔案名稱由 Jail 名稱、Port 名稱以及 set 名稱所組成:10amd64-local-workstation-make.conf。系統 make.conf 與這個新的檔案在編譯時期會被合併為編譯 Jail 要使用的 make.conf - 要編譯的套件會輸入到 10amd64-local-workstation-pkglist: + 要編譯的套件會輸入到 10amd64-local-workstation-pkglist editors/emacs devel/git ports-mgmt/pkg ... - 可使用以下方式設定選項及相依: + 可使用以下方式設定選項及相依: # poudriere options -j 10amd64 -p local -z workstation -f 10amd64-local-workstation-pkglist - 最後,編譯套件並建立套件檔案庫: + 最後,編譯套件並建立套件檔案庫: # poudriere bulk -j 10amd64 -p local -z workstation -f 10amd64-local-workstation-pkglist @@ -6848,15 +6851,15 @@ 設定 pkg 客戶端使用 Poudriere 檔案庫 - 雖然可以同時使用自訂的檔案庫與官方檔案庫,但有時關閉官方檔案庫會有幫助。這可以透過建立一個設定檔覆蓋並關閉官方的設定檔來完成。建立 /usr/local/etc/pkg/repos/FreeBSD.conf 包含以下內容: + 雖然可以同時使用自訂的檔案庫與官方檔案庫,但有時關閉官方檔案庫會有幫助。這可以透過建立一個設定檔覆蓋並關閉官方的設定檔來完成。建立 /usr/local/etc/pkg/repos/FreeBSD.conf 包含以下內容: FreeBSD: { enabled: no } - 通常最簡單要提供 poudriere 給客戶端的方式是透過 HTTP。安裝一個網頁伺服器來提供套件目錄,通常會像: /usr/local/poudriere/data/packages/10amd64,其中 10amd64 是編譯的名稱。 + 通常最簡單要提供 poudriere 給客戶端的方式是透過 HTTP。安裝一個網頁伺服器來提供套件目錄,通常會像:/usr/local/poudriere/data/packages/10amd64,其中 10amd64 是編譯的名稱。 - 若要連往套件檔案庫的 URL 是: http://pkg.example.com/10amd64,則在 /usr/local/etc/pkg/repos/custom.conf 的檔案庫設定檔為: + 若要連往套件檔案庫的 URL 是:http://pkg.example.com/10amd64,則在 /usr/local/etc/pkg/repos/custom.conf 的檔案庫設定檔為: custom: { url: "http://pkg.example.com/10amd64", @@ -6916,7 +6919,7 @@ - 自行修正看看! Porter's Handbook 中含有 Port 基礎架構的詳細資訊,可提供資訊讓您可修正偶然損壞的 Port 或甚至您可以提交之自己的 Port。 + 自行修正看看!Porter's Handbook 中含有 Port 基礎架構的詳細資訊,可提供資訊讓您可修正偶然損壞的 Port 或甚至您可以提交之自己的 Port。 @@ -7005,7 +7008,7 @@ X 伺服器 (X Server) - X 最初設計是以網路為中心,採用 client-server 架構。在此架構下 X 伺服器 在有鍵盤、螢幕、滑鼠的電腦上運作。該伺服器負責的工作包含管理顯示、處理來自鍵盤、滑鼠的輸入及來自其他設備(如平板或或影像投影機)的輸入或輸出。這點可能會讓人感到困惑,因為 X 使用的術語與一般的認知剛好相反。 一般認知會以為 X 伺服器 是要在最強悍的主機上執行,而 X 客戶端 才是在桌機上面執行,實際上卻是相反。 + X 最初設計是以網路為中心,採用 client-server 架構。在此架構下 X 伺服器 在有鍵盤、螢幕、滑鼠的電腦上運作。該伺服器負責的工作包含管理顯示、處理來自鍵盤、滑鼠的輸入及來自其他設備 (如平板或或影像投影機) 的輸入或輸出。這點可能會讓人感到困惑,因為 X 使用的術語與一般的認知剛好相反。 一般認知會以為 X 伺服器 是要在最強悍的主機上執行,而 X 客戶端 才是在桌機上面執行,實際上卻是相反。 @@ -7053,7 +7056,7 @@ 視窗元件 (Widget) - 視窗元件指的是在所有在使用者介面上可被點選或操作的項目,這包括按鈕、核選方塊、單選按鈕、圖示及清單。 視窗元件工具包(Widget toolkit)是指用來建立圖型化應用程式的一系列的視窗元件。目前有數個有名的視窗元件工具包,包含 KDE 所使用的 Qt、GNOME 所使用的 GTK+。 因此應用程式會依其開發時所選用的視窗元件工具包而有不同的外觀。 + 視窗元件指的是在所有在使用者介面上可被點選或操作的項目,這包括按鈕、核選方塊、單選按鈕、圖示及清單。 視窗元件工具包 (Widget toolkit) 是指用來建立圖型化應用程式的一系列的視窗元件。目前有數個有名的視窗元件工具包,包含 KDE 所使用的 Qt、GNOME 所使用的 GTK+。 因此應用程式會依其開發時所選用的視窗元件工具包而有不同的外觀。 @@ -7064,12 +7067,12 @@ 在 FreeBSD,Xorg 可透過套件或 Port 來安裝。 - 要從 Port 套件集編譯與安裝: + 要從 Port 套件集編譯與安裝: # cd /usr/ports/x11/xorg # make install clean - 使用 Binary 套件安裝快速,但可用的自訂選項較少: + 使用 Binary 套件安裝快速,但可用的自訂選項較少: # pkg install xorg @@ -7101,20 +7104,20 @@ - Xorg 曾經在電腦使用過,可先將現有的設定檔重新命名或移除: + Xorg 曾經在電腦使用過,可先將現有的設定檔重新命名或移除: # mv /etc/X11/xorg.conf ~/xorg.conf.etc # mv /usr/local/etc/X11/xorg.conf ~/xorg.conf.localetc - 加入要執行 Xorg 的使用者到 videowheel 群組,以便在可用時能開啟 3D 加速。要加入使用者 jru 到任一個可用的群組: + 加入要執行 Xorg 的使用者到 videowheel 群組,以便在可用時能開啟 3D 加速。要加入使用者 jru 到任一個可用的群組: # pw groupmod video -m jru || pw groupmod wheel -m jru - 預設內含 TWM 視窗管理程式,啟動 Xorg 時便會啟動該視窗管理程式: + 預設內含 TWM 視窗管理程式,啟動 Xorg 時便會啟動該視窗管理程式: % startx @@ -7128,7 +7131,7 @@ 可加速影像處理的使用者群組 - 要存取 /dev/dri 需要允許顯示卡的 3D 加速功能,這通常只需要將要執行 X 的使用者加入 videowheel 群組。此處使用 pw8 來將使用者 slurms 加入 video 群組,若沒有 video 則會加入 wheel 群組: + 要存取 /dev/dri 需要允許顯示卡的 3D 加速功能,這通常只需要將要執行 X 的使用者加入 videowheel 群組。此處使用 pw8 來將使用者 slurms 加入 video 群組,若沒有 video 則會加入 wheel 群組: # pw groupmod video -m slurms || pw groupmod wheel -m slurms @@ -7138,7 +7141,7 @@ 當電腦顯示從 Console 切換到高螢幕解析度供 X 使用時,必須設定影像輸出模式。最近版本的 Xorg 使用了核心內部的系統來讓切換模式更有效率。較舊版的 FreeBSD 使用的 sc4 並不知到 KMS 系統的存在,這會導致關閉 X 之後即始仍在運作但系統 Console 卻呈現空白。較新版的 vt4 Console 可避免這個問題。 - 加入此行到 /boot/loader.conf 來開啟 vt4: + 加入此行到 /boot/loader.conf 來開啟 vt4 kern.vty=vt @@ -7175,7 +7178,7 @@ 3D 加速在大多數 Intel 顯示晶片都有支援,最新到 Ivy Bridge (HD Graphics 2500, 4000, 及 P4000) 包含 Iron Lake (HD Graphics) 與 Sandy Bridge (HD Graphics 2000)。 - 驅動程式名稱: intel + 驅動程式名稱:intel 參考文獻請至 @@ -7187,7 +7190,7 @@ Radeon 顯示卡支援 2D 及 3D 加速,最新到 HD6000 系列。 - 驅動程式名稱: radeon + 驅動程式名稱:radeon 參考文獻請至 @@ -7233,7 +7236,7 @@ 在檔案中設定影像驅動程式 - 要在設定檔設定使用 Intel 驅動程式: + 要在設定檔設定使用 Intel 驅動程式: 在單檔中選擇 <trademark class="registered">Intel</trademark> 影像驅動程式 @@ -7249,7 +7252,7 @@ 若有多張顯示卡,可取消註解 BusID identifier 然後設定為想要的顯示卡,顯示卡的 Bus ID 清單可以使用 pciconf -lv | grep -B3 display 取得。 - 要在設定檔設定使用 Radeon 驅動程式: + 要在設定檔設定使用 Radeon 驅動程式: 在單檔中選擇 Radeon 影像驅動程式 @@ -7262,7 +7265,7 @@ EndSection - 要在設定檔設定使用 VESA 驅動程式: + 要在設定檔設定使用 VESA 驅動程式: 在單檔中選擇 <acronym>VESA</acronym> 影像驅動程式 @@ -7275,7 +7278,7 @@ EndSection - 要設定 UEFIARM 電腦使用 scfb 驅動程式: + 要設定 UEFIARM 電腦使用 scfb 驅動程式: 在單檔中選擇 <literal>scfb</literal> 影像驅動程式 @@ -7304,7 +7307,7 @@ 使用 xrandr1 - 執行 xrandr1 不加任何參數可檢查影像輸出及已偵測到的顯示器模式清單: + 執行 xrandr1 不加任何參數可檢查影像輸出及已偵測到的顯示器模式清單: % xrandr Screen 0: minimum 320 x 200, current 3000 x 1920, maximum 8192 x 8192 @@ -7324,13 +7327,13 @@ 這個結果顯示 DVI-0 輸出被用來顯示解析度為 1920x1200 像素於更新頻率約 60 Hz 的畫面,未有顯示器連接到 DisplayPort-0HDMI-0 接頭。 - 可使用 xrandr1 來選擇任何其他的顯示模式。例如要切換為 1280x1024 於 60 Hz: + 可使用 xrandr1 來選擇任何其他的顯示模式。例如要切換為 1280x1024 於 60 Hz: % xrandr --mode 1280x1024 --rate 60 在筆記型電腦使用外部顯示輸出到投影機是常見的作業。 - 不同裝置間輸出接頭的類型與數量也不同,給每個輸出的名稱在不同驅動程式間也不同。在某些驅動程式稱為 HDMI-1 的輸出在其他驅動程式則可能稱為 HDMI1。因此第一個步驟是執行 xrandr1 列出所有可用的輸出: + 不同裝置間輸出接頭的類型與數量也不同,給每個輸出的名稱在不同驅動程式間也不同。在某些驅動程式稱為 HDMI-1 的輸出在其他驅動程式則可能稱為 HDMI1。因此第一個步驟是執行 xrandr1 列出所有可用的輸出: % xrandr Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192 @@ -7351,9 +7354,9 @@ HDMI1 disconnected (normal left inverted right x axis y axis) DP1 disconnected (normal left inverted right x axis y axis) - 已找到四個輸出: 內建面板的 LVDS1,外接的 VGA1, HDMI1 以及 DP1 接頭。 + 已找到四個輸出:內建面板的 LVDS1,外接的 VGA1, HDMI1 以及 DP1 接頭。 - 投影機已連接至 VGA1 輸出,現在使用 xrandr1 來設定該輸出到投影機 (原始解析度) 並加入額外的空間到桌面的右側: + 投影機已連接至 VGA1 輸出,現在使用 xrandr1 來設定該輸出到投影機 (原始解析度) 並加入額外的空間到桌面的右側: % xrandr --output VGA1 --auto --right-of LVDS1 @@ -7367,7 +7370,7 @@ 在檔案中設定螢幕解析度 - 在設定檔設定螢幕解析度為 1024x768: + 在設定檔設定螢幕解析度為 1024x768: 在單檔中設定螢幕解析度 @@ -7452,7 +7455,7 @@ 從鍵盤關閉 Xorg - X 可以使用組合鍵來關閉,預設並未設定組合鍵,因為該組合鍵與部份應用程式的鍵盤指令衝突。要開啟這個選項需要更改鍵盤 InputDevice 節: + X 可以使用組合鍵來關閉,預設並未設定組合鍵,因為該組合鍵與部份應用程式的鍵盤指令衝突。要開啟這個選項需要更改鍵盤 InputDevice 節: 開啟鍵盤離開 X 功能 @@ -7481,7 +7484,7 @@ 滑鼠按鍵 - 滑鼠的按鍵數可在 xorg.conf 的滑鼠 InputDevice 節設定,例如要設定按鍵數為 7: + 滑鼠的按鍵數可在 xorg.conf 的滑鼠 InputDevice 節設定,例如要設定按鍵數為 7: 設定滑鼠按鍵數 @@ -7506,11 +7509,11 @@ 設定檔可由 Xorg 根據偵測到的硬體產生,這個檔案對一開始自訂設定很有幫助。 - 產生 xorg.conf: + 產生 xorg.conf # Xorg -configure - 設定檔會儲存至 /root/xorg.conf.new,做任何需要的更改,然後使用以下指令測試該檔案: + 設定檔會儲存至 /root/xorg.conf.new,做任何需要的更改,然後使用以下指令測試該檔案: # Xorg -config /root/xorg.conf.new @@ -7537,16 +7540,16 @@ 由於 Xorg 內建的預設字型用在典型的桌面出版應用程式並不是很理想,大字型會呈現鋸齒狀邊緣,看起來很不專業,小字型幾乎完全看不清楚。不過,這裡有幾個免費高品質的 Type1 (PostScript) 字型可用,且能容易的在 Xorg 使用。例如,URW 字型集 (Times Roman, Helvetica, Palatino 及其他)。 Freefont 字型集 (x11-fonts/freefonts) 包含了更多的字型,但其中大部分是給圖形軟體如 GIMP 所使用的字型,並不能完全作為螢幕字型使用。此外,Xorg 可以簡單的設定使用 TrueType 字型。更多有關本主題的詳細資訊,請參考 X7 操作手冊或 - 要從 Port 套件集安裝上述的 Type1 字型集可執行以下指令: + 要從 Port 套件集安裝上述的 Type1 字型集可執行以下指令: # cd /usr/ports/x11-fonts/urwfonts # make install clean - 同樣的安裝方式也適用 Freefont 或其他字型集。要讓 X 伺服器偵測到這些新安裝的字型,可加入適當的設定到 X 伺服器設定檔 (/etc/X11/xorg.conf),內容為: + 同樣的安裝方式也適用 Freefont 或其他字型集。要讓 X 伺服器偵測到這些新安裝的字型,可加入適當的設定到 X 伺服器設定檔 (/etc/X11/xorg.conf),內容為: FontPath "/usr/local/share/fonts/urwfonts/" - 或者在 X session 的指令列執行: + 或者在 X session 的指令列執行: % xset fp+ /usr/local/share/fonts/urwfonts % xset fp rehash @@ -7569,16 +7572,16 @@ Load "freetype" - 現在要建立一個儲存 TrueType 字型的目錄 (例如,/usr/local/share/fonts/TrueType) 然後複製所有 TrueType 字型到這個目錄。要注意 TrueType 字型並無法直接取自 Apple MacXorg 使用的字型必須為 UNIX/MS-DOS/Windows 的格式。檔案複製到讓目錄之後,使用 mkfontdir 來建立 fonts.dir 來讓 X 字型繪製程式知道安裝了新的檔案。mkfontdir 可用套件的方式安裝: + 現在要建立一個儲存 TrueType 字型的目錄 (例如,/usr/local/share/fonts/TrueType) 然後複製所有 TrueType 字型到這個目錄。要注意 TrueType 字型並無法直接取自 Apple MacXorg 使用的字型必須為 UNIX/MS-DOS/Windows 的格式。檔案複製到讓目錄之後,使用 mkfontdir 來建立 fonts.dir 來讓 X 字型繪製程式知道安裝了新的檔案。mkfontdir 可用套件的方式安裝: # pkg install mkfontdir - 然後在目錄中建立 X 字型檔的索引: + 然後在目錄中建立 X 字型檔的索引: # cd /usr/local/share/fonts/TrueType # mkfontdir - 接著加入 TrueType 目錄到字型路徑。這個動作與 中所介紹的方式相同: + 接著加入 TrueType 目錄到字型路徑。這個動作與 中所介紹的方式相同: % xset fp+ /usr/local/share/fonts/TrueType % xset fp rehash @@ -7612,25 +7615,25 @@ 所有可在 /usr/local/share/fonts/~/.fonts/ 找到的 Xorg 字型均可在 Xft-aware 的應用程式使用反鋸齒的效果。大多最近的應用程式均為 Xft-aware 的,包括 KDE, GNOME 以及 Firefox - 要控制那一些字型要做反鋸齒或設定反鋸齒的屬性,需建立 /usr/local/etc/fonts/local.conf 檔案 (若檔案存在則編輯)。在這個檔案中可以調整 Xft 字型系統的數項進階功能,本章節僅介紹部份簡單的項目,要取得進一步資訊,可參考 fonts-conf5 + 要控制那一些字型要做反鋸齒或設定反鋸齒的屬性,需建立 /usr/local/etc/fonts/local.conf 檔案 (若檔案存在則編輯)。在這個檔案中可以調整 Xft 字型系統的數項進階功能,本章節僅介紹部份簡單的項目,要取得進一步資訊,請參考 fonts-conf5 XML - 這個檔案必須使用 XML 格式,小心文字大小寫,且要確定所有標籤均有正常結尾。檔案的開頭使用常見的 XML 檔首,接著為 DOCTYPE 定義,然後是 <fontconfig> 標籤: + 這個檔案必須使用 XML 格式,小心文字大小寫,且要確定所有標籤均有正常結尾。檔案的開頭使用常見的 XML 檔首,接著為 DOCTYPE 定義,然後是 <fontconfig> 標籤: <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> - 如同前面所提到的,所有在 /usr/local/share/fonts/~/.fonts/ 的字型均已在 Xft-aware 的應用程式做反鋸齒效果,若您想要加入除了上兩者以外的目錄,可加入下行設定到 /usr/local/etc/fonts/local.conf: + 如同前面所提到的,所有在 /usr/local/share/fonts/~/.fonts/ 的字型均可在 Xft-aware 的應用程式做反鋸齒效果,若您想要加入除了上兩者以外的目錄,可加入如下行設定到 /usr/local/etc/fonts/local.conf <dir>/path/to/my/fonts</dir> - 加入新字型及額外的新字型目錄之後,您應執行以下指令來重新建立字型快取: + 加入新字型及額外的新字型目錄之後,需重新建立字型快取: # fc-cache -f - 反鋸齒效果會讓文字的邊緣變模糊,這會讓非常小的文字更能閱讀且去除大型文字的 鋸齒,但套用在一般的文字可能會造成眼睛的疲勞。要排除小於 14 點的字型大小使用反鋸齒效果,可加入這些行: + 反鋸齒效果會讓文字的邊緣變模糊,這會讓非常小的文字更能閱讀且去除大型文字的 鋸齒,但套用在一般的文字可能會造成眼睛的疲勞。要排除小於 14 點的字型大小使用反鋸齒效果,可加入這些行: <match target="font"> <test name="size" compare="less"> @@ -7654,9 +7657,9 @@ spacing - 反鋸齒所產生的間距對於部份等寬字型並不適合,尤其是在使用 KDE 時會發生問題。可能的修正方式是強制字型的間距為 100,可加入以下行: + 反鋸齒所產生的間距對於部份等寬字型並不合適,尤其是在使用 KDE 時會成為一個問題。可能的修正方式是強制這類字型的間距為 100,可加入以下行: - <match target="pattern" name="family"> + <match target="pattern" name="family"> <test qual="any" name="family"> <string>fixed</string> </test> @@ -7673,7 +7676,7 @@ </edit> </match> - (這會設定等寬字型的其他常用名稱為 "mono"),然後加入: + (這會設定等寬字型的其他常用名稱為 "mono"),然後加入: <match target="pattern" name="family"> <test qual="any" name="family"> @@ -7684,7 +7687,7 @@ </edit> </match> - 部份字型,如 Helvetica,在使用反鋸齒時可能會發生問題,通常會呈現像垂直切成兩半的字型,最差還可能會導致應用程式當掉。要避免這個問題,可考慮加入以下設定到 local.conf: + 部份字型,如 Helvetica,在使用反鋸齒時可能會發生問題,通常會呈現像垂直切成兩半的字型,最差還可能會導致應用程式當掉。要避免這個問題,可考慮加入以下設定到 local.conf <match target="pattern" name="family"> <test qual="any" name="family"> @@ -7695,17 +7698,20 @@ </edit> </match> - 編輯 local.conf 完之後,請確認有使用 </fontconfig> 標籤結尾,若沒使用會讓您的更改直接被忽略。 + 編輯 local.conf 完之後,請確認有使用 </fontconfig> 標籤結尾,若沒有使用會讓所做的更改被忽略。 - 最後,使用者可以透過個人的 .fonts.conf 檔案來加入自己的設定。要加入個人設定,每位使用者只需簡單的建立 ~/.fonts.conf,這個檔案也同樣需要為 XML 格式。 + Users can add personalized settings by creating their own + ~/.config/fontconfig/fonts.conf. This + file uses the same XML format described + above. LCD screen Fonts LCD screen - 最後一點: 若有使用 LCD 螢幕,可能會想要使用子像素取樣 (Sub-pixel sampling),這基本上會分開處理 (水平分隔) 紅、綠、藍色彩組成來提高垂直解析度,結果可能是無法預料的。要開啟這個功能,加入下行到 local.conf 的任一處: + 最後一點:若有使用 LCD 螢幕,可能會想要使用子像素取樣 (Sub-pixel sampling),這基本上會分開處理 (水平分隔) 紅、綠、藍色彩組成來提高垂直解析度,結果可能是無法預料的。要開啟這個功能,加入下行到 local.conf 的任一處: - <match target="font"> + <match target="font"> <test qual="all" name="rgba"> <const>unknown</const> </test> @@ -7715,7 +7721,7 @@ </match> - 依據不同的顯示器類型,rgb 可能會需要更改為 bgr, vrgbvbgr: 可實驗看看然後看那一個效果最好。 + 依據不同的顯示器類型可能會需要將 rgb 更改為 bgr, vrgbvbgr:可實驗看看然後看那一個效果最好。 @@ -7743,7 +7749,7 @@ 設定 <application>XDM</application> - 要安裝 XDM 可使用 x11/xdm 套件或 Port。安裝完成之後,可設定 XDM 在開機時執行,只需編輯 /etc/ttys 中的此項目: + 要安裝 XDM 可使用 x11/xdm 套件或 Port。安裝完成之後,可設定 XDM 在開機時執行,只需編輯 /etc/ttys 中的此項目: ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure @@ -7812,7 +7818,7 @@ 預設只有同系統的使用者可以使用 XDM 登入。要開啟讓其他系統的使用者可連線到顯示伺服器,需編輯存取控制規則及開啟連線傾聽程式。 - 要設定 XDM 傾聽作何遠端的連線,在 /usr/local/lib/X11/xdm/xdm-config 中的 DisplayManager.requestPort 行前加上 ! 來註解該行: + 要設定 XDM 傾聽作何遠端的連線,在 /usr/local/lib/X11/xdm/xdm-config 中的 DisplayManager.requestPort 行前加上 ! 來註解該行: ! SECURITY: do not listen for XDMCP or Chooser requests ! Comment out this line if you want to manage X terminals with xdm @@ -7844,9 +7850,9 @@ GNOME GNOME - GNOME 是一個擁有友善使用者介面的的桌面環境,它包括用於啟動應用程式和顯示狀態的面板、一系列工具與應用程序及一套可讓應用程式更容易進行合作、相互一致的協定。更多有關 FreeBSD GNOME 的訊息可在http://www.FreeBSD.org/gnome 取得,該網站包含了有關在 FreeBSD 安裝、設定和管理 GNOME 的額外文件。 + GNOME 是一個擁有友善使用者介面的的桌面環境,它包括用於啟動應用程式和顯示狀態的面板、一系列工具與應用程序及一套可讓應用程式更容易進行合作、相互一致的協定。更多有關 FreeBSD GNOME 的訊息可在 http://www.FreeBSD.org/gnome 取得,該網站包含了有關在 FreeBSD 安裝、設定和管理 GNOME 的額外文件。 - 這套桌面環境可以從套件安裝: + 這套桌面環境可以從套件安裝: # pkg install gnome3 @@ -7859,26 +7865,26 @@ proc /proc procfs rw 0 0 - GNOME 使用了 D-Bus 以及 HAL 的 Message bus 與 Hardware abstraction。這兩個應用程式會隨著 GNOME 的相依一併自動安裝,但需要在 /etc/rc.conf 開啟,這樣在系統開機時才會啟動: + GNOME 使用了 D-Bus 以及 HAL 的 Message bus 與 Hardware abstraction。這兩個應用程式會隨著 GNOME 的相依一併自動安裝,但需要在 /etc/rc.conf 開啟,這樣在系統開機時才會啟動: dbus_enable="YES" hald_enable="YES" - 安裝完之後,需設定讓 Xorg 啟動 GNOME。最簡單的方法是開啟 GNOME Display Manager, GDM,該程式已做為 GNOME 套件或 Port 的一部份安裝了,可加入下行到 /etc/rc.conf 來開啟: + 安裝完之後,需設定讓 Xorg 啟動 GNOME。最簡單的方法是開啟 GNOME Display Manager, GDM,該程式已做為 GNOME 套件或 Port 的一部份安裝了,可加入下行到 /etc/rc.conf 來開啟: gdm_enable="YES" - 通常也會需要啟動所有的 GNOME 服務,可加入下行到 /etc/rc.conf: + 通常也會需要啟動所有的 GNOME 服務,可加入下行到 /etc/rc.conf gnome_enable="YES" GDM 則會在系統開機時自動啟動。 - 第二種啟動 GNOME 的方法是在設定完 ~/.xinitrc 後在指令列輸入 startx。若這個檔案已經存在,替換啟動目前視窗管理程式的那一行,改為啟動 /usr/local/bin/gnome-session。若檔案不存在,則使用以下指令建立一個: + 第二種啟動 GNOME 的方法是在設定完 ~/.xinitrc 後在指令列輸入 startx。若這個檔案已經存在,替換啟動目前視窗管理程式的那一行,改為啟動 /usr/local/bin/gnome-session。若檔案不存在,則使用以下指令建立一個: % echo "exec /usr/local/bin/gnome-session" > ~/.xinitrc - 第三種方法是使用 XDM 做為顯示管理程式,在這個方法需要建立一個可執行的 ~/.xsession: + 第三種方法是使用 XDM 做為顯示管理程式,在這個方法需要建立一個可執行的 ~/.xsession % echo "#!/bin/sh" > ~/.xsession % echo "exec /usr/local/bin/gnome-session" >> ~/.xsession @@ -7892,7 +7898,7 @@ KDE 是另一套易於使用的桌面環境。這個桌面環境提供了一致外觀的應用程式、標準化的選單和工具列、組合鍵、配色方案、國際化與集中、對話框導向的桌面設定。更多有關 KDE 可在 http://www.kde.org/ 取得。要取得 FreeBSD 特定的資訊,則可參考 http://freebsd.kde.org。 - 要安裝 KDE 套件,請輸入: + 要安裝 KDE 套件,請輸入: # pkg install x11/kde4 @@ -7906,24 +7912,24 @@ display manager - KDE 需要掛載 /proc。加入下行到 /etc/fstab 讓系統啟動時會自動掛載這個檔案系統: + KDE 需要掛載 /proc。加入下行到 /etc/fstab 讓系統啟動時會自動掛載這個檔案系統: proc /proc procfs rw 0 0 - KDE 使用了 D-Bus 以及 HAL 的 Message bus 與 Hardware abstraction。這兩個應用程式會隨著 KDE 的相依一併自動安裝,但需要在 /etc/rc.conf 開啟,這樣在系統開機時才會啟動: + KDE 使用了 D-Bus 以及 HAL 的 Message bus 與 Hardware abstraction。這兩個應用程式會隨著 KDE 的相依一併自動安裝,但需要在 /etc/rc.conf 開啟,這樣在系統開機時才會啟動: dbus_enable="YES" hald_enable="YES" - KDE 的安裝包含了 KDE Display Manager, KDM,要開啟這個顯示管理程式,需加入下行到 /etc/rc.conf: + KDE 的安裝包含了 KDE Display Manager, KDM,要開啟這個顯示管理程式,需加入下行到 /etc/rc.conf kdm4_enable="YES" - 第二種執行 KDE 的方法是在在指令列輸入 startx。要採用這個方式,需要加入下行到 ~/.xinitrc: + 第二種執行 KDE 的方法是在在指令列輸入 startx。要採用這個方式,需要加入下行到 ~/.xinitrc exec /usr/local/bin/startkde - 第三種啟動 KDE 的方式是透過 XDM,要使用這個方法需要建立一個可執行的 ~/.xsession 如下: + 第三種啟動 KDE 的方式是透過 XDM,要使用這個方法需要建立一個可執行的 ~/.xsession 如下: % echo "#!/bin/sh" > ~/.xsession % echo "exec /usr/local/bin/startkde" >> ~/.xsession @@ -7937,20 +7943,20 @@ Xfce 是以 GNOME 使用的 GTK +工具包做為基礎所開發的桌面環境,但是它更輕巧且提供了一種簡單、高效、易於使用的桌面。它可完全自訂設定、附有選單、Applet 及應用程式啟動器的主面板、提供檔案管理程式和音效管理程式並且可設定主題。由於它是快速、輕巧、高效的桌面環境,因此它非常適合有記憶體限制的較舊或較慢機器。更多有關 Xfce 的資訊可至 http://www.xfce.org 取得。 - 要安裝 Xfce 套件: + 要安裝 Xfce 套件: # pkg install xfce - 或者使用 Port 編譯: + 或者使用 Port 編譯: # cd /usr/ports/x11-wm/xfce4 # make install clean - 不像 GNOMEKDEXfce 並沒有自己的登入管理程式,要由指令列啟動 Xfce 需輸入 startx,在這之前需先加入其項目到 ~/.xinitrc: + 不像 GNOMEKDEXfce 並沒有自己的登入管理程式,要由指令列啟動 Xfce 需輸入 startx,在這之前需先加入其項目到 ~/.xinitrc % echo "exec /usr/local/bin/startxfce4 --with-ck-launch" > ~/.xinitrc - 另一種方式是使用 XDM,要設定這個方式需建立一個可執行的 ~/.xsession: + 另一種方式是使用 XDM,要設定這個方式需建立一個可執行的 ~/.xsession % echo "#!/bin/sh" > ~/.xsession % echo "exec /usr/local/bin/startxfce4 --with-ck-launch" >> ~/.xsession @@ -7974,11 +7980,11 @@ 知道您的顯示卡要使用那種驅動程式才是正確的之後,接下來的安裝程序跟安裝其他套件一樣簡單。 - 例如,要安裝最新的驅動程式: + 例如,要安裝最新的驅動程式: # pkg install x11/nvidia-driver - 驅動程式會建立一個需要在系統啟動時載入的核心模組,加入下行到 /boot/loader.conf: + 驅動程式會建立一個需要在系統啟動時載入的核心模組,加入下行到 /boot/loader.conf nvidia_load="YES" @@ -7986,13 +7992,13 @@ 要立即載入核心模組到執行中的核心可以下 kldload nvidia 指令,但是需要注意,若不是在開機時載入,某些 Xorg 版本會無法正常運作。因此編輯完 /boot/loader.conf 之後建議要重新開機。 - 核心模組載入之後,您只需要更改 xorg.conf 的其中一行來開啟專用的驅動程式: + 核心模組載入之後,您只需要更改 xorg.conf 的其中一行來開啟專用的驅動程式: - 找到 /etc/X11/xorg.conf 中的下行: + 找到 /etc/X11/xorg.conf 中的下行: Driver "nv" - 然後更改該行為: + 然後更改該行為: Driver "nvidia" @@ -8002,15 +8008,15 @@ 設定 xorg.conf 來啟動桌面特效 - 要開啟 Compiz Fusion 需要修改 /etc/X11/xorg.conf: + 要開啟 Compiz Fusion 需要修改 /etc/X11/xorg.conf - 加入以下 Section 來開啟合成特效: + 加入以下 Section 來開啟合成特效: Section "Extensions" Option "Composite" "Enable" EndSection - 找到 Screen section,長的應該如下所示: + 找到 Screen section,長的應該如下所示: Section "Screen" Identifier "Screen0" @@ -8018,19 +8024,19 @@ Monitor "Monitor0" ... - 然後加入以下兩行 (在Monitor 之後): + 然後加入以下兩行 (在Monitor 之後): DefaultDepth 24 Option "AddARGBGLXVisuals" "True" - 找到您欲使用的螢幕解析度所在的 Subsection,例如,您想要使用 1280x1024,則找到如下所示的 Section。若想要使用的解析度不在任何 Subsection 之中,您可以手動加入對應的項目: + 找到您欲使用的螢幕解析度所在的 Subsection,例如,您想要使用 1280x1024,則找到如下所示的 Section。若想要使用的解析度不在任何 Subsection 之中,您可以手動加入對應的項目: SubSection "Display" Viewport 0 0 Modes "1280x1024" EndSubSection - 桌面合成需要 24 bit 的色彩深度,更改上述 Subsection 為: + 桌面合成需要 24 bit 的色彩深度,更改上述 Subsection 為: SubSection "Display" Viewport 0 0 @@ -8038,14 +8044,14 @@ Modes "1280x1024" EndSubSection - 最後確認在 Module section 中已經載入 glxextmod 模組: + 最後確認在 Module section 中已經載入 glxextmod 模組: Section "Module" Load "extmod" Load "glx" ... - 前面所述的動作可以執行 x11/nvidia-xconfig 來自動完成 (使用 root) : + 前面所述的動作可以執行 x11/nvidia-xconfig 來自動完成 (使用 root): # nvidia-xconfig --add-argb-glx-visuals # nvidia-xconfig --composite @@ -8055,30 +8061,30 @@ 安裝與設定 Compiz Fusion - 安裝 Compiz Fusion 如同安裝其他套件一樣簡單: + 安裝 Compiz Fusion 如同安裝其他套件一樣簡單: # pkg install x11-wm/compiz-fusion - 安裝完成之後,開啟您的圖型化桌面,然後在終端機的畫面輸入以下指令 (使用一般使用者): + 安裝完成之後,開啟您的圖型化桌面,然後在終端機的畫面輸入以下指令 (使用一般使用者): % compiz --replace --sm-disable --ignore-desktop-hints ccp & % emerald --replace & - 由於您的視窗管理程式 (例如: Metacity,若您使用 GNOME) 會被替換成 Compiz Fusion,您的螢幕會閃爍幾秒。而 Emerald 會處理視窗的裝飾 (例如: 關閉、最小化、最大化按鈕、標題列及其他相關)。 + 由於您的視窗管理程式 (例如:Metacity,若您使用 GNOME) 會被替換成 Compiz Fusion,您的螢幕會閃爍幾秒。而 Emerald 會處理視窗的裝飾 (例如:關閉、最小化、最大化按鈕、標題列及其他相關)。 - 您或許可以將這些指令改寫成較小的 Script 然後在啟動時自動執行 (加到 GNOME 桌面的 Sessions 中): + 您或許可以將這些指令改寫成較小的 Script 然後在啟動時自動執行 (加到 GNOME 桌面的 Sessions 中): #! /bin/sh compiz --replace --sm-disable --ignore-desktop-hints ccp & emerald --replace & - 儲存這個 Script 到您的家目錄所在位置,例如 start-compiz,然後讓該檔案可以執行: + 儲存這個 Script 到您的家目錄所在位置,例如 start-compiz,然後讓該檔案可以執行: % chmod +x ~/start-compiz 接著使用 GUI 將該檔案加入啟動程式 Startup Programs (位於 GNOME 桌面的系統 System, 偏好設定 Preferences, 工作階段 Sessions)。 - 要選擇所想使用的特效與相關設定,可執行 (一樣使用一般使用者) Compiz Config 設定管理程式 Compiz Config Settings Manager: + 要選擇所想使用的特效與相關設定,可執行 (一樣使用一般使用者) Compiz Config 設定管理程式 Compiz Config Settings Manager % ccsm @@ -8094,16 +8100,16 @@ 疑難排解 - 若滑鼠無法使用,您將需要做第一次設定方可繼續。在最近的 Xorg 版本,使用自動偵測裝置會忽略在 xorg.conf 中的 InputDevice section。要採用舊的方式,需在此檔案加入下行到 ServerLayoutServerFlags section: + 若滑鼠無法使用,您將需要做第一次設定方可繼續。在最近的 Xorg 版本,使用自動偵測裝置會忽略在 xorg.conf 中的 InputDevice section。要採用舊的方式,需在此檔案加入下行到 ServerLayoutServerFlags section: Option "AutoAddDevices" "false" - 輸入裝置便可如先前版本一樣設定,連同其他所需的選項 (如: 切換鍵盤配置)。 + 輸入裝置便可如先前版本一樣設定,連同其他所需的選項 (如:切換鍵盤配置)。 如同前面有說明過,hald Daemon 預設會自動偵測您的鍵盤,因此您的鍵盤配置或型號可能不正確,桌面環境如 GNOME, KDEXfce 會提供設定鍵盤的工具。即使如此,還是有可能透過 setxkbmap1 工具或 hald 的設定規則的協助來直接設定鍵盤屬性。 - 舉例來說,若有人想要使用 PC 102 鍵的鍵盤,採用法語 (French) 配置,我們便需要建立一個給 hald 的鍵盤設定檔,名稱為 x11-input.fdi,然後儲存到 /usr/local/etc/hal/fdi/policy 目錄。這個檔案中應要有以下幾行: + 舉例來說,若有人想要使用 PC 102 鍵的鍵盤,採用法語 (French) 配置,我們便需要建立一個給 hald 的鍵盤設定檔,名稱為 x11-input.fdi,然後儲存到 /usr/local/etc/hal/fdi/policy 目錄。這個檔案中應要有以下幾行: <?xml version="1.0" encoding="iso-8859-1"?> <deviceinfo version="0.2"> @@ -8119,7 +8125,7 @@ 您會需要重新啟動您的機器來讓 hald 讀取這個檔案。 - 也是可以從 X 終端機或 Script 下指令來做同樣的設定: + 也是可以從 X 終端機或 Script 下指令來做同樣的設定: % setxkbmap -model pc102 -layout fr @@ -8129,7 +8135,7 @@ Xorg tuning - 現在可以開始調整 xorg.conf.new 設定檔,在文字編輯器如 emacs1ee1 開啟該設定檔。若顯示器是不支援自動偵測同步頻率 (Sync frequency) 的舊或特殊的型號,同步頻率的設定可以手動加到 xorg.conf.new"Monitor" section: + 現在可以開始調整 xorg.conf.new 設定檔,在文字編輯器如 emacs1ee1 開啟該設定檔。若顯示器是不支援自動偵測同步頻率 (Sync frequency) 的舊或特殊的型號,同步頻率的設定可以手動加到 xorg.conf.new"Monitor" section: Section "Monitor" Identifier "Monitor0" @@ -8141,7 +8147,7 @@ 多數顯示器都支援自動偵測同步頻率,並不需要手動設定這些數值。對於那些不支援自動偵測的顯示器,請輸入由製造商提供的數值來避免損壞顯示器。 - X 允許在支援的顯示器使用 DPMS (Energy Star) 功能,xset1 程式可以控制逾時並可強制待機 (Standby)、暫停 (Suspend) 或關閉 (Off) 模式。若您想要為您的顯示器開啟 DPMS 功能,您需要加入下行到顯示器 (Monitor) 的 Section: + X 允許在支援的顯示器使用 DPMS (Energy Star) 功能,xset1 程式可以控制逾時並可強制待機 (Standby)、暫停 (Suspend) 或關閉 (Off) 模式。若您想要為您的顯示器開啟 DPMS 功能,您需要加入下行到顯示器 (Monitor) 的 Section: Option "DPMS" @@ -8149,7 +8155,7 @@ xorg.conf - 在編輯器還未關閉 xorg.conf.new 設定檔前,選擇想要使用的預設解析度及色彩深度。這些項目可在 "Screen" section 定義: + 在編輯器還未關閉 xorg.conf.new 設定檔前,選擇想要使用的預設解析度及色彩深度。這些項目可在 "Screen" section 定義: Section "Screen" Identifier "Screen0" @@ -8168,7 +8174,7 @@ 最後,儲存設定檔並使用測試模式來測試上述的設定。 - 有一個工具可以協助您診斷問題,那就是 Xorg 記錄檔。該記錄檔中記錄了 Xorg 連接的每個裝置的資訊。Xorg 記錄檔名稱的格式為 /var/log/Xorg.0.log,確切的記錄檔名會可能從 Xorg.0.logXorg.8.log 以此類推。 + 有一個工具可以協助您診斷問題,那就是 Xorg 日誌檔。該日誌檔中記錄了 Xorg 連接的每個裝置的資訊。Xorg 記錄檔名稱的格式為 /var/log/Xorg.0.log,確切的記錄檔名會可能從 Xorg.0.logXorg.8.log 以此類推。 若一且運作正常,設定檔需要安裝到 Xorg1 會尋找的常用設定檔位置,通常是 /etc/X11/xorg.conf/usr/local/etc/X11/xorg.conf @@ -8196,9 +8202,9 @@ widescreen flatpanel configuration - 此章節會需要有一些進階的設定知識,若嘗試使用上述的標準設定工具仍無法產生可運作的設定,在記錄檔中應有足夠的資訊可運用來讓顯示卡運作。在此會需要使用文字編輯器。 + 此章節會需要有一些進階的設定知識,若嘗試使用上述的標準設定工具仍無法產生可運作的設定,在日誌檔中應有足夠的資訊可運用來讓顯示卡運作。在此會需要使用文字編輯器。 - 目前使用寬螢幕 (WSXGA, WSXGA+, WUXGA, WXGA, WXGA+, et.al.) 格式支援的 16:10 及 10:9 格式或其他的寬高比可會有問題。例如一些 16:10 寬高比常見的螢幕解析度: + 目前使用寬螢幕 (WSXGA, WSXGA+, WUXGA, WXGA, WXGA+, et.al.) 格式支援的 16:10 及 10:9 格式或其他的寬高比可會有問題。例如一些 16:10 寬高比常見的螢幕解析度: @@ -8222,7 +8228,7 @@ - 在某些時候,可以簡單的將這些要使用的解析度以 Mode 加入到 Section "Screen": + 在某些時候,可以簡單的將這些要使用的解析度以 Mode 加入到 Section "Screen": Section "Screen" Identifier "Screen0" @@ -8238,7 +8244,7 @@ Xorg 能夠從寬螢幕設定取得解析度資訊 (透過 I2C/DDC),因此能夠知道螢幕能處理的頻率及解析度。 - 若驅動程式中不存在那些螢幕能處理的 ModeLines,則需要給 Xorg 一點提示。透過 /var/log/Xorg.0.log 可以取得足夠的資訊來手動建立可運作的 ModeLine。只需要在記錄檔中找到類似以下的訊息: + 若驅動程式中不存在那些螢幕能處理的 ModeLines,則需要給 Xorg 一點提示。透過 /var/log/Xorg.0.log 可以取得足夠的資訊來手動建立可運作的 ModeLine。只需要在日誌檔中找到類似以下的訊息: (II) MGA(0): Supported additional Video Mode: (II) MGA(0): clock: 146.2 MHz Image Size: 433 x 271 mm @@ -8246,11 +8252,11 @@ (II) MGA(0): v_active: 1050 v_sync: 1053 v_sync_end 1059 v_blanking: 1089 v_border: 0 (II) MGA(0): Ranges: V min: 48 V max: 85 Hz, H min: 30 H max: 94 kHz, PixClock max 170 MHz - 這些資訊稱作 EDID 資訊,使用 EDIT 資訊建立 ModeLine 只需要將數據使用正確的順序放入: + 這些資訊稱作 EDID 資訊,使用 EDIT 資訊建立 ModeLine 只需要將數據使用正確的順序放入: ModeLine <name> <clock> <4 horiz. timings> <4 vert. timings> - 將資訊放入之後,本例中 Section "Monitor" 中的 ModeLine 會看起來像這樣: + 將資訊放入之後,本例中 Section "Monitor" 中的 ModeLine 會看起來像這樣: Section "Monitor" Identifier "Monitor1" @@ -8283,7 +8289,7 @@ - 若您檢查 /var/log/Xorg.0.log,您可能可以找到當 X 啟動時所發生的錯誤訊息。最常發生的錯誤會是: + 若您檢查 /var/log/Xorg.0.log,您可能可以找到當 X 啟動時所發生的錯誤訊息。最常發生的錯誤會是: (EE) NVIDIA(0): Failed to initialize the GLX module; please check in your X (EE) NVIDIA(0): log file that the GLX module has been loaded in your X @@ -8462,7 +8468,7 @@ Firefox 與 <trademark>Java</trademark> 附加元件 - 安裝 Firefox 並不包含 Java 支援,雖然如此 java/icedtea-web 提供了免費的網頁瀏覽器附加元件來執行 Java applet,此附加元件可以用 Binary 套件安裝或者自 Port 編譯: + Firefox 的安裝並不包含 Java 支援,雖然如此 java/icedtea-web 提供了免費的網頁瀏覽器附加元件來執行 Java applet,此附加元件可以用 Binary 套件安裝或者自 Port 編譯: # cd /usr/ports/java/icedtea-web # make install clean @@ -8471,9 +8477,7 @@ 安裝完成時,啟動 firefox,在網址列輸入 about:plugins 並按 Enter 鍵。 會出現一個頁面列出已安裝的附加元件。 Java 附加元件應該會列在其中。 - If the browser is unable to find the plugin, each user - will have to run the following command and relaunch the - browser: + 若瀏覽器無法找到附加元件,每位使用者則須執行以下指令並重新執行瀏覽器: % ln -s /usr/local/lib/IcedTeaPlugin.so \ $HOME/.mozilla/plugins/ @@ -8518,23 +8522,18 @@ Firefox 與 Swfdec <trademark class="registered">Flash</trademark> 附加元件 - Swfdec is a decoder and - renderer for Flash animations. - Swfdec-Mozilla is a plugin for - Firefox browsers that uses the - Swfdec library for playing SWF files. + SwfdecFlash 動畫的解碼程式及繪製程式。Swfdec-Mozilla 是供 Firefox 瀏覽器使用的附加元件,可使用 Swfdec 程式庫來播放 SWF 檔案。 要安裝套件可: # pkg install swfdec-plugin - If the package is not available, compile and install it - from the Ports Collection: + 若無套件可用,可自 Port 套件集編譯並安裝該附加元件: # cd /usr/ports/www/swfdec-plugin # make install clean - Restart the browser to activate this plugin. + 重新啟動瀏覽器來啟動此附加元件。 @@ -8596,48 +8595,29 @@ Chromium - Chromium is an open source - browser project that aims to build a safer, faster, and more - stable web browsing experience. - Chromium features tabbed browsing, - popup blocking, extensions, and much more. - Chromium is the open source project - upon which the Google Chrome web browser is based. + Chromium 是一個開放源始碼的瀏覽器計劃,該計劃的目標是要建立一個安全、快速且更穩定的網頁瀏覽體驗。Chromium 的功能有頁籤式瀏覽、彈出視窗封鎖、擴充套件等等。Chromium 也是 Google Chrome 網頁瀏覽器所採用的基礎。 - Chromium can be installed as a - package by typing: + Chromium 可以使用套件來安裝,只要輸入: # pkg install chromium - Alternatively, Chromium can be - compiled from source using the Ports Collection: + 或者可從 Port 套件集的原始碼編譯 Chromium # cd /usr/ports/www/chromium # make install clean - The executable for Chromium - is /usr/local/bin/chrome, not - /usr/local/bin/chromium. + Chromium 的執行檔為 /usr/local/bin/chrome,並非 /usr/local/bin/chromium Chromium 與 <trademark>Java</trademark> 附加元件 - The installation of - Chromium does not include Java - support. To install Java plugin support, follow the - instructions in . - - Once Java support is installed, start - Chromium and enter - about:plugins in the address bar. - IcedTea-Web should be listed as one of the installed - plugins. - - If Chromium does not display - the IcedTea-Web plugin, run the following commands and - restart the web browser: + Chromium 的安裝並不包含 Java 的支援。要安裝 Java 附加元件支援,請依照 的指示操作。 + + Java 支援安裝完成後,啟動 Chromium 然後在網址列輸入 about:plugins。已安裝的附件元件其中之一應該會有 IcedTea-Web。 + + Chromium 未顯示 IcedTea-Web 為附件元件,請執行以下指令然後重新啟動網頁瀏覽器: # mkdir -p /usr/local/share/chromium/plugins # ln -s /usr/local/lib/IcedTeaPlugin.so \ @@ -8647,12 +8627,7 @@ Chromium 與 <trademark class="registered">Adobe</trademark> <trademark class="registered">Flash</trademark> 附加元件 - Configuring Chromium and - Adobe Flash is similar to the instructions in - . No additional - configuration should be necessary, since - Chromium is able to use some - plugins from other browsers. + 設定 ChromiumAdobe Flash 中的操作相似,無須額外的設定,因 Chromium 能夠使用部份來自其他瀏覽器的附加元件。 @@ -8726,25 +8701,13 @@ Calligra - The KDE desktop environment includes - an office suite which can be installed separately from - KDE. - Calligra includes standard - components that can be found in other office suites. - Words is the word processor, - Sheets is the spreadsheet program, - Stage manages slide presentations, - and Karbon is used to draw - graphical documents. - - In FreeBSD, editors/calligra can be - installed as a package or a port. To install the - package: + KDE 桌面環境中內含辦公軟體可以與 KDE 分開安裝。Calligra 中也有可在其他辦公軟體中找到的標準元件,如 Words 是文件處理程式、Sheets 是試算表程式、Stage 可管理投影片以及 Karbon 用來繪製圖型文件。 + + 在 FreeBSD 中 editors/calligra 可以使用套件或 Port 的方式安裝,要使用套件安裝: # pkg install calligra - If the package is not available, use the Ports Collection - instead: + 若沒有可用的套件,可改使用 Port 套件集安裝: # cd /usr/ports/editors/calligra # make install clean @@ -8847,64 +8810,29 @@ LibreOffice - LibreOffice is a free software - office suite developed by documentfoundation.org. - It is compatible with other major office suites and available - on a variety of platforms. It is a rebranded fork of - Apache OpenOffice and includes - applications found in a complete office productivity suite: - a word processor, spreadsheet, presentation manager, drawing - program, database management program, and a tool for creating - and editing mathematical formulæ. It is available in - a number of different languages and internationalization has - been extended to interfaces, spell checkers, and - dictionaries. - - The word processor of - LibreOffice uses a native XML file - format for increased portability and flexibility. The - spreadsheet program features a macro language which can be - interfaced with external databases. - LibreOffice is stable and runs - natively on Windows, Linux, FreeBSD, and Mac OS X. - More information about LibreOffice - can be found at libreoffice.org. + LibreOffice 是一套自由的辦公軟體由 documentfoundation.org 所開發。它可相容其他主流的辦公軟體以及可在各種平台上使用。它是 Apache OpenOffice 品牌重塑後的分支,含有可在完整辦公生產力軟體中找到的應用程式:文件處理程式、試算表、簡報管理程式、繪圖程式、資料庫管理程式以及建立與編輯數學公式的工具。它也支援數種語言與國際化一直延伸到介面、拼字檢查程式與字典。 + + LibreOffice 的文件處理程式使用了原生的 XML 檔案格式來增加可攜性與彈性,試算表程式支援可與外部資料庫連接的巨集語言。LibreOffice 非常穩定且可直接在 Windows, Linux, FreeBSD 以及 Mac OS X 上執行。更多有關 LibreOffice 的資訊可在 libreoffice.org 找到。 - To install the English version of the - LibreOffice package: + 要安裝英文版本的 LibreOffice 套件: # pkg install libreoffice - The editors category (freebsd.org/ports/editors.html) - of the Ports Collection contains several localizations for - LibreOffice. When installing a - localized package, replace libreoffice - with the name of the localized package. + Port 套件集的編輯器分類 (freebsd.org/ports/editors.html) 中含有數個 LibreOffice 的語系。安裝在地化套件時,請替換 libreoffice 為在地化套件的名稱。 - Once the package is installed, type the following command - to run LibreOffice: + 套件安裝之後,輸入以下指令來執行 LibreOffice % libreoffice - During the first launch, some questions will be asked - and a .libreoffice folder will be created - in the user's home directory. - - If the desired LibreOffice - package is not available, compiling the port is still an - option. However, this requires a lot of disk space and a - fairly long time to compile. This example compiles the - English version: + 第一次啟動的過程中會詢問一些問題並在使用者的家目錄建立 .libreoffice 資料夾。 + + 若找不到想使用的 LibreOffice 套件,也可從 Port 編譯,但這會要大量的磁碟空間及漫長的時間編譯。以下例子示範編譯英文版本: # cd /usr/ports/editors/libreoffice # make install clean - To build a localized version, - cd into the port directory of - the desired language. Supported languages can be found - in the editors category (freebsd.org/ports/editors.html) - of the Ports Collection. + 要編譯在地化版本,則需 cd 進入想要的語言 Port 目錄。支援的語言可在 Port 套件集的編輯器分類 (freebsd.org/ports/editors.html) 中找到。 @@ -8912,10 +8840,7 @@ 文件閱覽程式 - Some new document formats have gained popularity since - the advent of UNIX and the viewers they require may not be - available in the base system. This section demonstrates how to - install the following document viewers: + UNIX 出現之後,有一些新的文件格式才越來越熱門,這些文件所需的檢視程式可能並不在基礎系統中。本節將示範如何安裝以下文件檢視程式: @@ -9047,17 +8972,9 @@ viewing - ePDFView is a lightweight - PDF document viewer that only uses the - Gtk+ and - Poppler libraries. It is currently - under development, but already opens most - PDF files (even encrypted), save copies of - documents, and has support for printing using - CUPS. + ePDFView 是一套小巧的 PDF 文件檢視程式,只使用了 Gtk+Poppler 程式庫。它目前還在開發當中,但已經可以開啟大部份 PDF 檔案 (甚至是加密過的)、儲存文件複本以及支援使用 CUPS 來列印。 - To install ePDFView as a - package: + 要以套件安裝 ePDFView # pkg install epdfview @@ -9078,15 +8995,9 @@ viewing - Okular is a universal document - viewer based on KPDF for - KDE. It can open many document - formats, including PDF, PostScript, DjVu, - CHM, XPS, and - ePub. + Okular 是一套通用的文件檢視程式,以 KDEKPDF 為基礎。它可以開啟許多種文件格式,包含了 PDF, PostScript, DjVu, CHM, XPS 以及 ePub。 - To install Okular as a - package: + 要以套件安裝 Okular # pkg install okular @@ -9147,7 +9058,7 @@ GnuCash - GnuCashGNOME 團隊努力成果中的一部分, GNOME 團隊主要提供親切而強大的桌面應用程式給終端使用者。使用 GnuCash 可以持續追蹤記錄收入與花費、銀行帳戶以及股票證券等。 它的特性是介面直覺但功能仍非常專業。 + GnuCashGNOME 團隊努力成果中的一部分, GNOME 團隊主要提供親切而強大的桌面應用程式給終端使用者。使用 GnuCash 可以持續追蹤收入與花費、銀行帳戶以及股票證券等。 它的特性是介面直覺但功能仍非常專業。 GnuCash 提供了智慧的計數器、多階層帳戶系統以及快速鍵及自動完成功能。 它也能分開單一的報表至數個詳細的部份。 GnuCash 也能夠匯入及合併 Quicken QIF 檔案。 它也能處理大部分國際的日期及通用貨幣之格式。 @@ -9188,19 +9099,9 @@ 試算表 KMyMoney - KMyMoney is a personal finance - application created by the KDE - community. KMyMoney aims to - provide the important features found in commercial personal - finance manager applications. It also highlights ease-of-use - and proper double-entry accounting among its features. - KMyMoney imports from standard - Quicken QIF files, tracks - investments, handles multiple currencies, and provides a - wealth of reports. + KMyMoney 是一套個人財務應用程式,由 KDE 社群所開發。KMyMoney 的目標是提供可在商業個人財務管理應用程式中找到的重要功能,它也強調簡單易用及其功能間採用合適的複式記帳。KMyMoney 可從標準 Quicken QIF 檔案匯入資料、追蹤投資、處理多種貨幣並提供財務報表。 - To install KMyMoney as a - package: + 要以套件安裝 KMyMoney # pkg install kmymoney-kde4 @@ -10344,7 +10245,7 @@ TV cards - 電視卡(TV card)可以讓您用電腦來看無線、有線電視節目。許多卡都是透過 RCA 或 S-video 輸入端子來接收視訊,而且有些卡還可接收 FM 廣播的功能。 + 電視卡 (TV card) 可以讓您用電腦來看無線、有線電視節目。許多卡都是透過 RCA 或 S-video 輸入端子來接收視訊,而且有些卡還可接收 FM 廣播的功能。 FreeBSD 可透過 bktr4 驅動程式,來支援 PCI 介面的電視卡,只要這些卡使用的是 Brooktree Bt848/849/878/879 或 Conexant CN-878/Fusion 878a 視訊擷取晶片。此外,要再確認哪些卡上所附的選台功能是否有支援,可以參考 bktr4 說明,以查看所支援的硬體清單。 @@ -10845,28 +10746,18 @@ - Before building a custom kernel, consider the reason for - doing so. If there is a need for specific hardware support, - it may already exist as a module. - - Kernel modules exist in /boot/kernel - and may be dynamically loaded into the running kernel using - kldload8. Most kernel drivers have a loadable module and - manual page. For example, the ath4 wireless Ethernet - driver has the following information in its manual page: + 在編譯自訂核心之前,請思考要這麼做的原因,若是因為需要特定硬體的支援,很可能已有既有的模組可以使用。 + + 核心模組會放在 /boot/kernel 並且可使用 kldload8 動態載入到執行中的核心。大部份的核心驅動程式都有可載入的模組與操作手冊。例如 ath4 無線乙太網路驅動程式在其操作手冊有以下資訊: Alternatively, to load the driver as a module at boot time, place the following line in loader.conf5: if_ath_load="YES" - Adding if_ath_load="YES" to - /boot/loader.conf will load this module - dynamically at boot time. - - In some cases, there is no associated module in - /boot/kernel. This is mostly true for - certain subsystems. + 加入 if_ath_load="YES"/boot/loader.conf 會於開機期間自動載入這個模組。 + + 部份情況在 /boot/kernel 會沒有相關的模組,這對於某些子系統大多是真的。 @@ -11942,7 +11833,7 @@ - 建立一個目錄來儲存要被列印的檔案: + 建立一個目錄來儲存要被列印的檔案: # mkdir -p /var/spool/lpd/lp # chown daemon:daemon /var/spool/lpd/lp @@ -11950,7 +11841,7 @@ - root 建立 /etc/printcap 內容如下: + root 建立 /etc/printcap 內容如下: lp:\ :lp=/dev/unlpt0:\ @@ -11961,13 +11852,13 @@ - 此行是針對連接到 USB 埠的印表機: + 此行是針對連接到 USB 埠的印表機: - 連接到並列或 印表器 (Printer) 埠的印表機要使用: + 連接到並列或 印表器 (Printer) 埠的印表機要使用: :lp=/dev/lpt0:\ - 直接連接到網路的印表機要使用: + 直接連接到網路的印表機要使用: :lp=:rm=network-printer-name:rp=raw:\ @@ -11977,18 +11868,18 @@ - 編輯 /etc/rc.conf 加入下行來開啟 lpd: + 編輯 /etc/rc.conf 加入下行來開啟 lpd lpd_enable="YES" - 啟動服務: + 啟動服務: # service lpd start Starting lpd. - 測試列印: + 測試列印: # printf "1. This printer can print.\n2. This is the second line.\n" | lpr @@ -12018,7 +11909,7 @@ USB 印表機可以連接到電腦上任何可用的 USB 埠。 - 當 FreeBSD 偵測到 USB 印表機,會建立兩個裝置項目: /dev/ulpt0 以及 /dev/unlpt0,傳送到兩者任一裝置的資料都會被轉發到印表機。在每個列印工作完成後 ulpt0 便會重設 USB 埠,重設 USB 埠可能會在部份印表機造成問題,因此通常可以改使用 unlpt0 裝置。unlpt0 不會重設 USB 埠。 + 當 FreeBSD 偵測到 USB 印表機,會建立兩個裝置項目:/dev/ulpt0 以及 /dev/unlpt0,傳送到兩者任一裝置的資料都會被轉發到印表機。在每個列印工作完成後 ulpt0 便會重設 USB 埠,重設 USB 埠可能會在部份印表機造成問題,因此通常可以改使用 unlpt0 裝置。unlpt0 不會重設 USB 埠。 @@ -12076,7 +11967,7 @@ ASCII - ASCII 文字是傳送資料到印表機最簡單的方式,一個字元對應一個要列印的文字: 資料中的 A 會列印一個 A 在頁面。可以使用的格式非常少,沒有辦法選擇字型或者比例間距。強迫使用簡單的純 ASCII 為的是讓文字可以直接從電腦列印只需一點或甚至不需要編碼或轉譯,列印的結果可直接對應傳送的內容。 + ASCII 文字是傳送資料到印表機最簡單的方式,一個字元對應一個要列印的文字:資料中的 A 會列印一個 A 在頁面。可以使用的格式非常少,沒有辦法選擇字型或者比例間距。強迫使用簡單的純 ASCII 為的是讓文字可以直接從電腦列印只需一點或甚至不需要編碼或轉譯,列印的結果可直接對應傳送的內容。 部份便宜印表機無法列印純 ASCII 文字,這讓這些印表機較難設定。 @@ -12173,11 +12064,11 @@ 直接列印 - 對於偶爾列印,檔案可以直接傳送到印表機裝置,無需做任何設定。例如,要傳送一個名稱為 sample.txt 的檔案到 USB 印表機: + 對於偶爾列印,檔案可以直接傳送到印表機裝置,無需做任何設定。例如,要傳送一個名稱為 sample.txt 的檔案到 USB 印表機: # cp sample.txt /dev/unlpt0 - 要直接使用網路印表機列印需看該印表機支援的功能,但大多數會接受埠號 9100 的列印作業,可使用 nc1 來完成。要使用 DNS 主機名稱為 netlaser 的印表機列印與上述相同的檔案可: + 要直接使用網路印表機列印需看該印表機支援的功能,但大多數會接受埠號 9100 的列印作業,可使用 nc1 來完成。要使用 DNS 主機名稱為 netlaser 的印表機列印與上述相同的檔案可: # nc netlaser 9100 < sample.txt @@ -12192,13 +12083,13 @@ 初始設定 - 建立要用來儲存列印工作的目錄、設定擁有關係以及權限來避免其他使用者可以檢視這些檔案的內容: + 建立要用來儲存列印工作的目錄、設定擁有關係以及權限來避免其他使用者可以檢視這些檔案的內容: # mkdir -p /var/spool/lpd/lp # chown daemon:daemon /var/spool/lpd/lp # chmod 770 /var/spool/lpd/lp - 印表機會定義在 /etc/printcap,每台印表機項目所包含的詳細資料有名稱、連接的接頭以及各種其他設定。建立 /etc/printcap 使用以下內容: + 印表機會定義在 /etc/printcap,每台印表機項目所包含的詳細資料有名稱、連接的接頭以及各種其他設定。建立 /etc/printcap 使用以下內容: lp:\ :lp=/dev/unlpt0:\ @@ -12240,11 +12131,11 @@ 網路 - 針對支援 LPD 通訊協定的印表機: + 針對支援 LPD 通訊協定的印表機: :lp=:rm=network-printer-name:rp=raw:\ - 針對支援使用埠號 9100 列印的印表機: + 針對支援使用埠號 9100 列印的印表機: :lp=9100@network-printer-name:\ @@ -12275,21 +12166,21 @@ - 記錄此印表機回報錯誤的記錄檔。 + 回報此印表機的錯誤的日誌檔。 - 在建立 /etc/printcap 之後,使用 chkprintcap8 測試印表機是否有錯誤: + 在建立 /etc/printcap 之後,使用 chkprintcap8 測試印表機是否有錯誤: # chkprintcap 在繼續之前修正任何回報的問題。 - 開啟 /etc/rc.conf 中的 lpd8: + 開啟 /etc/rc.conf 中的 lpd8 lpd_enable="YES" - 啟動服務: + 啟動服務: # service lpd start @@ -12894,9 +12785,13 @@ Binary 相容性 Linux - FreeBSD 提供和 32 位元 Linux Binary 的相容性,允許使用者在 FreeBSD 不需要修改就可以安裝和執行大部份 32 位元 Linux Binary。 曾經有報告指出,在某些情況下,32 位元 Linux Binary 在 FreeBSD 的表現比在 Linux 好。 + FreeBSD 提供 Linux Binary 的相容性,允許使用者在 FreeBSD 系統上不需要修改就可以安裝和執行大部份的 Linux Binary。 曾經有報告指出,在某些情況下,Linux Binary 在 FreeBSD 的表現比在 Linux 好。 + + 然而,部份特定在 Linux 作業系統上的功能在 FreeBSD 並沒有支援。例如,若 Linux Binary 過度的使用 i386 特定的呼叫,如啟動虛擬 8086 模式,會無法在 FreeBSD 執行。 - 然而,部份 Linux 作業系統的特色在 FreeBSD 並未支援。 例如,如果 Linux Binary 過度使用 i386 特定的呼叫,像是啟動虛擬 8086 模式,將無法在 FreeBSD 執行。此外,64 位元 Linux Binary 目前也尚未支援。 + + FreeBSD 10.3 後支援 64 位元的 Linux Binary 相容性。 + 讀完這章,您將了解︰ @@ -12939,6 +12834,10 @@ # kldload linux + For 64-bit compatibility: + + # kldload linux64 + 確認模組已載入: % kldstat @@ -12956,6 +12855,9 @@ linux_enable="YES" + On 64-bit machines, /etc/rc.d/abi will + automatically load the module for 64-bit emulation. + 核心選項 COMPAT_LINUX 想要靜態連結 Linux Binary 相容性到自訂核心的使用者應加入 options COMPAT_LINUX 到自訂核心設定檔。 編譯並安裝新核心的方法,如 所述。 @@ -20928,32 +20830,55 @@ Instead of using passwords, a client can be configured to connect to the remote machine using keys. To generate - DSA or RSA + RSA authentication keys, use ssh-keygen. To generate a public and private key pair, specify the type of key and follow the prompts. It is recommended to protect the keys with a memorable, but hard to guess passphrase. - % ssh-keygen -t dsa -Generating public/private dsa key pair. -Enter file in which to save the key (/home/user/.ssh/id_dsa): -Created directory '/home/user/.ssh'. -Enter passphrase (empty for no passphrase): type some passphrase here which can contain spaces -Enter same passphrase again: type some passphrase here which can contain spaces -Your identification has been saved in /home/user/.ssh/id_dsa. -Your public key has been saved in /home/user/.ssh/id_dsa.pub. + % ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key (/home/user/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in /home/user/.ssh/id_rsa. +Your public key has been saved in /home/user/.ssh/id_rsa.pub. The key fingerprint is: -bb:48:db:f2:93:57:80:b6:aa:bc:f5:d5:ba:8f:79:17 user@host.example.com +SHA256:54Xm9Uvtv6H4NOo6yjP/YCfODryvUU7yWHzMqeXwhq8 user@host.example.com +The key's randomart image is: ++---[RSA 2048]----+ +| | +| | +| | +| . o.. | +| .S*+*o | +| . O=Oo . . | +| = Oo= oo..| +| .oB.* +.oo.| +| =OE**.o..=| ++----[SHA256]-----+ + + + + Type a passphrase here. It can contain spaces and + symbols. + + + + Retype the passphrase to verify it. + + - Depending upon the specified protocol, the private key - is stored in ~/.ssh/id_dsa (or - ~/.ssh/id_rsa), and the public key - is stored in ~/.ssh/id_dsa.pub (or - ~/.ssh/id_rsa.pub). The - public key must be first copied to + + The private key + is stored in ~/.ssh/id_rsa + and the public key + is stored in ~/.ssh/id_rsa.pub. + The + public key must be copied to ~/.ssh/authorized_keys on the remote - machine in order for key-based authentication to + machine for key-based authentication to work. @@ -20967,42 +20892,48 @@ passphrase. In addition, to better secure end users, from may be placed in the public key file. For example, adding - from="192.168.10.5" in the front of - ssh-rsa or rsa-dsa - prefix will only allow that specific user to login from + from="192.168.10.5" in front of the + ssh-rsa + prefix will only allow that specific user to log in from that IP address. - The various options and files can be different - according to the OpenSSH version. + The options and files vary with different versions of + OpenSSH. To avoid problems, consult ssh-keygen1. - If a passphrase is used, the user will be prompted for + If a passphrase is used, the user is prompted for the passphrase each time a connection is made to the server. - To load SSH keys into memory, without - needing to type the passphrase each time, use + To load SSH keys into memory and remove + the need to type the passphrase each time, use ssh-agent1 and ssh-add1. Authentication is handled by - ssh-agent, using the private key(s) that - are loaded into it. Then, ssh-agent - should be used to launch another application such as a + ssh-agent, using the private keys that + are loaded into it. ssh-agent + can be used to launch another application like a shell or a window manager. To use ssh-agent in a shell, start it - with a shell as an argument. Next, add the identity by - running ssh-add and providing it the - passphrase for the private key. Once these steps have been - completed, the user will be able to ssh + with a shell as an argument. Add the identity by + running ssh-add and entering the + passphrase for the private key. + The user will then be able to ssh to any host that has the corresponding public key installed. For example: % ssh-agent csh % ssh-add -Enter passphrase for key '/usr/home/user/.ssh/id_dsa': type passphrase here -Identity added: /usr/home/user/.ssh/id_dsa (/usr/home/user/.ssh/id_dsa) +Enter passphrase for key '/usr/home/user/.ssh/id_rsa': +Identity added: /usr/home/user/.ssh/id_rsa (/usr/home/user/.ssh/id_rsa) % + + + Enter the passphrase for the key. + + + To use ssh-agent in Xorg, add an entry for it in ~/.xinitrc. This provides the @@ -26596,7 +26527,7 @@ 79691810 4194236 3 freebsd-swap (2G) 83886046 18513921 - free - (8.8G) - 分割區只能重設大小到連續的未使用空間。在這個例子磁碟上最後的分割區為交換 (Swap) 分割區,而第二個分割區才是需要重設大小的分割區。交換分割區中只會有暫存的資料,所以可以安全的解除掛載、刪除,然後在重設其他分割區大小之後再重建。 + 分割區只能重設大小到連續的未使用空間。在這個例子磁碟上最後的分割區為交換 (Swap) 分割區,而第二個分割區才是需要重設大小的分割區。交換分割區中只會有暫存的資料,所以可以安全的卸載、刪除,然後在重設其他分割區大小之後再重建。 # swapoff /dev/ada0p3 # gpart delete -i 3 ada0 @@ -26637,7 +26568,7 @@ 擴增 UFS 檔案系統來使用重設分割區大小之後的新容量: - 只能在 FreeBSD 10.0-RELEASE 或之後的版本擴增運作中的 UFS 檔案系統,較先前的版本必須將檔案系統解除掛載。 + 只能在 FreeBSD 10.0-RELEASE 或之後的版本擴增運作中的 UFS 檔案系統,較先前的版本必須將檔案系統卸載。 # growfs /dev/ada0p2 @@ -26763,7 +26694,7 @@ % mount -t msdosfs -o -m=644,-M=755 /dev/da0s1 /mnt/username - 在裝置可以被拔除前,必須先解除掛載: + 在裝置可以被拔除前,必須先卸載: % umount /mnt/username @@ -26814,7 +26745,7 @@ 可以被自動掛載的檔案系統會在 /media/ 中以目錄呈現,會以檔案系統的標籤來命名目錄,若標籤遺失,則會以裝置節點命名。 - 檔案系統會在第一次存取時自動掛載,並在一段時間未使用後自動解除掛載。自動掛載的磁碟也可手動解除掛載: + 檔案系統會在第一次存取時自動掛載,並在一段時間未使用後自動卸載。自動掛載的磁碟也可手動卸載: # automount -fu @@ -27815,7 +27746,7 @@ Copies of whole file systems or disks which are - sychronized with another system on the network using a + synchronized with another system on the network using a scheduled net/rsync. @@ -29900,22 +29831,9 @@ Striping - Striping combines several disk drives into a single volume. - Striping can be performed through the use of hardware - RAID controllers. The - GEOM disk subsystem provides software support - for disk striping, also known as RAID0, - without the need for a RAID disk - controller. + 串連會合併數個磁碟成單一個磁碟區 (Volume)。串連可以透過使用硬體 RAID 控制器來達到。GEOM 磁碟子系統提供了軟體支援的磁碟串連,也就是所謂的 RAID0,而不需要 RAID 磁碟控制器。 - In RAID0, data is split into blocks that - are written across all the drives in the array. As seen in the - following illustration, instead of having to wait on the system - to write 256k to one disk, RAID0 can - simultaneously write 64k to each of the four disks in the array, - offering superior I/O performance. This - performance can be enhanced further by using multiple disk - controllers. + RAID0 中,資料會被切割成數個資料區塊 (Block) 寫入到磁碟陣列中的每一個磁碟機。如下圖所示,取代以往等候系統寫入 256k 到一個磁碟的時間, RAID0 可以同時寫入 64k 到磁碟陣列中四個磁碟的每個磁碟,這可提供優異的 I/O 效能,若使用多個磁碟控制器可增加更多的效能。 @@ -29927,17 +29845,10 @@ - Each disk in a RAID0 stripe must be of - the same size, since I/O requests are - interleaved to read or write to multiple disks in - parallel. + RAID0 串連中的每個磁碟必須要相同大小,因為 I/O 的請求是平行交錯讀取或寫入到多個磁碟的。 - RAID0 does not - provide any redundancy. This means that if one disk in the - array fails, all of the data on the disks is lost. If the - data is important, implement a backup strategy that regularly - saves backups to a remote system or device. + RAID0提供任何備援 (Redundancy) 功能。這意謂著若磁碟陣列中的其中一個磁碟故障,所有在該磁碟上的資料便會遺失。若資料很重要,請規畫備份策略,定期儲存備份到遠端系統或裝置。 The process for creating a software, @@ -30044,15 +29955,7 @@ RAID1 - RAID1, or - mirroring, is the technique of writing - the same data to more than one disk drive. Mirrors are usually - used to guard against data loss due to drive failure. Each - drive in a mirror contains an identical copy of the data. When - an individual drive fails, the mirror continues to work, - providing data from the drives that are still functioning. The - computer keeps running, and the administrator has time to - replace the failed drive without user interruption. + RAID1鏡像是一項寫入相同資料到超過一個磁碟機的技術。鏡像通常用來保護資料因磁碟機故障導致的損失,每個在鏡像中的磁碟機會擁有完全相同的資料,當各別磁碟機故障時,鏡像會繼續運作,由還可運作的磁碟機提供資料。電腦會繼續執行,等到管理者有時間更換故障的硬碟,而不會被使用者中斷運作。 Two common situations are illustrated in these examples. The first creates a mirror out of two new drives and uses it as @@ -31514,115 +31417,55 @@ - The Z File System, or - ZFS, is an advanced file system designed to - overcome many of the major problems found in previous - designs. + Z 檔案系統ZFS 是設計來克服許多在以往設計中發現的主要問題的一個先進的檔案系統。 - Originally developed at Sun, ongoing open source - ZFS development has moved to the OpenZFS Project. + 最初由 Sun 所開發,後來的開放源始碼 ZFS 開發已移到 OpenZFS 計劃。 - ZFS has three major design goals: + ZFS 的設計目標主要有三個: - Data integrity: All data includes a - checksum of the data. - When data is written, the checksum is calculated and written - along with it. When that data is later read back, the - checksum is calculated again. If the checksums do not match, - a data error has been detected. ZFS will - attempt to automatically correct errors when data redundancy - is available. + 資料完整性:所有資料都會有一個資料的校驗碼 (checksum),資被寫入時會計算校驗碼然後一併寫入,往後讀取資料時又會再計算一次校驗碼,若校驗碼與當初寫入時不相符,便可偵測到資料錯誤,此時若有可用的資料備援 (Data redundancy),ZFS 會嘗試自動修正錯誤。 - Pooled storage: physical storage devices are added to a - pool, and storage space is allocated from that shared pool. - Space is available to all file systems, and can be increased - by adding new storage devices to the pool. + 儲存池:實體的儲存裝置都會被加入到一個儲存池 (Pool),然後會使用這個共用的儲存池來配置儲存空間,空間可給所有的檔案系統使用,而空間可透過加入新的儲存裝置到儲存池來增加。 - Performance: multiple caching mechanisms provide increased - performance. ARC is an - advanced memory-based read cache. A second level of - disk-based read cache can be added with - L2ARC, and disk-based - synchronous write cache is available with - ZIL. + 效能:提供多個快取機制來增加效能。先進、以記憶體為基礎的讀取快取可使用 ARC。第二層以磁碟為基礎的讀取快取可使用 L2ARC,以磁碟為基礎的同步寫入快取則可使用 ZIL。 - A complete list of features and terminology is shown in - . + 完整的功能清單與術語在 中有詳述。 什麼使 <acronym>ZFS</acronym> 與眾不同 - ZFS is significantly different from any - previous file system because it is more than just a file system. - Combining the traditionally separate roles of volume manager and - file system provides ZFS with unique - advantages. The file system is now aware of the underlying - structure of the disks. Traditional file systems could only be - created on a single disk at a time. If there were two disks - then two separate file systems would have to be created. In a - traditional hardware RAID configuration, this - problem was avoided by presenting the operating system with a - single logical disk made up of the space provided by a number of - physical disks, on top of which the operating system placed a - file system. Even in the case of software - RAID solutions like those provided by - GEOM, the UFS file system - living on top of the RAID transform believed - that it was dealing with a single device. - ZFS's combination of the volume manager and - the file system solves this and allows the creation of many file - systems all sharing a pool of available storage. One of the - biggest advantages to ZFS's awareness of the - physical layout of the disks is that existing file systems can - be grown automatically when additional disks are added to the - pool. This new space is then made available to all of the file - systems. ZFS also has a number of different - properties that can be applied to each file system, giving many - advantages to creating a number of different file systems and - datasets rather than a single monolithic file system. + ZFS 與任何以往的檔案系統有顯著的不同,它並不只是一個檔案系統,結合了傳統磁碟區管理程式 (Volume Manager) 及檔案系統兩個獨立的角色,造就了 ZFS 獨特的優點,讓檔案系統現在可以察覺磁碟底層結構的變動。傳統在一個磁碟上只能建立一個檔案系統,若有兩個磁碟則會需要建立兩個分開的檔案系統,這個問題在傳統硬體 RAID 上可以透過呈現一個單一的邏輯磁碟給作業系統來解決,這個磁碟的空間實際上由數個實體磁碟所組成,而作業系統便可在這個邏輯磁碟上放置檔案系統,即使在像 GEOM 提供的軟體 RAID 解決方案也是一樣,把 RAID transform 當做是一個單一的裝置,把 UFS 檔案系統放在上面。ZFS 結合了 Volume Manager 與檔案系統來解決這個問題並讓建立的許多檔案系統可以共用一個儲存池 (Pool)。ZFS 最大的優點是可以察覺實體磁碟配置的變動,當有額外的磁碟加入到儲存池時可以自動擴增即有的檔案系統,所有的檔案系統便可使用這個新的空間。ZFS 也有數個不同的屬性可以套用到各別檔案系統上,比起單一檔案系統,對建立數個不同檔案系統與資料集 (Dataset) 時有許多的好處。 快速入門指南 - There is a startup mechanism that allows FreeBSD to mount - ZFS pools during system initialization. To - enable it, add this line to - /etc/rc.conf: + 這裡有一個啟動機制,可讓 FreeBSD 在系統初始化時掛載 ZFS 儲存池。要開啟這個功能,可加入此行到 /etc/rc.conf zfs_enable="YES" - Then start the service: + 然後啟動服務: # service zfs start - The examples in this section assume three - SCSI disks with the device names - da0, - da1, and - da2. Users - of SATA hardware should instead use - ada device - names. + 這本節的例子會假設有三個 SCSI 磁碟,名稱分別為 da0, da1da2SATA 硬體的使用者裝置名稱改為 ada 單磁碟儲存池 - To create a simple, non-redundant pool using a single - disk device: + 要使用一個磁碟裝置建立一個簡單、無備援的儲存池可: # zpool create example /dev/da0 - To view the new pool, review the output of - df: + 要檢視這個新的儲存池,可查看 df 的輸出結果: # df Filesystem 1K-blocks Used Avail Capacity Mounted on @@ -31631,10 +31474,7 @@ /dev/ad0s1d 54098308 1032846 48737598 2% /usr example 17547136 0 17547136 0% /example - This output shows that the example pool - has been created and mounted. It is now accessible as a file - system. Files can be created on it and users can browse - it: + 這個輸出結果說明 example 儲存池已建立且被掛載,現在已經可以作為檔案系統存取,可以在上面建立檔案且使用者可以瀏覽: # cd /example # ls @@ -31645,25 +31485,18 @@ drwxr-xr-x 21 root wheel 512 Aug 29 23:12 .. -rw-r--r-- 1 root wheel 0 Aug 29 23:15 testfile - However, this pool is not taking advantage of any - ZFS features. To create a dataset on this - pool with compression enabled: + 但是,這個儲存池並未運用到任何 ZFS 功能,若要在這個儲存池上建立一個有開啟壓縮的資料集: # zfs create example/compressed # zfs set compression=gzip example/compressed - The example/compressed dataset is now a - ZFS compressed file system. Try copying - some large files to - /example/compressed. + example/compressed 資料集現在是一個 ZFS 壓縮的檔案系統,可以試著複製較大的檔案到 /example/compressed - Compression can be disabled with: + 壓縮也可以使用以下指令關閉: # zfs set compression=off example/compressed - To unmount a file system, use - zfs umount and then verify with - df: + 要卸載檔案系統,使用 zfs umount 然後再使用 df 確認: # zfs umount example/compressed # df @@ -31673,9 +31506,7 @@ /dev/ad0s1d 54098308 1032864 48737580 2% /usr example 17547008 0 17547008 0% /example - To re-mount the file system to make it accessible again, - use zfs mount and verify with - df: + 要重新掛載檔案系統以便再次使用,使用 use zfs mount 然後以 df 檢查: # zfs mount example/compressed # df @@ -31686,8 +31517,7 @@ example 17547008 0 17547008 0% /example example/compressed 17547008 0 17547008 0% /example/compressed - The pool and file system may also be observed by viewing - the output from mount: + 儲存池與檔案系統也可以從 mount 的結果查詢到: # mount /dev/ad0s1a on / (ufs, local) @@ -31696,19 +31526,12 @@ example on /example (zfs, local) example/compressed on /example/compressed (zfs, local) - After creation, ZFS datasets can be - used like any file systems. However, many other features are - available which can be set on a per-dataset basis. In the - example below, a new file system called - data is created. Important files will be - stored here, so it is configured to keep two copies of each - data block: + 在建立之後,ZFS 的資料集可如同其他檔案系統一般使用,且有許多額外功能可在每個資料集上設定。例如,建立一個新的檔案系統 data,此處預計存放重要的資料,所以會設定每個資料區 (Data block) 要保留兩份備份: # zfs create example/data # zfs set copies=2 example/data - It is now possible to see the data and space utilization - by issuing df: + 現在,可以使用 df 指令來查看資料與空間的使用率: # df Filesystem 1K-blocks Used Avail Capacity Mounted on @@ -31719,16 +31542,9 @@ example/compressed 17547008 0 17547008 0% /example/compressed example/data 17547008 0 17547008 0% /example/data - Notice that each file system on the pool has the same - amount of available space. This is the reason for using - df in these examples, to show that the file - systems use only the amount of space they need and all draw - from the same pool. ZFS eliminates - concepts such as volumes and partitions, and allows multiple - file systems to occupy the same pool. + 注意,從這個可以發現每個在儲存池上的檔案系統都擁有相同的可用空間,這是為什麼要在這些範例使用 df 的原因,為了要顯示檔案系統只會用它們所需要使用到的空間,且均取自同一個儲存池。ZFS 淘汰了磁碟區 (Volume) 與分割區 (Partition) 的概念,且允許多個檔案系統共用相同的儲存池。 - To destroy the file systems and then destroy the pool as - it is no longer needed: + 不需要使用時可摧毀檔案系統後再摧毀儲存池: # zfs destroy example/compressed # zfs destroy example/data @@ -31738,94 +31554,57 @@ RAID-Z - Disks fail. One method of avoiding data loss from disk - failure is to implement RAID. - ZFS supports this feature in its pool - design. RAID-Z pools require three or more - disks but provide more usable space than mirrored - pools. + 磁碟損壞時,要避免資料因磁碟故障造成遺失便是使用 RAIDZFS 在它的儲存池設計中支援了這項功能。RAID-Z 儲存池需要使用三個或更多的磁碟,但可以提供比鏡像 (Mirror) 儲存池更多的可用空間。 - This example creates a RAID-Z pool, - specifying the disks to add to the pool: + 這個例子會建立一個 RAID-Z 儲存池,並指定要加入這個儲存池的磁碟: # zpool create storage raidz da0 da1 da2 - Sun recommends that the number of devices used in a - RAID-Z configuration be between three and - nine. For environments requiring a single pool consisting - of 10 disks or more, consider breaking it up into smaller - RAID-Z groups. If only two disks are - available and redundancy is a requirement, consider using a - ZFS mirror. Refer to zpool8 for - more details. + Sun 建議用在 RAID-Z 設定的裝置數在三到九個之間。若需要由 10 個或更多磁碟組成單一儲存池環境,請考慮是否分成較小的 RAID-Z 群組。若只有兩個可用的磁碟且需要做備援 (Redundancy),請考慮使用 ZFS 鏡像 (Mirror)。請參考 zpool8 取得更多詳細資訊。 - The previous example created the - storage zpool. This example makes a new - file system called home in that - pool: + 先前的例子已經建立了 storage zpool,現在這個例子會在該儲存池中建立一個新的檔案系統,名稱為 home # zfs create storage/home - Compression and keeping extra copies of directories - and files can be enabled: + 可以設定開啟壓縮及保留目錄及檔案額外備份的功能: # zfs set copies=2 storage/home # zfs set compression=gzip storage/home - To make this the new home directory for users, copy the - user data to this directory and create the appropriate - symbolic links: + 要讓這個空間做為使用者的新家目錄位置,複製使用者資料到這個目錄並建立適合的符號連結 (Symbolic link): # cp -rp /home/* /storage/home # rm -rf /home /usr/home # ln -s /storage/home /home # ln -s /storage/home /usr/home - Users data is now stored on the freshly-created - /storage/home. Test by adding a new user - and logging in as that user. + 現在使用者的資料會儲存在新建立的 /storage/home,可以加入新使用者並登入該使用者來測試。 - Try creating a file system snapshot which can be rolled - back later: + 試著建立檔案系統快照 (Snapshot),稍後可用來還原 (Rollback): # zfs snapshot storage/home@08-30-08 - Snapshots can only be made of a full file system, not a - single directory or file. + 只可以對整個檔案系統做快照,無法針對各別目錄或檔案。 - The @ character is a delimiter between - the file system name or the volume name. If an important - directory has been accidentally deleted, the file system can - be backed up, then rolled back to an earlier snapshot when the - directory still existed: + @ 是用來區隔檔案系統 (File system) 名稱或磁碟區 (Volume) 名稱的字元,若有重要的目錄意外被刪除,檔案系統可以備份然後還原到先前目錄還存在時的快照 (Snapshot): # zfs rollback storage/home@08-30-08 - To list all available snapshots, run - ls in the file system's - .zfs/snapshot directory. For example, to - see the previously taken snapshot: + 要列出所有可用的快照,可在檔案系統的 .zfs/snapshot 目錄執行 ls,舉例來說,要查看先前已做的快照: # ls /storage/home/.zfs/snapshot - It is possible to write a script to perform regular - snapshots on user data. However, over time, snapshots can - consume a great deal of disk space. The previous snapshot can - be removed using the command: + 也可以寫一個 Script 來對使用者資料做例行性的快照,但隨著時間快照可能消耗大量的磁碟空間。先前的快照可以使用指令移除: # zfs destroy storage/home@08-30-08 - After testing, /storage/home can be - made the real /home using this - command: + 在測試之後,便可讓 /storage/home 成為真正的 /home 使用此指令: # zfs set mountpoint=/home storage/home - Run df and mount to - confirm that the system now treats the file system as the real - /home: + 執行 dfmount 來確認系統現在是否以把檔案系統做為真正的 /home # mount /dev/ad0s1a on / (ufs, local) @@ -31841,11 +31620,7 @@ storage 26320512 0 26320512 0% /storage storage/home 26320512 0 26320512 0% /home - This completes the RAID-Z - configuration. Daily status updates about the file systems - created can be generated as part of the nightly - periodic8 runs. Add this line to - /etc/periodic.conf: + 這個動作完成 RAID-Z 最後的設定,有關已建立的檔案系統每日狀態更新可以做為 periodic8 的一部份在每晚執行。加入此行到 /etc/periodic.conf daily_status_zfs_enable="YES" @@ -31853,22 +31628,15 @@ 復原 <acronym>RAID-Z</acronym> - Every software RAID has a method of - monitoring its state. The status of - RAID-Z devices may be viewed with this - command: + 每個軟體 RAID 都有監控其狀態 (state) 的方式,RAID-Z 裝置的狀態可以使用這個指令來查看: # zpool status -x - If all pools are - Online and everything - is normal, the message shows: + 如果所有儲存池為上線 (Online) 且正常,則訊息會顯示: all pools are healthy - If there is an issue, perhaps a disk is in the - Offline state, the - pool state will look similar to: + 如果有發生問題,可能磁碟會呈現離線 (Offline) 的狀態,此時儲存池的狀態會是: pool: storage state: DEGRADED @@ -31889,20 +31657,15 @@ errors: No known data errors - This indicates that the device was previously taken - offline by the administrator with this command: + 這代表著裝置在之前被管理者使用此指令拿下線: # zpool offline storage da1 - Now the system can be powered down to replace - da1. When the system is back online, - the failed disk can replaced in the pool: + 現在系統可以關機然後更換 da1,當系統恢復上線,則可以替換掉儲存池中故障的磁碟: # zpool replace storage da1 - From here, the status may be checked again, this time - without so that all pools are - shown: + 到這裡,可以再檢查狀態一次,這時不使用 參數來顯示所有的儲存池: # zpool status storage pool: storage @@ -31919,37 +31682,23 @@ errors: No known data errors - In this example, everything is normal. + 在這個例子中,所有的磁碟均正常運作。 資料檢驗 - ZFS uses checksums to verify the - integrity of stored data. These are enabled automatically - upon creation of file systems. + ZFS 使用校驗碼 (Checksum) 來檢驗資料的完整性 (Integrity),在建立檔案系統時便會自動開啟。 - Checksums can be disabled, but it is - not recommended! Checksums take very - little storage space and provide data integrity. Many - ZFS features will not work properly with - checksums disabled. There is no noticeable performance gain - from disabling these checksums. + 校驗碼 (Checksum) 可以關閉,但並建議!校驗碼只會使用非常少的儲存空間來確保資料的完整性。校驗碼若關閉會使許多 ZFS 功能無法正常運作,關閉校驗碼功能並不會明顯的改善效能。 - Checksum verification is known as - scrubbing. Verify the data integrity of - the storage pool with this command: + 檢驗校驗碼這個動作即所謂的清潔 (Scrub),可以使用以下指令來檢驗 storage 儲存池的資料完整性: # zpool scrub storage - The duration of a scrub depends on the amount of data - stored. Larger amounts of data will take proportionally - longer to verify. Scrubs are very I/O - intensive, and only one scrub is allowed to run at a time. - After the scrub completes, the status can be viewed with - status: + 清潔所需要的時間依儲存的資料量而定,較大的資料量相對會需要花費較長的時間來檢驗。清潔對 I/O 的操作非常密集,且一次只能進行一個清潔動作。在清潔完成之後,可以使用 status 來查看狀態: # zpool status storage pool: storage @@ -31966,49 +31715,23 @@ errors: No known data errors - The completion date of the last scrub operation is - displayed to help track when another scrub is required. - Routine scrubs help protect data from silent corruption and - ensure the integrity of the pool. + 查詢結果會顯示上次完成清潔的時間來協助追蹤是否要再做清潔。定期清潔可以協助保護資料不會默默損壞且確保儲存池的完整性。 - Refer to zfs8 and zpool8 for other - ZFS options. + 請參考 zfs8zpool8 來取得其他 ZFS 選項。 <command>zpool</command> 管理 - ZFS administration is divided between two - main utilities. The zpool utility controls - the operation of the pool and deals with adding, removing, - replacing, and managing disks. The - zfs utility - deals with creating, destroying, and managing datasets, - both file systems and - volumes. + ZFS 管理分成兩個主要的工具。zpool 工具用來控制儲存池的運作並可處理磁碟的新增、移除、更換與管理。zfs 工具用來建立、摧毀與管理檔案系統 (File system) 與磁碟區 (Volume) 的資料集。 建立與摧毀儲存池 - Creating a ZFS storage pool - (zpool) involves making a number of - decisions that are relatively permanent because the structure - of the pool cannot be changed after the pool has been created. - The most important decision is what types of vdevs into which - to group the physical disks. See the list of - vdev types for details - about the possible options. After the pool has been created, - most vdev types do not allow additional disks to be added to - the vdev. The exceptions are mirrors, which allow additional - disks to be added to the vdev, and stripes, which can be - upgraded to mirrors by attaching an additional disk to the - vdev. Although additional vdevs can be added to expand a - pool, the layout of the pool cannot be changed after pool - creation. Instead, the data must be backed up and the - pool destroyed and recreated. + 建立 ZFS 儲存池 (zpool) 要做幾個涉及長遠規劃的決定,因為建立儲存池之後便無法再更改儲存池的結構。最重要的決定是要使用那一種型態的 vdev 來將實體磁碟設為同一群組。請參考 vdev 型態 的清單來取得有關可用選項的詳細資訊。大部份的 vdev 型態不允許在建立儲存池之後再加入額外的磁碟,鏡像 (Mirror) 是其中一個例外,可以允許加入額外的磁碟到 vdev,另一個則是串連 (Stripe),可以加入額外的磁碟到 vdev 來升級為鏡像。雖然可以加入額外的 vdev 來擴充儲存池,但儲存池的配置在建立之後便無法更改,若要要更改,則必須備份資料,把儲存池摧毀後再重新建立。 - Create a simple mirror pool: + 建立一個簡單的鏡像儲存池: # zpool create mypool mirror /dev/ada1 /dev/ada2 # zpool status @@ -32025,9 +31748,7 @@ errors: No known data errors - Multiple vdevs can be created at once. Specify multiple - groups of disks separated by the vdev type keyword, - mirror in this example: + 可以一次建立數個 vdev,磁碟群組間使用 vdev type 關鍵字來區隔,在這個例子使用 mirror # zpool create mypool mirror /dev/ada1 /dev/ada2 mirror /dev/ada3 /dev/ada4 pool: mypool @@ -32046,24 +31767,9 @@ errors: No known data errors - Pools can also be constructed using partitions rather than - whole disks. Putting ZFS in a separate - partition allows the same disk to have other partitions for - other purposes. In particular, partitions with bootcode and - file systems needed for booting can be added. This allows - booting from disks that are also members of a pool. There is - no performance penalty on FreeBSD when using a partition rather - than a whole disk. Using partitions also allows the - administrator to under-provision the - disks, using less than the full capacity. If a future - replacement disk of the same nominal size as the original - actually has a slightly smaller capacity, the smaller - partition will still fit, and the replacement disk can still - be used. - - Create a - RAID-Z2 pool using - partitions: + 儲存池也可使用分割區 (Partition) 來建立,不使用整個磁碟。把 ZFS 放到不同的分割區可讓同一個磁碟有其他的分割區可做其他用途,尤其是有 Bootcode 與檔案系統要用來開機的分割區,這讓磁碟可以用來開機也同樣可以做為儲存池的一部份。在 FreeBSD 用分割區來替代整個磁碟並不會對效能有影響。使用分割區也讓管理者可以對磁碟容量做 少算的預備,使用比完整容量少的容量,未來若要替換的磁碟號稱與原磁碟相同,但實際上卻比較小時,也可符合這個較小的分割區容量,以使用替換的磁碟。 + + 使用分割區建立一個 RAID-Z2 儲存池: # zpool create mypool raidz2 /dev/ada0p3 /dev/ada1p3 /dev/ada2p3 /dev/ada3p3 /dev/ada4p3 /dev/ada5p3 # zpool status @@ -32084,47 +31790,17 @@ errors: No known data errors - A pool that is no longer needed can be destroyed so that - the disks can be reused. Destroying a pool involves first - unmounting all of the datasets in that pool. If the datasets - are in use, the unmount operation will fail and the pool will - not be destroyed. The destruction of the pool can be forced - with , but this can cause undefined - behavior in applications which had open files on those - datasets. + 不再使用的儲存池可以摧毀,來讓磁碟可以再次使用。摧毀一個儲存池要先卸載所有該儲存池的資料集。若資料集在使用中,卸載的操作會失敗且不會被摧毀儲存池。儲存池的摧毀可以使用 來強制執行,但這可能造成那些有開啟這些資料集中的檔案的應用程式無法辨識的行為。 加入與移除裝置 - There are two cases for adding disks to a zpool: attaching - a disk to an existing vdev with - zpool attach, or adding vdevs to the pool - with zpool add. Only some - vdev types allow disks to - be added to the vdev after creation. - - A pool created with a single disk lacks redundancy. - Corruption can be detected but - not repaired, because there is no other copy of the data. - - The copies property may - be able to recover from a small failure such as a bad sector, - but does not provide the same level of protection as mirroring - or RAID-Z. Starting with a pool consisting - of a single disk vdev, zpool attach can be - used to add an additional disk to the vdev, creating a mirror. - zpool attach can also be used to add - additional disks to a mirror group, increasing redundancy and - read performance. If the disks being used for the pool are - partitioned, replicate the layout of the first disk on to the - second, gpart backup and - gpart restore can be used to make this - process easier. - - Upgrade the single disk (stripe) vdev - ada0p3 to a mirror by attaching - ada1p3: + 加入磁碟到儲存池 (zpool) 會有兩種情形:使用 zpool attach 加入一個磁碟到既有的 vdev,或使用 zpool add 加入 vdev 到儲存池。只有部份 vdev 型態 允許在 vdev 建立之後加入磁碟。 + + 由單一磁碟所建立的儲存池缺乏備援 (Redundancy) 功能,可以偵測到資料的損壞但無法修復,因為資料沒有其他備份可用。備份數 (Copies) 屬性可以讓您從較小的故障中復原,如磁碟壞軌 (Bad sector),但無法提供與鏡像或 RAID-Z 同樣層級的保護。由單一磁碟所建立的儲存池可以使用 zpool attach 來加入額外的磁碟到 vdev,來建立鏡像。zpool attach 也可用來加入額外的磁碟到鏡像群組,來增加備援與讀取效率。若使用的磁碟已有分割區,可以複製該磁碟的分割區配置到另一個,使用 gpart backupgpart restore 可讓這件事變的很簡單。 + + 加入 ada1p3 來升級單一磁碟串連 (stripe) vdev ada0p3 採用鏡像型態 (mirror): # zpool status pool: mypool @@ -32181,34 +31857,13 @@ errors: No known data errors - When adding disks to the existing vdev is not an option, - as for RAID-Z, an alternative method is to - add another vdev to the pool. Additional vdevs provide higher - performance, distributing writes across the vdevs. Each vdev - is responsible for providing its own redundancy. It is - possible, but discouraged, to mix vdev types, like - mirror and RAID-Z. - Adding a non-redundant vdev to a pool containing mirror or - RAID-Z vdevs risks the data on the entire - pool. Writes are distributed, so the failure of the - non-redundant disk will result in the loss of a fraction of - every block that has been written to the pool. - - Data is striped across each of the vdevs. For example, - with two mirror vdevs, this is effectively a - RAID 10 that stripes writes across two sets - of mirrors. Space is allocated so that each vdev reaches 100% - full at the same time. There is a performance penalty if the - vdevs have different amounts of free space, as a - disproportionate amount of the data is written to the less - full vdev. - - When attaching additional devices to a boot pool, remember - to update the bootcode. - - Attach a second mirror group (ada2p3 - and ada3p3) to the existing - mirror: + 若不想選擇加入磁碟到既有的 vdev ,對 RAID-Z 來說,可選擇另一種方式,便是加入另一個 vdev 到儲存池。額外的 vdev 可以提供更高的效能,分散寫入資料到 vdev 之間,每個 vdev 會負責自己的備援。也可以混合使用不同的 vdev 型態,但並不建議,例如混合使用 mirrorRAID-Z,加入一個無備援的 vdev 到一個含有 mirror 或 RAID-Z vdev 的儲存池會讓資料損壞的風險擴大整個儲存池,由於會分散寫入資料,若在無備援的磁碟上發生故障的結果便是遺失大半寫到儲存池的資料區塊。 + + 在每個 vdev 間的資料是串連的,例如,有兩個 mirror vdev,便跟 RAID 10 一樣在兩個 mirror 間分散寫入資料,且會做空間的分配,因此 vdev 會在同時達到全滿 100% 的用量。若 vdev 間的可用空間量不同則會影響到效能,因為資料量會不成比例的寫入到使用量較少的 vdev。 + + 當連接額外的裝置到一個可以開機的儲存池,要記得更新 Bootcode。 + + 連接第二個 mirror 群組 (ada2p3ada3p3) 到既有的 mirror: # zpool status pool: mypool @@ -32245,13 +31900,9 @@ errors: No known data errors - Currently, vdevs cannot be removed from a pool, and disks - can only be removed from a mirror if there is enough remaining - redundancy. If only one disk in a mirror group remains, it - ceases to be a mirror and reverts to being a stripe, risking - the entire pool if that remaining disk fails. + 現在已無法從儲存池上移除 vdev,且磁碟只能夠在有足夠備援空間的情況下從 mirror 移除,若在 mirror 群組中只剩下一個磁碟,便會取消 mirror 然後還原為 stripe,若剩下的那個磁碟故障,便會影響到整個儲存池。 - Remove a disk from a three-way mirror group: + 從一個三方 mirror 群組移除一個磁碟: # zpool status pool: mypool @@ -32286,13 +31937,7 @@ 檢查儲存池狀態 - Pool status is important. If a drive goes offline or a - read, write, or checksum error is detected, the corresponding - error count increases. The status output - shows the configuration and status of each device in the pool - and the status of the entire pool. Actions that need to be - taken and details about the last scrub - are also shown. + 儲存池的狀態很重要,若有磁碟機離線或偵測到讀取、寫入或校驗碼 (Checksum) 錯誤,對應的錯誤計數便會增加。status 會顯示儲存池中每一個磁碟機的設定與狀態及整個儲存池的狀態。需要處置的方式與有關最近清潔 (Scrub) 的詳細資訊也會一併顯示。 # zpool status pool: mypool @@ -32316,32 +31961,15 @@ 清除錯誤 - When an error is detected, the read, write, or checksum - counts are incremented. The error message can be cleared and - the counts reset with zpool clear - mypool. Clearing the - error state can be important for automated scripts that alert - the administrator when the pool encounters an error. Further - errors may not be reported if the old errors are not - cleared. + 當偵測到錯誤發生,讀取、寫入或校驗碼 (Checksum) 的計數便會增加。使用 zpool clear mypool 可以清除錯誤訊息及重置計數。清空錯誤狀態對當儲存池發生錯誤要使用自動化 Script 通知的管理者來說會很重要,因在舊的錯誤尚未清除前,可能便不會回報後續的錯誤。 - 替換運作中的裝置 + 更換運作中的裝置 - There are a number of situations where it may be - desirable to replace one disk with a different disk. When - replacing a working disk, the process keeps the old disk - online during the replacement. The pool never enters a - degraded state, - reducing the risk of data loss. - zpool replace copies all of the data from - the old disk to the new one. After the operation completes, - the old disk is disconnected from the vdev. If the new disk - is larger than the old disk, it may be possible to grow the - zpool, using the new space. See Growing a Pool. + 可能有一些情況會需要更換磁碟為另一個磁碟,當要更換運作中的磁碟,此程序會維持舊有的磁碟在更換的過程為上線的狀態,儲存池不會進入降級 (Degraded) 的狀態,來減少資料遺失的風險。zpool replace 會複製所有舊磁碟的資料到新磁碟,操作完成之後舊磁碟便會與 vdev 中斷連線。若新磁碟容量較舊磁碟大,也可以會增加儲存池來使用新的空間,請參考 擴增儲存池。 - Replace a functioning device in the pool: + 更換儲存池中正在運作的狀置: # zpool status pool: mypool @@ -32405,36 +32033,13 @@ 處理故障裝置 - When a disk in a pool fails, the vdev to which the disk - belongs enters the - degraded state. All - of the data is still available, but performance may be reduced - because missing data must be calculated from the available - redundancy. To restore the vdev to a fully functional state, - the failed physical device must be replaced. - ZFS is then instructed to begin the - resilver operation. - Data that was on the failed device is recalculated from - available redundancy and written to the replacement device. - After completion, the vdev returns to - online status. - - If the vdev does not have any redundancy, or if multiple - devices have failed and there is not enough redundancy to - compensate, the pool enters the - faulted state. If a - sufficient number of devices cannot be reconnected to the - pool, the pool becomes inoperative and data must be restored - from backups. + 當儲存池中的磁碟故障,該故障硬碟所屬的 vdev 便會進入降級 (Degraded) 狀態,所有的資料仍可使用,但效能可能會降低,因為遺失的資料必須從可用的備援資料計算才能取得。要將 vdev 恢復完整運作的狀態必須更換故障的實體裝置。然後 ZFS 便會開始修復 (Resilver,古代鏡子的修復稱 Resilver) 作業,會從可用的備援資料計算出故障磁碟中的資料並寫入到替換的裝置上。完成後 vdev 便會重新返回上線 (Online) 的狀態。 + + 若 vdev 沒有任何備援資料或有多個裝置故障,沒有足夠的備援資料可以補償,儲存池便會進入故障 (Faulted) 的狀態。 - When replacing a failed disk, the name of the failed disk - is replaced with the GUID of the device. - A new device name parameter for - zpool replace is not required if the - replacement device has the same device name. + 更換故障的磁碟時,故障磁碟的名稱會更換為裝置的 GUID,若替換裝置要使用相同的裝置名稱,則在 zpool replace 不須加上新裝置名稱參數。 - Replace a failed disk using - zpool replace: + 使用 zpool replace 更換故障的磁碟: # zpool status pool: mypool @@ -32492,15 +32097,7 @@ 清潔儲存池 - It is recommended that pools be - scrubbed regularly, - ideally at least once every month. The - scrub operation is very disk-intensive and - will reduce performance while running. Avoid high-demand - periods when scheduling scrub or use vfs.zfs.scrub_delay - to adjust the relative priority of the - scrub to prevent it interfering with other - workloads. + 建議儲存池要定期清潔 (Scrub),最好是每一個月清潔一次。 scrub 作業對磁碟操作非常的密集,在執行時會降低磁碟的效能。在排程 scrub 時避免在使用高峰的時期,或使用 vfs.zfs.scrub_delay 來調整 scrub 的相對優先權來避免影響其他的工作。 # zpool scrub mypool # zpool status @@ -32523,37 +32120,15 @@ errors: No known data errors - In the event that a scrub operation needs to be cancelled, - issue zpool scrub -s - mypool. + 若發生需要取消清潔作業的事,可以下 zpool scrub -s mypool 自我修復 - The checksums stored with data blocks enable the file - system to self-heal. This feature will - automatically repair data whose checksum does not match the - one recorded on another device that is part of the storage - pool. For example, a mirror with two disks where one drive is - starting to malfunction and cannot properly store the data any - more. This is even worse when the data has not been accessed - for a long time, as with long term archive storage. - Traditional file systems need to run algorithms that check and - repair the data like fsck8. These commands take time, - and in severe cases, an administrator has to manually decide - which repair operation must be performed. When - ZFS detects a data block with a checksum - that does not match, it tries to read the data from the mirror - disk. If that disk can provide the correct data, it will not - only give that data to the application requesting it, but also - correct the wrong data on the disk that had the bad checksum. - This happens without any interaction from a system - administrator during normal pool operation. - - The next example demonstrates this self-healing behavior. - A mirrored pool of disks /dev/ada0 and - /dev/ada1 is created. + 校驗碼 (Checksum) 會隨資料區塊一併儲存,這使得檔案系統可以做到自我修復。這個功能可以在校驗碼與儲存池中的另一個裝置不同時自動修復資料。舉例來說,有兩個磁碟做鏡像 (Mirror),其中一個磁碟機開始失常並無法正常儲存資料,甚至是資料放在長期封存的儲存裝置上,已經很久沒有被存取。傳統的檔案系統需要執行演算法來檢查並修復資料如 fsck8,這些指令耗費時間,且在嚴重時需要管理者手動決定要做那一種修復操作。當 ZFS 偵測到資料區塊的校驗碼不對時,它除了把資料交給需要的應用程式外,也會修正在磁碟上錯誤的資料。這件事不需要與系統管理者作任何互動便會在一般的儲存池操作時完成。 + + 接下來的例子會示範自我修復會如何運作。建立一個使用磁碟 /dev/ada0/dev/ada1 做鏡像的儲存池。 # zpool create healer mirror /dev/ada0 /dev/ada1 # zpool status healer @@ -32573,9 +32148,7 @@ NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT healer 960M 92.5K 960M 0% 1.00x ONLINE - - Some important data that to be protected from data errors - using the self-healing feature is copied to the pool. A - checksum of the pool is created for later comparison. + 將部份需要使用自我修復功能來保護的重要資料複製到該儲存池,建立一個儲存池的校驗碼供稍後做比較時使用。 # cp /some/important/data /healer # zfs list @@ -32585,22 +32158,10 @@ # cat checksum.txt SHA1 (/healer) = 2753eff56d77d9a536ece6694bf0a82740344d1f - Data corruption is simulated by writing random data to the - beginning of one of the disks in the mirror. To prevent - ZFS from healing the data as soon as it is - detected, the pool is exported before the corruption and - imported again afterwards. + 寫入隨機的資料到鏡像的第一個磁碟來模擬資料損毀的情況。要避免 ZFS 偵測到錯誤時馬上做修復,接著要將儲存池匯出,待模擬資料損毀之後再匯入。 - This is a dangerous operation that can destroy vital - data. It is shown here for demonstrational purposes only - and should not be attempted during normal operation of a - storage pool. Nor should this intentional corruption - example be run on any disk with a different file system on - it. Do not use any other disk device names other than the - ones that are part of the pool. Make certain that proper - backups of the pool are created before running the - command! + 這是一個危險的操作,會破壞重要的資料。在這裡使用僅為了示範用,不應在儲存池正常運作時嘗試使用,也不應將這個故意損壞資料的例子用在任何其他的檔案系統上,不要使用任何不屬於該儲存池的其他磁碟裝置名稱。請確定在執行指令前已對儲存池做正確的備份。 # zpool export healer @@ -32610,13 +32171,7 @@ 209715200 bytes transferred in 62.992162 secs (3329227 bytes/sec) # zpool import healer - The pool status shows that one device has experienced an - error. Note that applications reading data from the pool did - not receive any incorrect data. ZFS - provided data from the ada0 device with - the correct checksums. The device with the wrong checksum can - be found easily as the CKSUM column - contains a nonzero value. + 儲存池的狀態顯示有一個裝置發生了錯誤。注意,應用程式從儲存池讀取的資料中並沒有任何的錯誤資料,ZFS 會自 ada0 裝置提供有正確校驗碼的資料。結果裡面 CKSUM 欄位含有非零值便是有錯誤校驗碼的裝置。 # zpool status healer pool: healer @@ -32637,30 +32192,14 @@ errors: No known data errors - The error was detected and handled by using the redundancy - present in the unaffected ada0 mirror - disk. A checksum comparison with the original one will reveal - whether the pool is consistent again. + 錯誤已經被偵測到並且由未被影響的 ada0 鏡像磁碟上的備援提供資料。可與原來的校驗碼做比較來看儲存池是否已修復為一致。 # sha1 /healer >> checksum.txt # cat checksum.txt SHA1 (/healer) = 2753eff56d77d9a536ece6694bf0a82740344d1f SHA1 (/healer) = 2753eff56d77d9a536ece6694bf0a82740344d1f - The two checksums that were generated before and after the - intentional tampering with the pool data still match. This - shows how ZFS is capable of detecting and - correcting any errors automatically when the checksums differ. - Note that this is only possible when there is enough - redundancy present in the pool. A pool consisting of a single - device has no self-healing capabilities. That is also the - reason why checksums are so important in - ZFS and should not be disabled for any - reason. No fsck8 or similar file system consistency - check program is required to detect and correct this and the - pool was still available during the time there was a problem. - A scrub operation is now required to overwrite the corrupted - data on ada1. + 儲存池在故意竄改資料前與後的兩個校驗碼仍相符顯示了 ZFS 在校驗碼不同時偵測與自動修正錯誤的能力。注意,這只在當儲存池中有足夠的備援時才可做到,由單一裝置組成的儲存池並沒有自我修復的能力。這也是為什麼在 ZFS 中校驗碼如此重要,任何原因都不該關閉。不需要 fsck8 或類似的檔案系統一致性檢查程式便能夠偵測與修正問題,且儲存儲存池在發生問題時仍可正常運作。接著需要做清潔作業來覆蓋在 ada1 上的錯誤資料。 # zpool scrub healer # zpool status healer @@ -32684,12 +32223,7 @@ errors: No known data errors - The scrub operation reads data from - ada0 and rewrites any data with an - incorrect checksum on ada1. This is - indicated by the (repairing) output from - zpool status. After the operation is - complete, the pool status changes to: + 清潔作業會從 ada0 讀取資料並重新寫入任何在 ada1 上有錯誤校驗碼的資料。這個操作可以由 zpool status 的輸出中呈現修復中 (repairing) 的項目來辨識。這個作業完成後,儲存池的狀態會更改為: # zpool status healer pool: healer @@ -32710,11 +32244,7 @@ errors: No known data errors - After the scrub operation completes and all the data - has been synchronized from ada0 to - ada1, the error messages can be - cleared from the pool - status by running zpool clear. + 清潔操作完成後,便同步完 ada0ada1 間的所有資料。執行 zpool clear 可以清除 (Clear) 儲存池狀態的錯誤訊息。 # zpool clear healer # zpool status healer @@ -32731,68 +32261,29 @@ errors: No known data errors - The pool is now back to a fully working state and all the - errors have been cleared. + 儲存池現在恢復完整運作的狀態且清除所有的錯誤了。 擴增儲存池 - The usable size of a redundant pool is limited by the - capacity of the smallest device in each vdev. The smallest - device can be replaced with a larger device. After completing - a replace or - resilver operation, - the pool can grow to use the capacity of the new device. For - example, consider a mirror of a 1 TB drive and a - 2 TB drive. The usable space is 1 TB. When the - 1 TB drive is replaced with another 2 TB drive, the - resilvering process copies the existing data onto the new - drive. Because - both of the devices now have 2 TB capacity, the mirror's - available space can be grown to 2 TB. - - Expansion is triggered by using - zpool online -e on each device. After - expansion of all devices, the additional space becomes - available to the pool. + 可用的備援儲存池大小會受到每個 vdev 中容量最小的裝置限制。最小的裝置可以替換成較大的裝置,在更換 (Replace) 或修復 (Resilver) 作業後,儲存池可以成長到該新裝置的可用容量。例如,要做一個 1 TB 磁碟機與一個 2 TB 磁碟機的鏡像,可用的空間會是 1 TB,當 1 TB 磁碟機備更換成另一個 2 TB 的磁碟機時,修復程序會複製既有的資料到新的磁碟機,由於現在兩個裝置都有 2 TB 的容量,所以鏡像的可用空間便會成長到 2 TB。 + + 可以在每個裝置用 zpool online -e 來觸發擴充的動作,在擴充完所有裝置後,儲存池便可使用額外的空間。 匯入與匯出儲存池 - Pools are exported before moving them - to another system. All datasets are unmounted, and each - device is marked as exported but still locked so it cannot be - used by other disk subsystems. This allows pools to be - imported on other machines, other - operating systems that support ZFS, and - even different hardware architectures (with some caveats, see - zpool8). When a dataset has open files, - zpool export -f can be used to force the - export of a pool. Use this with caution. The datasets are - forcibly unmounted, potentially resulting in unexpected - behavior by the applications which had open files on those - datasets. + 儲存池在移動到其他系統之前需要做匯出 (Export),會卸載所有的資料集,然後標記每個裝置為已匯出,為了避免被其他磁碟子系統存取,因此仍會鎖定這些裝置。這個動作讓儲存池可以在支援 ZFS 的其他機器、其他作業系統做匯入 (Import),甚至是不同的硬體架構 (有一些注意事項,請參考 zpool8)。當資料集有被開啟的檔案,可使用 zpool export -f 來強制匯出儲存池,使用這個指令需要小心,資料集是被強制卸載的,因此有可能造成在該資料集開啟檔案的應用程式發生無法預期的結果。 - Export a pool that is not in use: + 匯出未使用的儲存池: # zpool export mypool - Importing a pool automatically mounts the datasets. This - may not be the desired behavior, and can be prevented with - zpool import -N. - zpool import -o sets temporary properties - for this import only. - zpool import altroot= allows importing a - pool with a base mount point instead of the root of the file - system. If the pool was last used on a different system and - was not properly exported, an import might have to be forced - with zpool import -f. - zpool import -a imports all pools that do - not appear to be in use by another system. + 匯入儲存池會自動掛載資料集,若不想自動掛載,可以使用 zpool import -Nzpool import -o 可以設定在匯入時暫時使用的屬性。zpool import altroot= 允許匯入時指定基礎掛載點 (Base mount point) 來替換檔案系統根目錄。若儲存池先前用在不同的系統且不正常匯出,可能會需要使用 zpool import -f 來強制匯入。zpool import -a 會匯入所有沒有被其他系統使用的儲存池。 - List all available pools for import: + 列出所有可以匯入的儲存池: # zpool import pool: mypool @@ -32804,7 +32295,7 @@ mypool ONLINE ada2p3 ONLINE - Import the pool with an alternative root directory: + 使用替代的根目錄匯入儲存池: # zpool import -o altroot=/mnt mypool # zfs list @@ -32816,17 +32307,9 @@ 升級儲存儲存池 - After upgrading FreeBSD, or if a pool has been imported from - a system using an older version of ZFS, the - pool can be manually upgraded to the latest version of - ZFS to support newer features. Consider - whether the pool may ever need to be imported on an older - system before upgrading. Upgrading is a one-way process. - Older pools can be upgraded, but pools with newer features - cannot be downgraded. + 在升級 FreeBSD 之後或儲存池是由其他使用舊版 ZFS 所匯入,儲存池可以手動升級到最新版本的 ZFS 來支援新的功能。在升級前請評估儲存池是否還要在舊的系統做匯入,由於升級是一個單向的程序,舊的儲存池可以升級,但有新功能的儲存池無法降級。 - Upgrade a v28 pool to support - Feature Flags: + 升級一個 v28 的儲存以支援功能旗標 (Feature Flags): # zpool status pool: mypool @@ -32870,13 +32353,9 @@ lz4_compress multi_vdev_crash_dump - The newer features of ZFS will not be - available until zpool upgrade has - completed. zpool upgrade -v can be used to - see what new features will be provided by upgrading, as well - as which features are already supported. + ZFS 的新功能在 zpool upgrade 尚未完成之前無法使用。可以用 zpool upgrade -v 來查看升級後有那些新功能,也同時會列出已經支援那些功能。 - Upgrade a pool to support additional feature flags: + 升級儲存池支援額外的功能旗標 (Feature flags): # zpool status pool: mypool @@ -32928,25 +32407,14 @@ filesystem_limits - The boot code on systems that boot from a pool must be - updated to support the new pool version. Use - gpart bootcode on the partition that - contains the boot code. See gpart8 for more - information. + 使用儲存池來開機的系統上的 Boot code 必須更新以支援新的儲存池版本,在含有 Boot code 的分割區使用 gpart bootcode 來更新。請參考 gpart8 取得更多資訊。 顯示已記錄的儲存池歷史日誌 - Commands that modify the pool are recorded. Recorded - actions include the creation of datasets, changing properties, - or replacement of a disk. This history is useful for - reviewing how a pool was created and which user performed a - specific action and when. History is not kept in a log file, - but is part of the pool itself. The command to review this - history is aptly named - zpool history: + 修改儲存池的指令會被記錄下來,會記錄的動作包含資料集的建立,屬性更改或更換磁碟。這個歷史記錄用來查看儲存池是如何建立、由誰執行、什麼動作及何時。歷史記錄並非儲存在日誌檔 (Log file),而是儲存在儲存池。查看這個歷史記錄的指令名稱為 zpool history # zpool history History for 'tank': @@ -32955,19 +32423,9 @@ 2013-02-27.18:51:09 zfs set checksum=fletcher4 tank 2013-02-27.18:51:18 zfs create tank/backup - The output shows zpool and - zfs commands that were executed on the pool - along with a timestamp. Only commands that alter the pool in - some way are recorded. Commands like - zfs list are not included. When no pool - name is specified, the history of all pools is - displayed. - - zpool history can show even more - information when the options or - are provided. - displays user-initiated events as well as internally logged - ZFS events. + 輸出結果顯示曾在該儲存池上執行的 zpoolzfs 指令以及時間戳記。只有會修改儲存池或類似的指令會被記錄下來,像是 zfs list 這種指令並不會被記錄。當不指定儲存池名稱時,會列出所有儲存池的歷史記錄。 + + 在提供選項 zpool history 可以顯更多詳細資訊。 會顯示使用者觸發的事件外,也會顯示內部記錄的 ZFS 事件。 # zpool history -i History for 'tank': @@ -32979,10 +32437,7 @@ 2013-02-27.18:51:13 [internal create txg:55] dataset = 39 2013-02-27.18:51:18 zfs create tank/backup - More details can be shown by adding . - History records are shown in a long format, including - information like the name of the user who issued the command - and the hostname on which the change was made. + 更多詳細的資訊可加上 來取得,歷史記錄會以較長的格式顯示,包含的資訊有執行指令的使用者名稱、主機名稱以及更改的項目。 # zpool history -l History for 'tank': @@ -32991,36 +32446,15 @@ 2013-02-27.18:51:09 zfs set checksum=fletcher4 tank [user 0 (root) on myzfsbox:global] 2013-02-27.18:51:18 zfs create tank/backup [user 0 (root) on myzfsbox:global] - The output shows that the - root user created - the mirrored pool with disks - /dev/ada0 and - /dev/ada1. The hostname - myzfsbox is also - shown in the commands after the pool's creation. The hostname - display becomes important when the pool is exported from one - system and imported on another. The commands that are issued - on the other system can clearly be distinguished by the - hostname that is recorded for each command. - - Both options to zpool history can be - combined to give the most detailed information possible for - any given pool. Pool history provides valuable information - when tracking down the actions that were performed or when - more detailed output is needed for debugging. + 輸出結果顯示 root 使用者使用 /dev/ada0/dev/ada1 建立鏡像的儲存池。主機名稱 myzfsbox 在建立完儲存池後也同樣會顯示。由於儲存池可以從一個系統匯出再匯入到另一個系統,因此主機名稱也很重要,這樣一來可以清楚的辦識在其他系統上執行的每一個指令的主機名稱。 + + 兩個 zpool history 選項可以合併使用來取得最完整的儲存池詳細資訊。儲存池歷史記錄在追蹤執行什麼動作或要取得除錯所需的輸出結果提供了非常有用的資訊。 監視效能 - A built-in monitoring system can display pool - I/O statistics in real time. It shows the - amount of free and used space on the pool, how many read and - write operations are being performed per second, and how much - I/O bandwidth is currently being utilized. - By default, all pools in the system are monitored and - displayed. A pool name can be provided to limit monitoring to - just that pool. A basic example: + 內建的監視系統可以即時顯示儲存池的 I/O 統計資訊。它會顯示儲存池剩餘的空間與使用的空間,每秒執行了多少讀取與寫入的操作,有多少 I/O 頻寬被使用。預設會監視所有在系統中的儲存池都並顯示出來,可以提供儲存池名稱來只顯示該儲存池的監視資訊。舉一個簡單的例子: # zpool iostat capacity operations bandwidth @@ -33028,25 +32462,9 @@ ---------- ----- ----- ----- ----- ----- ----- data 288G 1.53T 2 11 11.3K 57.1K - To continuously monitor I/O activity, a - number can be specified as the last parameter, indicating a - interval in seconds to wait between updates. The next - statistic line is printed after each interval. Press - - Ctrl - C - to stop this continuous monitoring. - Alternatively, give a second number on the command line after - the interval to specify the total number of statistics to - display. - - Even more detailed I/O statistics can - be displayed with . Each device in the - pool is shown with a statistics line. This is useful in - seeing how many read and write operations are being performed - on each device, and can help determine if any individual - device is slowing down the pool. This example shows a - mirrored pool with two devices: + 要持續監視 I/O 的活動可以在最後的參數指定一個數字,這個數字代表每次更新資訊所間隔的秒數。在每次經過間隔的時間後會列出新一行的統計資訊,按下 Ctrl C 可以中止監視。或者在指令列的間隔時間之後再指定一個數字,代表總共要顯示的統計資訊筆數。 + + 使用 可以顯示更詳細的 I/O 統計資訊。每個在儲存池中的裝置會以一行統計資訊顯示。這可以幫助了解每一個裝置做了多少讀取與寫入的操作,並可協助確認是否有各別裝置拖慢了整個儲存池的速度。以下範例會顯示有兩個裝置的鏡像儲存池: # zpool iostat -v capacity operations bandwidth @@ -33062,54 +32480,21 @@ 分割儲存儲存池 - A pool consisting of one or more mirror vdevs can be split - into two pools. Unless otherwise specified, the last member - of each mirror is detached and used to create a new pool - containing the same data. The operation should first be - attempted with . The details of the - proposed operation are displayed without it actually being - performed. This helps confirm that the operation will do what - the user intends. + 由一個或多個鏡像 vdev 所組成的儲存池可以切分開成兩個儲存池。除非有另外指定,否則每個鏡像的最後一個成員會被分離來然用來建立一個含有相同資料的新儲存池。在做這個操作的第一次應先使用 ,會顯示預計會做的操作而不會真的執行,這可以協助確認操作是否與使用者所要的相同。 <command>zfs</command> 管理 - The zfs utility is responsible for - creating, destroying, and managing all ZFS - datasets that exist within a pool. The pool is managed using - zpool. + zfs 工具負責建立、摧毀與管理在一個儲存池中所有的 ZFS 資料集。儲存池使用 zpool 來管理。 建立與摧毀資料集 - Unlike traditional disks and volume managers, space in - ZFS is not - preallocated. With traditional file systems, after all of the - space is partitioned and assigned, there is no way to add an - additional file system without adding a new disk. With - ZFS, new file systems can be created at any - time. Each dataset - has properties including features like compression, - deduplication, caching, and quotas, as well as other useful - properties like readonly, case sensitivity, network file - sharing, and a mount point. Datasets can be nested inside - each other, and child datasets will inherit properties from - their parents. Each dataset can be administered, - delegated, - replicated, - snapshotted, - jailed, and destroyed as a - unit. There are many advantages to creating a separate - dataset for each different type or set of files. The only - drawbacks to having an extremely large number of datasets is - that some commands like zfs list will be - slower, and the mounting of hundreds or even thousands of - datasets can slow the FreeBSD boot process. + 不同於傳統的磁碟與磁碟區管理程式 (Volume manager) ,在 ZFS 中的空間並會預先分配。傳統的檔案系統在分割與分配空間完後,若沒有增加新的磁碟便無法再增加額外的檔案系統。在 ZFS,可以隨時建立新的檔案系統,每個資料集 (Dataset) 都有自己的屬性,包含壓縮 (Compression)、去重複 (Deduplication)、快取 (Caching) 與配額 (Quota) 功能以及其他有用的屬性如唯讀 (Readonly)、區分大小寫 (Case sensitivity)、網路檔案分享 (Network file sharing) 以及掛載點 (Mount point)。資料集可以存在於其他資料集中,且子資料集會繼承其父資料集的屬性。每個資料集都可以作為一個單位來管理、委託 (Delegate)、備份 (Replicate)、快照 (Snapshot)、監禁 (Jail) 與摧毀 (Destroy),替每種不同類型或集合的檔案建立各別的資料集還有許多的好處。唯一的缺點是在當有非常大數量的資料集時,部份指令例如 zfs list 會變的較緩慢,且掛載上百個或其至上千個資料集可能會使 FreeBSD 的開機程序變慢。 - Create a new dataset and enable LZ4 - compression on it: + 建立一個新資料集並開啟 LZ4 壓縮: # zfs list NAME USED AVAIL REFER MOUNTPOINT @@ -33144,12 +32529,9 @@ mypool/var/mail 144K 93.2G 144K /var/mail mypool/var/tmp 152K 93.2G 152K /var/tmp - Destroying a dataset is much quicker than deleting all - of the files that reside on the dataset, as it does not - involve scanning all of the files and updating all of the - corresponding metadata. + 摧毀資料集會比刪除所有在資料集上所殘留的檔案來的快,由於摧毀資料集並不會掃描所有檔案並更新所有相關的 Metadata。 - Destroy the previously-created dataset: + 摧毀先前建立的資料集: # zfs list NAME USED AVAIL REFER MOUNTPOINT @@ -33184,44 +32566,15 @@ mypool/var/mail 144K 93.2G 144K /var/mail mypool/var/tmp 152K 93.2G 152K /var/tmp - In modern versions of ZFS, - zfs destroy is asynchronous, and the free - space might take several minutes to appear in the pool. Use - zpool get freeing - poolname to see the - freeing property, indicating how many - datasets are having their blocks freed in the background. - If there are child datasets, like - snapshots or other - datasets, then the parent cannot be destroyed. To destroy a - dataset and all of its children, use to - recursively destroy the dataset and all of its children. - Use to list datasets - and snapshots that would be destroyed by this operation, but - do not actually destroy anything. Space that would be - reclaimed by destruction of snapshots is also shown. + 在最近版本的 ZFSzfs destroy 是非同步的,且釋放出的空間會許要花費數分鐘才會出現在儲存池上,可使用 zpool get freeing poolname 來查看 freeing 屬性,這個屬性會指出資料集在背景已經釋放多少資料區塊了。若有子資料集,如快照 (Snapshot) 或其他資料集存在的話,則會無法摧毀父資料集。要摧毀一個資料集及其所有子資料集,可使用 來做遞迴摧毀資料集及其所有子資料集,可用 來列出會被這個操作所摧毀的資料集及快照,而不會真的摧毀,因摧毀快照所釋放出的空間也會同時顯示。 建立與摧毀磁碟區 - A volume is a special type of dataset. Rather than being - mounted as a file system, it is exposed as a block device - under - /dev/zvol/poolname/dataset. - This allows the volume to be used for other file systems, to - back the disks of a virtual machine, or to be exported using - protocols like iSCSI or - HAST. - - A volume can be formatted with any file system, or used - without a file system to store raw data. To the user, a - volume appears to be a regular disk. Putting ordinary file - systems on these zvols provides features - that ordinary disks or file systems do not normally have. For - example, using the compression property on a 250 MB - volume allows creation of a compressed FAT - file system. + 磁碟區 (Volume) 是特殊類型的資料集,不會被掛載成一個檔案系統,而是會被當做儲存區塊裝置出現在 /dev/zvol/poolname/dataset 下。這讓磁碟區可以用於其他檔案系統,備份虛擬機器的磁碟或是使用 iSCSIHAST 通訊協定匯出。 + + 磁碟區可以被格式化成任何檔案系統,或不使用檔案系統來儲存原始資料。對一般使用者,磁碟區就像是一般的磁碟,可以放置一般的檔案系統在這些 zvols上,並提供一般磁碟或檔案系統一般所沒有的功能。例如,使用壓縮屬性在一個 250 MB 的磁碟區可建立一個壓縮的 FAT 檔案系統。 # zfs create -V 250m -o compression=on tank/fat32 # zfs list tank @@ -33235,27 +32588,15 @@ # mount | grep fat32 /dev/zvol/tank/fat32 on /mnt (msdosfs, local) - Destroying a volume is much the same as destroying a - regular file system dataset. The operation is nearly - instantaneous, but it may take several minutes for the free - space to be reclaimed in the background. + 摧毀一個磁碟區與摧毀一個一般的檔案系統資料集差不多。操作上幾乎是即時的,但在背景會需要花費數分鐘來讓釋放空間再次可用。 重新命名資料集 - The name of a dataset can be changed with - zfs rename. The parent of a dataset can - also be changed with this command. Renaming a dataset to be - under a different parent dataset will change the value of - those properties that are inherited from the parent dataset. - When a dataset is renamed, it is unmounted and then remounted - in the new location (which is inherited from the new parent - dataset). This behavior can be prevented with - . + 資料集的名稱可以使用 zfs rename 更改。父資料集也同樣可以使用這個指令來更改名稱。重新命名一個資料集到另一個父資料集也會更改自父資料集繼承的屬性值。重新命名資料集後,會被卸載然後重新掛載到新的位置 (依繼承的新父資料集而定),可使用 來避免重新掛載。 - Rename a dataset and move it to be under a different - parent dataset: + 重新命名一個資料集並移動該資料集到另一個父資料集: # zfs list NAME USED AVAIL REFER MOUNTPOINT @@ -33291,11 +32632,7 @@ mypool/var/newname 87.5K 93.2G 87.5K /var/newname mypool/var/tmp 152K 93.2G 152K /var/tmp - Snapshots can also be renamed like this. Due to the - nature of snapshots, they cannot be renamed into a different - parent dataset. To rename a recursive snapshot, specify - , and all snapshots with the same name in - child datasets with also be renamed. + 快照也可以像這樣重新命名,由於快照的天性,使其無法被重新命名到另一個父資料集。要遞迴重新命名快照可指定 ,然後在子資料集中所有同名的快照也會一併被重新命名。 # zfs list -t snapshot NAME USED AVAIL REFER MOUNTPOINT @@ -33309,35 +32646,16 @@ 設定資料集屬性 - Each ZFS dataset has a number of - properties that control its behavior. Most properties are - automatically inherited from the parent dataset, but can be - overridden locally. Set a property on a dataset with - zfs set - property=value - dataset. Most - properties have a limited set of valid values, - zfs get will display each possible property - and valid values. Most properties can be reverted to their - inherited values using zfs inherit. - - User-defined properties can also be set. They become part - of the dataset configuration and can be used to provide - additional information about the dataset or its contents. To - distinguish these custom properties from the ones supplied as - part of ZFS, a colon (:) - is used to create a custom namespace for the property. + 每個 ZFS 資料集有數個屬性可以用來控制其行為。大部份的屬性會自動繼承自其父資料集,但可以被自己覆蓋。設定資料集上的屬性可使用 zfs set property=value dataset。大部份屬性有限制可用的值,zfs get 會顯示每個可以使用的屬性及其可用的值。大部份可以使用 zfs inherit 還原成其繼承的值。 + + 也可設定使用者自訂的屬性。這些屬性也會成為資料集設定的一部份,且可以被用來提供資料集或其內容的額外資訊。要別分自訂屬性與 ZFS 提供的屬性,會使用冒號 (:) 建立一個自訂命名空間供自訂屬性使用。 # zfs set custom:costcenter=1234 tank # zfs get custom:costcenter tank NAME PROPERTY VALUE SOURCE tank custom:costcenter 1234 local - To remove a custom property, use - zfs inherit with . If - the custom property is not defined in any of the parent - datasets, it will be removed completely (although the changes - are still recorded in the pool's history). + 要移除自訂屬性,可用 zfs inherit 加上 。若父資料集未定義任何自訂屬性,將會將該屬性完全移除 (更改動作仍會記錄於儲存池的歷史記錄)。 # zfs inherit -r custom:costcenter tank # zfs get custom:costcenter tank @@ -33350,59 +32668,16 @@ 管理快照 (Snapshot) - Snapshots are one - of the most powerful features of ZFS. A - snapshot provides a read-only, point-in-time copy of the - dataset. With Copy-On-Write (COW), - snapshots can be created quickly by preserving the older - version of the data on disk. If no snapshots exist, space is - reclaimed for future use when data is rewritten or deleted. - Snapshots preserve disk space by recording only the - differences between the current dataset and a previous - version. Snapshots are allowed only on whole datasets, not on - individual files or directories. When a snapshot is created - from a dataset, everything contained in it is duplicated. - This includes the file system properties, files, directories, - permissions, and so on. Snapshots use no additional space - when they are first created, only consuming space as the - blocks they reference are changed. Recursive snapshots taken - with create a snapshot with the same name - on the dataset and all of its children, providing a consistent - moment-in-time snapshot of all of the file systems. This can - be important when an application has files on multiple - datasets that are related or dependent upon each other. - Without snapshots, a backup would have copies of the files - from different points in time. - - Snapshots in ZFS provide a variety of - features that even other file systems with snapshot - functionality lack. A typical example of snapshot use is to - have a quick way of backing up the current state of the file - system when a risky action like a software installation or a - system upgrade is performed. If the action fails, the - snapshot can be rolled back and the system has the same state - as when the snapshot was created. If the upgrade was - successful, the snapshot can be deleted to free up space. - Without snapshots, a failed upgrade often requires a restore - from backup, which is tedious, time consuming, and may require - downtime during which the system cannot be used. Snapshots - can be rolled back quickly, even while the system is running - in normal operation, with little or no downtime. The time - savings are enormous with multi-terabyte storage systems and - the time required to copy the data from backup. Snapshots are - not a replacement for a complete backup of a pool, but can be - used as a quick and easy way to store a copy of the dataset at - a specific point in time. + 快照 (Snapshot) 是 ZFS 最強大的功能之一。快照提供了資料集唯讀、單一時間點 (Point-in-Time) 的複製功能,使用了寫入時複製 (Copy-On-Write, COW) 的技術,可以透過保存在磁碟上的舊版資料快速的建立快照。若沒有快照存在,在資料被覆蓋或刪除時,便回收空間供未來使用。由於只記錄前一個版本與目前資料集的差異,因此快照可節省磁碟空間。快照只允許在整個資料集上使用,無法在各別檔案或目錄。當建立了一個資料集的快照時,便備份了所有內含的資料,這包含了檔案系統屬性、檔案、目錄、權限等等。第一次建立快照時只會使用到更改參照到資料區塊的空間,不會用到額外的空間。使用 可以對使用同名的資料集及其所有子資料集的建立一個遞迴快照,提供一致且即時 (Moment-in-time) 的完整檔案系統快照功能,這對於那些彼此有相關或相依檔案存放在不同資料集的應用程式非常重要。若不使用快照,備份所複製的資料其實是不同時間點的,可能會有不一致的問題。 + + ZFS 中的快照提供了多種功能,即使是在其他缺乏快照功能的檔案系統上。一個使用快照的典型例子是在安裝軟體或執行系統升級這種有風險的動作時,能有一個快速的方式可以備份檔案系統目前的狀態,若動作失敗,可以使用快照還原 (Roll back) 到與快照建立時相同的系統狀態,若升級成功,便可刪除快照來釋放空間。若沒有快照功能,升級失敗通常會需要使用備份來恢復 (Restore) 系統,而這個動作非常繁瑣、耗時且可能會需要停機一段時間系統無法使用。使用快照可以快速的還原,即使系統正在執行一般的運作,只而要短暫或甚至不需停機。能夠節省大量在有數 TB 的儲存系統上從備份複製所需資料的時間。快照並非要用來取代儲存池的完整備份,但可以用在快速且簡單的保存某個特定時間點的資料集。 建立快照 - Snapshots are created with zfs snapshot - dataset@snapshotname. - Adding creates a snapshot recursively, - with the same name on all child datasets. + 快照可以使用 zfs snapshot dataset@snapshotname 來建立。加入 可以遞迴對所有同名的子資料集建立快照。 - Create a recursive snapshot of the entire pool: + 建立一個整個儲存池的遞迴快照: # zfs list -t all NAME USED AVAIL REFER MOUNTPOINT @@ -33440,33 +32715,16 @@ mypool/var/newname@my_recursive_snapshot 0 - 87.5K - mypool/var/tmp@my_recursive_snapshot 0 - 152K - - Snapshots are not shown by a normal - zfs list operation. To list snapshots, - is appended to - zfs list. - displays both file systems and snapshots. - - Snapshots are not mounted directly, so path is shown in - the MOUNTPOINT column. There is no - mention of available disk space in the - AVAIL column, as snapshots cannot be - written to after they are created. Compare the snapshot - to the original dataset from which it was created: + 建立的快照不會顯示在一般的 zfs list 操作結果,要列出快照需在 zfs list 後加上 ,使用 可以同時列出檔案系統的內容及快照。 + + 快照並不會直接掛載,因此 MOUNTPOINT 欄位的路徑如此顯示。在 AVAIL 欄位不會有可用的磁碟空間,因為快照建立之後便無法再寫入。比較快照與其原來建立時的資料集: # zfs list -rt all mypool/usr/home NAME USED AVAIL REFER MOUNTPOINT mypool/usr/home 184K 93.2G 184K /usr/home mypool/usr/home@my_recursive_snapshot 0 - 184K - - Displaying both the dataset and the snapshot together - reveals how snapshots work in - COW fashion. They save - only the changes (delta) that were made - and not the complete file system contents all over again. - This means that snapshots take little space when few changes - are made. Space usage can be made even more apparent by - copying a file to the dataset, then making a second - snapshot: + 同時顯示資料集與快照可以了解快照如何使用 COW 技術來運作。快照只會保存有更動 (差異) 的資料,並非整個檔案系統的內容,這個意思是說,快照只會在有做更動時使用一小部份的空間,複製一個檔案到該資料集,可以讓空間使用量變的更明顯,然後再做第二個快照: # cp /etc/passwd /var/tmp # zfs snapshot mypool/var/tmp@after_cp @@ -33476,27 +32734,13 @@ mypool/var/tmp@my_recursive_snapshot 88K - 152K - mypool/var/tmp@after_cp 0 - 118K - - The second snapshot contains only the changes to the - dataset after the copy operation. This yields enormous - space savings. Notice that the size of the snapshot - mypool/var/tmp@my_recursive_snapshot - also changed in the USED - column to indicate the changes between itself and the - snapshot taken afterwards. + 第二快照只會包含了資料集做了複製動作後的更動,這樣的機制可以節省大量的空間。注意在複製之後快照 mypool/var/tmp@my_recursive_snapshotUSED 欄位中的大小也更改了,這說明了這個更動在前次快照與之後快照間的關係。 比對快照 - ZFS provides a built-in command to compare the - differences in content between two snapshots. This is - helpful when many snapshots were taken over time and the - user wants to see how the file system has changed over time. - For example, zfs diff lets a user find - the latest snapshot that still contains a file that was - accidentally deleted. Doing this for the two snapshots that - were created in the previous section yields this - output: + ZFS 提供了內建指令可以用來比對兩個快照 (Snapshot) 之間的差異,在使用者想要查看一段時間之間檔案系統所的變更時非常有用。例如 zfs diff 可以讓使用者在最後一次快照中找到意外刪除的檔案。對前面一節所做的兩個快照使用這個指令會產生以下結果: # zfs list -rt all mypool/var/tmp NAME USED AVAIL REFER MOUNTPOINT @@ -33507,52 +32751,39 @@ M /var/tmp/ + /var/tmp/passwd - The command lists the changes between the specified - snapshot (in this case - mypool/var/tmp@my_recursive_snapshot) - and the live file system. The first column shows the - type of change: + 指令會列出指定快照 (在這個例子中為 mypool/var/tmp@my_recursive_snapshot) 與目前檔案系統間的更改。第一個欄位是更改的類型: + - The path or file was added. + 加入了該路徑或檔案。 - - The path or file was deleted. + 刪除了該路徑或檔案。 M - The path or file was modified. + 修改了該路徑或檔案。 R - The path or file was renamed. + 重新命名了該路徑或檔案。 - Comparing the output with the table, it becomes clear - that passwd - was added after the snapshot - mypool/var/tmp@my_recursive_snapshot - was created. This also resulted in a modification to the - parent directory mounted at - /var/tmp. - - Comparing two snapshots is helpful when using the - ZFS replication feature to transfer a - dataset to a different host for backup purposes. + 對照這個表格來看輸出的結果,可以明顯的看到 passwd 是在快照 mypool/var/tmp@my_recursive_snapshot 建立之後才加入的,結果也同樣看的到掛載到 /var/tmp 的父目錄已經做過修改。 + + 在使用 ZFS 備份功能來傳輸一個資料集到另一個主機備份時比對兩個快照也同樣很有用。 - Compare two snapshots by providing the full dataset name - and snapshot name of both datasets: + 比對兩個快照需要提供兩個資料集的完整資料集名稱與快照名稱:# cp /var/tmp/passwd /var/tmp/passwd.copy # zfs snapshot mypool/var/tmp@diff_snapshot @@ -33564,45 +32795,15 @@ M /var/tmp/ + /var/tmp/passwd - A backup administrator can compare two snapshots - received from the sending host and determine the actual - changes in the dataset. See the - Replication section for - more information. + 備份管理者可以比對兩個自傳送主機所接收到的兩個快照並查看實際在資料集中的變更。請參考 備份 一節來取得更多資訊。 使用快照還原 - When at least one snapshot is available, it can be - rolled back to at any time. Most of the time this is the - case when the current state of the dataset is no longer - required and an older version is preferred. Scenarios such - as local development tests have gone wrong, botched system - updates hampering the system's overall functionality, or the - requirement to restore accidentally deleted files or - directories are all too common occurrences. Luckily, - rolling back a snapshot is just as easy as typing - zfs rollback - snapshotname. - Depending on how many changes are involved, the operation - will finish in a certain amount of time. During that time, - the dataset always remains in a consistent state, much like - a database that conforms to ACID principles is performing a - rollback. This is happening while the dataset is live and - accessible without requiring a downtime. Once the snapshot - has been rolled back, the dataset has the same state as it - had when the snapshot was originally taken. All other data - in that dataset that was not part of the snapshot is - discarded. Taking a snapshot of the current state of the - dataset before rolling back to a previous one is a good idea - when some data is required later. This way, the user can - roll back and forth between snapshots without losing data - that is still valuable. - - In the first example, a snapshot is rolled back because - of a careless rm operation that removes - too much data than was intended. + 只要至少有一個可用的快照便可以隨時還原。大多數在已不需要目前資料集,想要改用較舊版的資料的情況,例如,本地開發的測試發生錯誤、不良的系統更新破壞了系統的整體功能或需要還原意外刪除檔案或目錄 ... 等,都是非常常見的情形。幸運的,要還原到某個快照只需要簡單輸入 zfs rollback snapshotname。會依快照所做的變更數量來決定處理的時間,還原的操作會在一段時間後完成。在這段時間中,資料集會一直保持一致的狀態,類似一個符合 ACID 原則的資料庫在做還原。還原可在資料集處於上線及可存取的情況下完成,不需要停機。還原到快照之後,資料集便回到當初執行快照時相同的狀態,所有沒有在快照中的其他資料便會被丟棄,因此往後若還有可能需要部份資料時,建議在還原到前一個快照之前先對目前的資料集做快照,這樣一來,使用者便可以在快照之間來回快換,而不會遺失重要的資料。 + + 在第一個範例中,因為 rm 操作不小心移除了預期外的資料,要還原到快照。 # zfs list -rt all mypool/var/tmp NAME USED AVAIL REFER MOUNTPOINT @@ -33617,22 +32818,13 @@ vi.recover % - At this point, the user realized that too many files - were deleted and wants them back. ZFS - provides an easy way to get them back using rollbacks, but - only when snapshots of important data are performed on a - regular basis. To get the files back and start over from - the last snapshot, issue the command: + 在此時,使用者發現到刪除了太多檔案並希望能夠還原。ZFS 提供了簡單的方可以取回檔案,便是使用還原 (Rollback),但這只在有定期對重要的資料使用快照時可用。要拿回檔案並從最後一次快照重新開始,可執行以下指令: # zfs rollback mypool/var/tmp@diff_snapshot % ls /var/tmp passwd passwd.copy vi.recover - The rollback operation restored the dataset to the state - of the last snapshot. It is also possible to roll back to a - snapshot that was taken much earlier and has other snapshots - that were created after it. When trying to do this, - ZFS will issue this warning: + 還原操作會將資料集還原為最後一次快照的狀態。這也可以還原到更早之前,有其他在其之後建立的快照。要這麼做時,ZFS 會發出這個警告: # zfs list -rt snapshot mypool/var/tmp AME USED AVAIL REFER MOUNTPOINT @@ -33645,17 +32837,7 @@ mypool/var/tmp@after_cp mypool/var/tmp@diff_snapshot - This warning means that snapshots exist between the - current state of the dataset and the snapshot to which the - user wants to roll back. To complete the rollback, these - snapshots must be deleted. ZFS cannot - track all the changes between different states of the - dataset, because snapshots are read-only. - ZFS will not delete the affected - snapshots unless the user specifies to - indicate that this is the desired action. If that is the - intention, and the consequences of losing all intermediate - snapshots is understood, the command can be issued: + 這個警告是因在該快照與資料集的目前狀態之間有其他快照存在,然而使用者想要還原到該快照。要完成這樣的還原動作,必須刪除在這之間的快照,因為 ZFS 無法追蹤不同資料集狀態間的變更。在使用者未指定 來確認這個動作前,ZFS 不會刪除受影響的快照。若確定要這麼做,那麼必須要知道會遺失所有在這之間的快照,然後可執行以下指令: # zfs rollback -r mypool/var/tmp@my_recursive_snapshot # zfs list -rt snapshot mypool/var/tmp @@ -33664,27 +32846,13 @@ % ls /var/tmp vi.recover - The output from zfs list -t snapshot - confirms that the intermediate snapshots - were removed as a result of - zfs rollback -r. + 可從 zfs list -t snapshot 的結果來確認 zfs rollback -r 會移除的快照。 - 自快照還原單一檔案 + 從快照還原個別檔案 - Snapshots are mounted in a hidden directory under the - parent dataset: - .zfs/snapshots/snapshotname. - By default, these directories will not be displayed even - when a standard ls -a is issued. - Although the directory is not displayed, it is there - nevertheless and can be accessed like any normal directory. - The property named snapdir controls - whether these hidden directories show up in a directory - listing. Setting the property to visible - allows them to appear in the output of ls - and other commands that deal with directory contents. + 快照會掛載在父資料集下的隱藏目錄:.zfs/snapshots/snapshotname。預設不會顯示這些目錄,即使是用 ls -a 指令。雖然該目錄不會顯示,但該目錄實際存在,而且可以像一般的目錄一樣存取。一個名稱為 snapdir 的屬性可以控制是否在目錄清單中顯示這些隱藏目錄,設定該屬性為可見 (visible) 可以讓這些目錄出現在 ls 以及其他處理目錄內容的指令中。 # zfs get snapdir mypool/var/tmp NAME PROPERTY VALUE SOURCE @@ -33695,16 +32863,7 @@ % ls -a /var/tmp . .. .zfs passwd vi.recover - Individual files can easily be restored to a previous - state by copying them from the snapshot back to the parent - dataset. The directory structure below - .zfs/snapshot has a directory named - exactly like the snapshots taken earlier to make it easier - to identify them. In the next example, it is assumed that a - file is to be restored from the hidden - .zfs directory by copying it from the - snapshot that contained the latest version of the - file: + 要還原個別檔案到先前的狀態非常簡單,只要從快照中複製檔案到父資料集。在 .zfs/snapshot 目錄結構下有一個與先前所做的快照名稱相同的目錄,可以很容易的找到。在下個範例中,我們會示範從隱藏的 .zfs 目錄還原一個檔案,透過從含有該檔案的最新版快照複製: # rm /var/tmp/passwd % ls -a /var/tmp @@ -33715,61 +32874,25 @@ passwd vi.recover # cp /var/tmp/.zfs/snapshot/after_cp/passwd /var/tmp - When ls .zfs/snapshot was issued, the - snapdir property might have been set to - hidden, but it would still be possible to list the contents - of that directory. It is up to the administrator to decide - whether these directories will be displayed. It is possible - to display these for certain datasets and prevent it for - others. Copying files or directories from this hidden - .zfs/snapshot is simple enough. Trying - it the other way around results in this error: + 執行 ls .zfs/snapshot 時,雖然 snapdir 可能已經設為隱藏,但仍可能可以顯示該目錄中的內容,這取決於管理者是否要顯示這些目錄,可以只顯示特定的資料集,而其他的則不顯示。從這個隱藏的 .zfs/snapshot 複製檔案或目錄非常簡單,除此之外,嘗試其他的動作則會出現以下錯誤: # cp /etc/rc.conf /var/tmp/.zfs/snapshot/after_cp/ cp: /var/tmp/.zfs/snapshot/after_cp/rc.conf: Read-only file system - The error reminds the user that snapshots are read-only - and cannot be changed after creation. Files cannot be - copied into or removed from snapshot directories because - that would change the state of the dataset they - represent. - - Snapshots consume space based on how much the parent - file system has changed since the time of the snapshot. The - written property of a snapshot tracks how - much space is being used by the snapshot. - - Snapshots are destroyed and the space reclaimed with - zfs destroy - dataset@snapshot. - Adding recursively removes all snapshots - with the same name under the parent dataset. Adding - to the command displays a list of the - snapshots that would be deleted and an estimate of how much - space would be reclaimed without performing the actual - destroy operation. + 這個錯誤用來提醒使用者快照是唯讀的,在建立之後不能更改。無法複製檔案進去或從該快照目錄中移除,因為這會變更該資料集所代表的狀態。 + + 快照所消耗的空間是依據自快照之後父檔案系統做了多少變更來決定,快照的 written 屬性可以用來追蹤有多少空間被快照所使用。 + + 使用 zfs destroy dataset@snapshot 可以摧毀快照並回收空間。加上 可以遞迴移除所有在父資料集下使用同名的快照。加入 來顯示將要移除的快照清單以及估計回收的空間,而不會實際執行摧毀的操作。 管理複本 (Clone) - A clone is a copy of a snapshot that is treated more like - a regular dataset. Unlike a snapshot, a clone is not read - only, is mounted, and can have its own properties. Once a - clone has been created using zfs clone, the - snapshot it was created from cannot be destroyed. The - child/parent relationship between the clone and the snapshot - can be reversed using zfs promote. After a - clone has been promoted, the snapshot becomes a child of the - clone, rather than of the original parent dataset. This will - change how the space is accounted, but not actually change the - amount of space consumed. The clone can be mounted at any - point within the ZFS file system hierarchy, - not just below the original location of the snapshot. + 複本 (Clone) 是快照的複製,但更像是一般的資料集,與快照不同的是,複本是非唯讀的 (可寫),且可掛載,可以有自己的屬性。使用 zfs clone 建立複本之後,便無法再摧毀用來建立複本的快照。複本與快照的父/子關係可以使用 zfs promote 來對換。提升複本之後 ,快照便會成為複本的子資料集,而不是原來的父資料集,這個動作會改變空間計算的方式,但並不會實際改變空間的使用量。複本可以被掛載到 ZFS 檔案系統階層中的任何一點,並非只能位於原來快照的位置底下。 - To demonstrate the clone feature, this example dataset is - used: + 要示範複本功能會用到這個範例資料集: # zfs list -rt all camino/home/joe NAME USED AVAIL REFER MOUNTPOINT @@ -33777,14 +32900,7 @@ camino/home/joe@plans 21K - 85.5K - camino/home/joe@backup 0K - 87K - - A typical use for clones is to experiment with a specific - dataset while keeping the snapshot around to fall back to in - case something goes wrong. Since snapshots cannot be - changed, a read/write clone of a snapshot is created. After - the desired result is achieved in the clone, the clone can be - promoted to a dataset and the old file system removed. This - is not strictly necessary, as the clone and dataset can - coexist without problems. + 會使用到複本一般是要在可以保留快照以便出錯時可還原的情況下使用指定的資料集做實驗,由於快照並無法做更改,所以會建立一個可以讀/寫的快照複本。當在複本中做完想要執行的動作後,便可以提升複本成資料集,然後移除舊的檔案系統。嚴格來說這並非必要,因為複本與資料集可同時存在,不會有任何問題。 # zfs clone camino/home/joe@backup camino/home/joenew # ls /usr/home/joe* @@ -33798,16 +32914,7 @@ usr/home/joe 1.3G 31k 1.3G 0% /usr/home/joe usr/home/joenew 1.3G 31k 1.3G 0% /usr/home/joenew - After a clone is created it is an exact copy of the state - the dataset was in when the snapshot was taken. The clone can - now be changed independently from its originating dataset. - The only connection between the two is the snapshot. - ZFS records this connection in the property - origin. Once the dependency between the - snapshot and the clone has been removed by promoting the clone - using zfs promote, the - origin of the clone is removed as it is now - an independent dataset. This example demonstrates it: + 建立完的複本便有與建立快照時狀態相同的資料集,現在複本可以獨立於原來的資料集來做更改。剩下唯一與資料集之間的關係便是快照,ZFS 會在屬性 origin 記錄這個關係,一旦在快照與複本之間的相依關係因為使用 zfs promote 提升而移除時,複本的 origin 也會因為成為一個完全獨立的資料集而移除。以下範例會示範這個動作: # zfs get origin camino/home/joenew NAME PROPERTY VALUE SOURCE @@ -33817,14 +32924,7 @@ NAME PROPERTY VALUE SOURCE camino/home/joenew origin - - - After making some changes like copying - loader.conf to the promoted clone, for - example, the old directory becomes obsolete in this case. - Instead, the promoted clone can replace it. This can be - achieved by two consecutive commands: zfs - destroy on the old dataset and zfs - rename on the clone to name it like the old - dataset (it could also get an entirely different name). + 做為部份更改之後,例如複製 loader.conf 到提升後的複本,這個例子中的舊目錄便無須保留,取而代之的是提升後的複本,這個動作可以用兩個連續的指令來完成:在舊資料集上執行 zfs destroy 並在與舊資料相似名稱 (也可能用完全不同的名稱) 的複本上執行 zfs rename # cp /boot/defaults/loader.conf /usr/home/joenew # zfs destroy -f camino/home/joe @@ -33835,81 +32935,35 @@ Filesystem Size Used Avail Capacity Mounted on usr/home/joe 1.3G 128k 1.3G 0% /usr/home/joe - The cloned snapshot is now handled like an ordinary - dataset. It contains all the data from the original snapshot - plus the files that were added to it like - loader.conf. Clones can be used in - different scenarios to provide useful features to ZFS users. - For example, jails could be provided as snapshots containing - different sets of installed applications. Users can clone - these snapshots and add their own applications as they see - fit. Once they are satisfied with the changes, the clones can - be promoted to full datasets and provided to end users to work - with like they would with a real dataset. This saves time and - administrative overhead when providing these jails. + 快照的複本現在可以如同一般資料集一樣使用,它的內容包含了所有來自原始快照的資料以及後來加入的檔案,例如 loader.conf。複本可以在許多不同的情境下使用提供 ZFS 的使用者有用的功能,例如,Jail 可以透過含有已安裝了各種應用程式集的快照來提供,使用者可以複製這些快照然後加入自己想要嘗試的應用程式,一但更改可以滿足需求,便可提升複本為完整的資料集然後提供給終端使用者,讓終端使用者可以如同實際擁有資料集一般的使用,這個以節省提供這些 Jail 的時間與管理成本。 - 備援 + 備份 (Replication) - Keeping data on a single pool in one location exposes - it to risks like theft and natural or human disasters. Making - regular backups of the entire pool is vital. - ZFS provides a built-in serialization - feature that can send a stream representation of the data to - standard output. Using this technique, it is possible to not - only store the data on another pool connected to the local - system, but also to send it over a network to another system. - Snapshots are the basis for this replication (see the section - on ZFS - snapshots). The commands used for replicating data - are zfs send and - zfs receive. + 將資料保存在單一地點的單一儲存池上會讓資料暴露在盜竊、自然或人為的風險之下,定期備份整個儲存池非常重要,ZFS 提供了內建的序列化 (Serialization) 功能可以將資料以串流傳送到標準輸出。使用這項技術,不僅可以將資料儲存到另一個已連結到本地系統的儲存池,也可以透過網路將資料傳送到另一個系統,這種備份方式以快照為基礎 (請參考章節 ZFS 快照(Snapshot))。用來備份資料的指令為 zfs sendzfs receive - These examples demonstrate ZFS - replication with these two pools: + 以下例子將示範使用兩個儲存池來做 ZFS 備份: # zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT backup 960M 77K 896M 0% 1.00x ONLINE - mypool 984M 43.7M 940M 4% 1.00x ONLINE - - The pool named mypool is the - primary pool where data is written to and read from on a - regular basis. A second pool, - backup is used as a standby in case - the primary pool becomes unavailable. Note that this - fail-over is not done automatically by ZFS, - but must be manually done by a system administrator when - needed. A snapshot is used to provide a consistent version of - the file system to be replicated. Once a snapshot of - mypool has been created, it can be - copied to the backup pool. Only - snapshots can be replicated. Changes made since the most - recent snapshot will not be included. + 名為 mypool 的儲存池為主要的儲存池,資料會定期寫入與讀取的位置。第二個儲存池 backup 用來待命 (Standby),萬一主要儲存池無法使用時可替換。注意,ZFS 並不會自動做容錯移轉 (Fail-over),必須要由系統管理者在需要的時候手動完成。快照會用來提供一個與檔系統一致的版本來做備份,mypool 的快照建立之後,便可以複製到 backup 儲存池,只有快照可以做備份,最近一次快照之後所做的變更不會含在內容裡面。 # zfs snapshot mypool@backup1 # zfs list -t snapshot NAME USED AVAIL REFER MOUNTPOINT mypool@backup1 0 - 43.6M - - Now that a snapshot exists, zfs send - can be used to create a stream representing the contents of - the snapshot. This stream can be stored as a file or received - by another pool. The stream is written to standard output, - but must be redirected to a file or pipe or an error is - produced: + 快照存在以後,便可以使用 zfs send 來建立一個代表快照內容的串流,這個串流可以儲存成檔案或由其他儲存池接收。串流會寫入到標準輸出,但是必須要重新導向到一個檔案或轉接到其他地方,否則會錯誤: # zfs send mypool@backup1 Error: Stream can not be written to a terminal. You must redirect standard output. - To back up a dataset with zfs send, - redirect to a file located on the mounted backup pool. Ensure - that the pool has enough free space to accommodate the size of - the snapshot being sent, which means all of the data contained - in the snapshot, not just the changes from the previous - snapshot. + 要使用 zfs send 備份一個資料集,可重新導向到一個位於在已掛載到備份儲存池上的檔案。確定該儲存池有足夠的空間容納要傳送的快照,這裡指的是該快照中內含的所有資料,並非只有上次快照到該快照間的變更。 # zfs send mypool@backup1 > /backup/backup1 # zpool list @@ -33917,23 +32971,9 @@ backup 960M 63.7M 896M 6% 1.00x ONLINE - mypool 984M 43.7M 940M 4% 1.00x ONLINE - - The zfs send transferred all the data - in the snapshot called backup1 to - the pool named backup. Creating - and sending these snapshots can be done automatically with a - cron8 job. - - Instead of storing the backups as archive files, - ZFS can receive them as a live file system, - allowing the backed up data to be accessed directly. To get - to the actual data contained in those streams, - zfs receive is used to transform the - streams back into files and directories. The example below - combines zfs send and - zfs receive using a pipe to copy the data - from one pool to another. The data can be used directly on - the receiving pool after the transfer is complete. A dataset - can only be replicated to an empty dataset. + zfs send 會傳輸在快照 backup1 中所有的資料到儲存池 backup。可以使用 cron8 排程來自動完成建立與傳送快照的動作。 + + 若不想將備份以封存檔案儲存,ZFS 可用實際的檔案系統來接收資料,讓備份的資料可以直接被存取。要取得實際包含在串流中的資料可以用 zfs receive 將串流轉換回檔案與目錄。以下例子會以管線符號連接 zfs sendzfs receive,將資料從一個儲存池複製到另一個,傳輸完成後可以直接使用接收儲存池上的資料。一個資料集只可以被複製到另一個空的資料集。 # zfs snapshot mypool@replica1 # zfs send -v mypool@replica1 | zfs receive backup/mypool @@ -33949,10 +32989,7 @@ 漸進式備份 - zfs send can also determine the - difference between two snapshots and send only the - differences between the two. This saves disk space and - transfer time. For example: + zfs send 也可以比較兩個快照之間的差異,並且只傳送兩者之間的差異,這麼做可以節省磁碟空間及傳輸時間。例如: # zfs snapshot mypool@replica2 # zfs list -t snapshot @@ -33964,16 +33001,7 @@ backup 960M 61.7M 898M 6% 1.00x ONLINE - mypool 960M 50.2M 910M 5% 1.00x ONLINE - - A second snapshot called - replica2 was created. This - second snapshot contains only the changes that were made to - the file system between now and the previous snapshot, - replica1. Using - zfs send -i and indicating the pair of - snapshots generates an incremental replica stream containing - only the data that has changed. This can only succeed if - the initial snapshot already exists on the receiving - side. + 會建立一個名為 replica2 的第二個快照,這個快照只中只會含有目前與前次快照 replica1 之間檔案系統所做的變更。使用 zfs send -i 並指定要用來產生漸進備份串流的快照,串流中只會含有做過更改的資料。這個動作只在接收端已經有初始快照時才可用。 # zfs send -v -i mypool@replica1 mypool@replica2 | zfs receive /backup/mypool send from @replica1 to mypool@replica2 estimated size is 5.02M @@ -33998,85 +33026,37 @@ mypool@replica1 29.9K - 50.0M - mypool@replica2 0 - 55.0M - - The incremental stream was successfully transferred. - Only the data that had changed was replicated, rather than - the entirety of replica1. Only - the differences were sent, which took much less time to - transfer and saved disk space by not copying the complete - pool each time. This is useful when having to rely on slow - networks or when costs per transferred byte must be - considered. - - A new file system, - backup/mypool, is available with - all of the files and data from the pool - mypool. If - is specified, the properties of the dataset will be copied, - including compression settings, quotas, and mount points. - When is specified, all child datasets of - the indicated dataset will be copied, along with all of - their properties. Sending and receiving can be automated so - that regular backups are created on the second pool. + 如此一來,便成功傳輸漸進式的串流,只有做過更改的資料會被備份,不會傳送完整的 replica1。由於不會備份完整的儲存池,只傳送差異的部份,所以可以減少傳輸的時間並節省磁碟空間,特別是在網路緩慢或需要考量每位元傳輸成本時非常有用。 + + 從儲存池 mypool 複製所有檔案與資料的新檔案系統 backup/mypool 便可以使用。若指定 ,會一併複製資料集的屬性,這包含壓縮 (Compression) 設定,配額 (Quota) 及掛載點 (Mount point)。若指定 ,會複製所有指定資料集的子資料集,及這些子資料集的所有屬性。可將傳送與接收自動化來定期使用第二個儲存池做備份。 - 透過 <application>SSH</application> 傳送已加密的備份 + 透過 <application>SSH</application> 傳送加密的備份 - Sending streams over the network is a good way to keep a - remote backup, but it does come with a drawback. Data sent - over the network link is not encrypted, allowing anyone to - intercept and transform the streams back into data without - the knowledge of the sending user. This is undesirable, - especially when sending the streams over the internet to a - remote host. SSH can be used to - securely encrypt data send over a network connection. Since - ZFS only requires the stream to be - redirected from standard output, it is relatively easy to - pipe it through SSH. To keep the - contents of the file system encrypted in transit and on the - remote system, consider using PEFS. - - A few settings and security precautions must be - completed first. Only the necessary steps required for the - zfs send operation are shown here. For - more information on SSH, see - . + 透過網路來傳送串流對要遠端備份是相當不錯的方式,但是也有一些缺點,透過網路連結傳送的資料沒有加密,這會讓任何人都可以在未告知傳送使用者的情況下攔截並轉換串流回資料,這是我們所不想見到的情況,特別是在使用網際網路傳送串流到遠端的主機時。SSH 可用來安全的加密要透過網路連線傳送的資料,在 ZFS 只需要從標準輸出重新導向便可簡單的轉接到 SSH。要在傳送或在遠端系統中維持檔案系統內容在加密的狀態也可考慮使用 PEFS。 - This configuration is required: + 有一些設定以及安全性注意事項必須先完成,只有對 zfs send 操作必要的步驟才會在此說明,要取得更多有關 SSH 的資訊請參考 + + 必要的環境設定: - Passwordless SSH access - between sending and receiving host using - SSH keys + 使用 SSH 金鑰設定傳送端與接收端間無密碼的 SSH 存取 - Normally, the privileges of the - root user are - needed to send and receive streams. This requires - logging in to the receiving system as - root. - However, logging in as - root is - disabled by default for security reasons. The - ZFS Delegation - system can be used to allow a - non-root user - on each system to perform the respective send and - receive operations. + 正常會需要 root 的權限來傳送與接收串流,這需要可以 root 登入到接收端系統。但是,預設因安全性考慮會關閉以 root 登入。ZFS 委託 (ZFS Delegation) 系統可以用來允許一個非 root 使用者在每個系統上執行各自的發送與接收操作。 - On the sending system: + 在傳送端系統上: # zfs allow -u someuser send,snapshot mypool - To mount the pool, the unprivileged user must own - the directory, and regular users must be allowed to - mount file systems. On the receiving system: + 要掛載儲存池,無權限的使用者必須擁有該目錄且必須允許一般的使用者掛載檔案系統。在接收端系統上: # sysctl vfs.usermount=1 vfs.usermount: 0 -> 1 @@ -34087,146 +33067,79 @@ - The unprivileged user now has the ability to receive and - mount datasets, and the home - dataset can be replicated to the remote system: + 無權限的使用者現在有能力可以接收並掛載資料集,且 home 資料集可以被複製到遠端系統: % zfs snapshot -r mypool/home@monday % zfs send -R mypool/home@monday | ssh someuser@backuphost zfs recv -dvu recvpool/backup - A recursive snapshot called - monday is made of the file system - dataset home that resides on the - pool mypool. Then it is sent - with zfs send -R to include the dataset, - all child datasets, snaphots, clones, and settings in the - stream. The output is piped to the waiting - zfs receive on the remote host - backuphost through - SSH. Using a fully qualified - domain name or IP address is recommended. The receiving - machine writes the data to the - backup dataset on the - recvpool pool. Adding - to zfs recv - overwrites the name of the pool on the receiving side with - the name of the snapshot. causes the - file systems to not be mounted on the receiving side. When - is included, more detail about the - transfer is shown, including elapsed time and the amount of - data transferred. + 替儲存在儲存池 mypool 上的檔案系統資料集 home 製作一個遞迴快照 monday,然後使用 zfs send -R 來傳送包含該資料集及其所有子資料集、快照、複製與設定的串流。輸出會被導向到 SSH 連線的遠端主機 backuphost 上等候輸入的 zfs receive,在此建議使用完整網域名稱或 IP 位置。接收端的機器會寫入資料到 recvpool 儲存池上的 backup 資料集,在 zfs recv 加上 可覆寫在接收端使用相同名稱的快照,加上 可讓檔案系統在接收端不會被掛載,當使用 ,會顯示更多有關傳輸的詳細資訊,包含已花費的時間及已傳輸的資料量。 資料集、使用者以及群組配額 - Dataset quotas are - used to restrict the amount of space that can be consumed - by a particular dataset. - Reference Quotas work - in very much the same way, but only count the space - used by the dataset itself, excluding snapshots and child - datasets. Similarly, - user and - group quotas can be - used to prevent users or groups from using all of the - space in the pool or dataset. + 資料集配額 (Dataset quota) 可用來限制特定資料集可以使用的的空間量。參考配額 (Reference Quota) 的功能也非常相似,差在參考配額只會計算資料集自己使用的空間,不含快照與子資料集。類似的,使用者 (User) 與群組 (Group) 配額可以用來避免使用者或群組用掉儲存池或資料集的所有空間。 - To enforce a dataset quota of 10 GB for - storage/home/bob: + 要設定 storage/home/bob 的資料集配額為 10 GB: # zfs set quota=10G storage/home/bob - To enforce a reference quota of 10 GB for - storage/home/bob: + 要設定 storage/home/bob 的參考配額為 10 GB: # zfs set refquota=10G storage/home/bob - To remove a quota of 10 GB for - storage/home/bob: + 要移除 storage/home/bob 的 10 GB 配額: # zfs set quota=none storage/home/bob - The general format is - userquota@user=size, - and the user's name must be in one of these formats: + 設定使用者配額的一般格式為 userquota@user=size 使用者的名稱必須使用以下格式: - POSIX compatible name such as - joe. + POSIX 相容的名稱,如 joe - POSIX numeric ID such as - 789. + POSIX 數字 ID,如 789 - SID name - such as - joe.bloggs@example.com. + SID 名稱,如 joe.bloggs@example.com - SID - numeric ID such as - S-1-123-456-789. + SID 數字 ID,如 S-1-123-456-789 - For example, to enforce a user quota of 50 GB for the - user named joe: + 例如,要設定使用者名為 joe 的使用者配額為 50 GB: # zfs set userquota@joe=50G - To remove any quota: + 要移除所有配額: # zfs set userquota@joe=none - User quota properties are not displayed by - zfs get all. - Non-root users can - only see their own quotas unless they have been granted the - userquota privilege. Users with this - privilege are able to view and set everyone's quota. + 使用者配額的屬性不會顯示在 zfs get all。非 root 的使用者只可以看到自己的配額,除非它們有被授予 userquota 權限,擁有這個權限的使用者可以檢視與設定任何人的配額。 - The general format for setting a group quota is: - groupquota@group=size. + 要設定群組配額的一般格式為:groupquota@group=size - To set the quota for the group - firstgroup to 50 GB, - use: + 要設定群組 firstgroup 的配額為 50 GB 可使用: # zfs set groupquota@firstgroup=50G - To remove the quota for the group - firstgroup, or to make sure that - one is not set, instead use: + 要移除群組 firstgroup 的配額,或確保該群組未設定配額可使用: # zfs set groupquota@firstgroup=none - As with the user quota property, - non-root users can - only see the quotas associated with the groups to which they - belong. However, - root or a user with - the groupquota privilege can view and set - all quotas for all groups. - - To display the amount of space used by each user on - a file system or snapshot along with any quotas, use - zfs userspace. For group information, use - zfs groupspace. For more information about - supported options or how to display only specific options, - refer to zfs1. - - Users with sufficient privileges, and - root, can list the - quota for storage/home/bob using: + 如同使用者配額屬性,非 root 使用者只可以查看自己所屬群組的配額。而 root 或擁有 groupquota 權限的使用者,可以檢視並設定所有群組的任何配額。 + + 要顯示在檔案系統或快照上每位使用者所使用的空間量及配額可使用 zfs userspace,要取得群組的資訊則可使用 zfs groupspace,要取得有關支援的選項資訊或如何只顯示特定選項的資訊請參考 zfs1 + + 有足夠權限的使用者及 root 可以使用以下指令列出 storage/home/bob 的配額: # zfs get quota storage/home/bob @@ -34234,33 +33147,19 @@ 保留空間 - Reservations - guarantee a minimum amount of space will always be available - on a dataset. The reserved space will not be available to any - other dataset. This feature can be especially useful to - ensure that free space is available for an important dataset - or log files. - - The general format of the reservation - property is - reservation=size, - so to set a reservation of 10 GB on - storage/home/bob, use: + 保留空間 (Reservation) 可以確保資料集最少可用的空間量,其他任何資料集無法使用保留的空間,這個功能在要確保有足夠的可用空間來存放重要的資料集或日誌檔時特別有用。 + + reservation 屬性的一般格式為 reservation=size,所以要在 storage/home/bob 設定保留 10 GB 的空間可以用: # zfs set reservation=10G storage/home/bob - To clear any reservation: + 要清除任何保留空間: # zfs set reservation=none storage/home/bob - The same principle can be applied to the - refreservation property for setting a - Reference - Reservation, with the general format - refreservation=size. + 同樣的原則可以應用在 refreservation 屬性來設定參考保留空間 (Reference Reservation),參考保留空間的一般格式為 refreservation=size - This command shows any reservations or refreservations - that exist on storage/home/bob: + 這個指令會顯示任何已設定於 storage/home/bob 的 reservation 或 refreservation: # zfs get reservation storage/home/bob # zfs get refreservation storage/home/bob @@ -34269,34 +33168,11 @@ 壓縮 (Compression) - ZFS provides transparent compression. - Compressing data at the block level as it is written not only - saves space, but can also increase disk throughput. If data - is compressed by 25%, but the compressed data is written to - the disk at the same rate as the uncompressed version, - resulting in an effective write speed of 125%. Compression - can also be a great alternative to - Deduplication - because it does not require additional memory. - - ZFS offers several different - compression algorithms, each with different trade-offs. With - the introduction of LZ4 compression in - ZFS v5000, it is possible to enable - compression for the entire pool without the large performance - trade-off of other algorithms. The biggest advantage to - LZ4 is the early abort - feature. If LZ4 does not achieve at least - 12.5% compression in the first part of the data, the block is - written uncompressed to avoid wasting CPU cycles trying to - compress data that is either already compressed or - uncompressible. For details about the different compression - algorithms available in ZFS, see the - Compression entry - in the terminology section. + ZFS 提供直接的壓縮功能,在資料區塊層級壓縮資料不僅可以節省空間,也可以增加磁碟的效能。若資料壓縮了 25%,但壓縮的資料會使用了與未壓縮版本相同的速率寫入到磁碟,所以實際的寫入速度會是原來的 125%。壓縮功能也可來替代去重複 (Deduplication) 功能,因為壓縮並不需要使用額外的記憶體。 - The administrator can monitor the effectiveness of - compression using a number of dataset properties. + ZFS 提了多種不同的壓縮演算法,每一種都有不同的優缺點,隨著 ZFS v5000 引進了 LZ4 壓縮技術,可對整個儲存池開啟壓縮,而不像其他演算法需要消耗大量的效能來達成,最大的優點是 LZ4 擁有 提早放棄 的功能,若 LZ4 無法在資料一開始的部份達成至少 12.5% 的壓縮率,便會以不壓縮的方式來寫入資料區塊來避免 CPU 在那些已經壓縮過或無法壓縮的資料上浪費運算能力。要取得更多有關 ZFS 中可用的壓縮演算法詳細資訊,可參考術語章節中的壓縮 (Compression) 項目。 + + 管理者可以使用資料集的屬性來監視壓縮的效果。 # zfs get used,compressratio,compression,logicalused mypool/compressed_dataset NAME PROPERTY VALUE SOURCE @@ -34305,94 +33181,44 @@ mypool/compressed_dataset compression lz4 local mypool/compressed_dataset logicalused 496G - - The dataset is currently using 449 GB of space (the - used property). Without compression, it would have taken - 496 GB of space (the logicallyused - property). This results in the 1.11:1 compression - ratio. - - Compression can have an unexpected side effect when - combined with - User Quotas. - User quotas restrict how much space a user can consume on a - dataset, but the measurements are based on how much space is - used after compression. So if a user has - a quota of 10 GB, and writes 10 GB of compressible - data, they will still be able to store additional data. If - they later update a file, say a database, with more or less - compressible data, the amount of space available to them will - change. This can result in the odd situation where a user did - not increase the actual amount of data (the - logicalused property), but the change in - compression caused them to reach their quota limit. - - Compression can have a similar unexpected interaction with - backups. Quotas are often used to limit how much data can be - stored to ensure there is sufficient backup space available. - However since quotas do not consider compression, more data - may be written than would fit with uncompressed - backups. + 資料集目前使用了 449 GB 的空間 (在 used 屬性)。在尚未壓縮前,該資料集應該會使用 496 GB 的空間 (於 logicallyused 屬性),這個結果顯示目前的壓縮比為 1.11:1。 + + 壓縮功能在與使用者配額 (User Quota) 一併使用時可能會產生無法預期的副作用。使用者配額會限制一個使用者在一個資料集上可以使用多少空間,但衡量的依據是以 壓縮後 所使用的空間,因此,若一個使用者有 10 GB 的配額,寫入了 10 GB 可壓縮的資料,使用者將還會有空間儲存額外的資料。若使用者在之後更新了一個檔案,例如一個資料庫,可能有更多或較少的可壓縮資料,那麼剩餘可用的空間量也會因此而改變,這可能會造成奇怪的現象便是,一個使用者雖然沒有增加實際的資料量 (於 logicalused 屬性),但因為更改影響了壓縮率,導致使用者達到配額的上限。 + + 壓縮功能在與備份功能一起使用時也可能會有類似的問題,通常會使用配額功能來限制能夠儲存的資料量來確保有足夠的備份空間可用。但是由於配額功能並不會考量壓縮狀況,可能會有比未壓縮版本備份更多的資料量會被寫入到資料集。 去重複 (Deduplication) - When enabled, - deduplication - uses the checksum of each block to detect duplicate blocks. - When a new block is a duplicate of an existing block, - ZFS writes an additional reference to the - existing data instead of the whole duplicate block. - Tremendous space savings are possible if the data contains - many duplicated files or repeated information. Be warned: - deduplication requires an extremely large amount of memory, - and most of the space savings can be had without the extra - cost by enabling compression instead. + 當開啟,去重複 (Deduplication) 功能會使用每個資料區塊的校驗碼 (Checksum) 來偵測重複的資料區塊,當新的資料區塊與現有的資料區塊重複,ZFS 便會寫入連接到現有資料的參考來替代寫入重複的資料區塊,這在資料中有大量重複的檔案或資訊時可以節省大量的空間,要注意的是:去重複功能需要使用大量的記憶體且大部份可節省的空間可改開啟壓縮功能來達成,而壓縮功能不需要使用額外的記憶體。 - To activate deduplication, set the - dedup property on the target pool: + 要開啟去重複功能,需在目標儲存池設定 dedup 屬性: # zfs set dedup=on pool - Only new data being written to the pool will be - deduplicated. Data that has already been written to the pool - will not be deduplicated merely by activating this option. A - pool with a freshly activated deduplication property will look - like this example: + 只有要被寫入到儲存池的新資料才會做去重複的動作,先前已被寫入到儲存池的資料不會因此啟動了這個選項而做去重複。查看已開啟去重複屬性的儲存池會如下: # zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT pool 2.84G 2.19M 2.83G 0% 1.00x ONLINE - - The DEDUP column shows the actual rate - of deduplication for the pool. A value of - 1.00x shows that data has not been - deduplicated yet. In the next example, the ports tree is - copied three times into different directories on the - deduplicated pool created above. + DEDUP 欄位會顯示儲存池的實際去重複率,數值為 1.00x 代表資料尚未被去重複。在下一個例子會在前面所建立的去重複儲存池中複製三份 Port 樹到不同的目錄。中。 # zpool list for d in dir1 dir2 dir3; do for> mkdir $d && cp -R /usr/ports $d & for> done - Redundant data is detected and deduplicated: + 已經偵測到重複的資料並做去重複: # zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT pool 2.84G 20.9M 2.82G 0% 3.00x ONLINE - - The DEDUP column shows a factor of - 3.00x. Multiple copies of the ports tree - data was detected and deduplicated, using only a third of the - space. The potential for space savings can be enormous, but - comes at the cost of having enough memory to keep track of the - deduplicated blocks. - - Deduplication is not always beneficial, especially when - the data on a pool is not redundant. - ZFS can show potential space savings by - simulating deduplication on an existing pool: + DEDUP 欄位顯示有 3.00x 的去重複率,這代表已偵測到多份複製的 Port 樹資料並做了去重複的動作,且只會使用第三份資料所佔的空間。去重複能節省空間的潛力可以非常巨大,但會需要消耗大量的記憶體來持續追蹤去重複的資料區塊。 + + 去重複並非總是有效益的,特別是當儲存池中的資料本身並沒有重複時。ZFS 可以透過在現有儲存池上模擬開啟去重複功能來顯示可能節省的空間: # zdb -S pool Simulated DDT histogram: @@ -34415,87 +33241,31 @@ dedup = 1.05, compress = 1.11, copies = 1.00, dedup * compress / copies = 1.16 - After zdb -S finishes analyzing the - pool, it shows the space reduction ratio that would be - achieved by activating deduplication. In this case, - 1.16 is a very poor space saving ratio that - is mostly provided by compression. Activating deduplication - on this pool would not save any significant amount of space, - and is not worth the amount of memory required to enable - deduplication. Using the formula - ratio = dedup * compress / copies, - system administrators can plan the storage allocation, - deciding whether the workload will contain enough duplicate - blocks to justify the memory requirements. If the data is - reasonably compressible, the space savings may be very good. - Enabling compression first is recommended, and compression can - also provide greatly increased performance. Only enable - deduplication in cases where the additional savings will be - considerable and there is sufficient memory for the DDT. + zdb -S 分析完儲存池後會顯示在啟動去重複後可達到的空間減少比例。在本例中,1.16 是非常差的空間節省比例,因為這個比例使用壓縮功能便能達成。若在此儲存池上啟動去重複並不能明顯的節省空間使用量,那麼就不值得耗費大量的記憶體來開啟去重複功能。透過公式 ratio = dedup * compress / copies,系統管理者可以規劃儲存空間的配置,來判斷要處理的資料是否有足夠的重複資料區塊來平衡所需的記憶體。若資料是可壓縮的,那麼空間節少的效果可能會非常好,建議先開啟壓縮功能,且壓縮功能也可以大大提高效能。去重複功能只有在可以節省可觀的空間且有足夠的記憶體做 DDT 時才開啟。 <acronym>ZFS</acronym> 與 Jail - zfs jail and the corresponding - jailed property are used to delegate a - ZFS dataset to a - Jail. - zfs jail jailid - attaches a dataset to the specified jail, and - zfs unjail detaches it. For the dataset to - be controlled from within a jail, the - jailed property must be set. Once a - dataset is jailed, it can no longer be mounted on the - host because it may have mount points that would compromise - the security of the host. + zfs jail 以及相關的 jailed 屬性可以用來將一個 ZFS 資料集委託給一個 Jail 管理。zfs jail jailid 可以將一個資料集連結到一個指定的 Jail,而 zfs unjail 則可解除連結。資料集要可以在 Jail 中控制需設定 jailed 屬性,一旦資料集被隔離便無法再掛載到主機,因為有掛載點可能會破壞主機的安全性。 委託管理 - A comprehensive permission delegation system allows - unprivileged users to perform ZFS - administration functions. For example, if each user's home - directory is a dataset, users can be given permission to create - and destroy snapshots of their home directories. A backup user - can be given permission to use replication features. A usage - statistics script can be allowed to run with access only to the - space utilization data for all users. It is even possible to - delegate the ability to delegate permissions. Permission - delegation is possible for each subcommand and most - properties. + 一個全面性的權限委託系統可能無權限的使用者執行 ZFS 的管理功能。例如,若每個使用者的家目錄均為一個資料集,便可以給予使用者權限建立與摧毀它們家目錄中的快照。可以給予備份使用者使用備份功能的權限。一個使用量統計的 Script 可以允許其在執行時能存取所有使用者的空間利用率資料。甚至可以將委託權限委託給其他人,每個子指令與大多數屬性都可使用權限委託。 - Delegating Dataset Creation + 委託資料集建立 - zfs allow - someuser create - mydataset gives the - specified user permission to create child datasets under the - selected parent dataset. There is a caveat: creating a new - dataset involves mounting it. That requires setting the - FreeBSD vfs.usermount sysctl8 to - 1 to allow non-root users to mount a - file system. There is another restriction aimed at preventing - abuse: non-root - users must own the mountpoint where the file system is to be - mounted. + zfs allow someuser create mydataset 可以給予指定的使用者在指定的父資料集下建立子資料集的權限。這裡需要注意:建立新資料集會牽涉到掛載,因此需要設定 FreeBSD 的 vfs.usermount sysctl81 來允許非 root 的使用者掛載一個檔案系統。這裡還有另一項限制可以避免濫用:非 root 使用者必須擁有掛載點在檔案系統中所在位置的權限才可掛載。 - Delegating Permission Delegation + 委託權限委託 - zfs allow - someuser allow - mydataset gives the - specified user the ability to assign any permission they have - on the target dataset, or its children, to other users. If a - user has the snapshot permission and the - allow permission, that user can then grant - the snapshot permission to other - users. + zfs allow someuser allow mydataset 可以給予指定的使用者有權限指派它們在目標資料集或其子資料集上擁有的任何權限給其他人。若該使用者擁有 snapshot 權限及 allow 權限,則該使用者可以授權 snapshot 權限給其他使用者。 @@ -34505,9 +33275,7 @@ 調校 - There are a number of tunables that can be adjusted to - make ZFS perform best for different - workloads. + 這裡有數個可調校的項目可以調整,來讓 ZFS 在面對各種工作都能以最佳狀況運作。 @@ -34770,65 +33538,35 @@ i386 上的 <acronym>ZFS</acronym> - Some of the features provided by ZFS - are memory intensive, and may require tuning for maximum - efficiency on systems with limited - RAM. + ZFS 所提供的部份功能需要使用大量記憶體,且可能需要對有限 RAM 的系統調校來取得最佳的效率。 記憶體 - As a bare minimum, the total system memory should be at - least one gigabyte. The amount of recommended - RAM depends upon the size of the pool and - which ZFS features are used. A general - rule of thumb is 1 GB of RAM for every 1 TB of - storage. If the deduplication feature is used, a general - rule of thumb is 5 GB of RAM per TB of storage to be - deduplicated. While some users successfully use - ZFS with less RAM, - systems under heavy load may panic due to memory exhaustion. - Further tuning may be required for systems with less than - the recommended RAM requirements. + 最低需求,總系統記憶體應至少有 1 GB,建議的 RAM 量需視儲存池的大小以及使用的 ZFS 功能而定。一般的經驗法則是每 1 TB 的儲存空間需要 1 GB 的 RAM,若有開啟去重複的功能,一般的經驗法則是每 1 TB 的要做去重複的儲存空間需要 5 GB 的 RAM。雖然有部份使用者成功使用較少的 RAM 來運作 ZFS,但系統在負載較重時有可能會因為記憶用耗而導致當機,對於要使用低於建議 RAM 需求量來運作的系統可能會需要更進一步的調校。 核心設定 - Due to the address space limitations of the - i386 platform, ZFS users on the - i386 architecture must add this option to a - custom kernel configuration file, rebuild the kernel, and - reboot: + 由於在 i386 平台上位址空間的限制,在 i386 架構上的 ZFS 使用者必須加入這個選項到自訂核心設定檔,重新編譯核心並重新開啟: options KVA_PAGES=512 - This expands the kernel address space, allowing - the vm.kvm_size tunable to be pushed - beyond the currently imposed limit of 1 GB, or the - limit of 2 GB for PAE. To find the - most suitable value for this option, divide the desired - address space in megabytes by four. In this example, it - is 512 for 2 GB. + 這個選項會增加核心位址空間,允許調整 vm.kvm_size 超出目前的 1 GB 限制或在 PAE 的 2 GB 限制。要找到這個選項最合適的數值,可以將想要的位址空間換算成 MB 然後除以 4,在本例中,以 2 GB 計算後即為 512 載入程式可調參數 - The kmem address space can be - increased on all FreeBSD architectures. On a test system with - 1 GB of physical memory, success was achieved with - these options added to - /boot/loader.conf, and the system - restarted: + 在所有的 FreeBSD 架構上均可增加 kmem 位址空間,經測試在一個 1 GB 實體記憶體的測試系統上,加入以下選項到 /boot/loader.conf,重新開啟系統,可成功設定。 vm.kmem_size="330M" vm.kmem_size_max="330M" vfs.zfs.arc_max="40M" vfs.zfs.vdev.cache.size="5M" - For a more detailed list of recommendations for - ZFS-related tuning, see . + 要取得更多詳細的 ZFS 相關調校的建議清單,請參考 @@ -34879,840 +33617,270 @@ <acronym>ZFS</acronym> 特色與術語 - ZFS is a fundamentally different file - system because it is more than just a file system. - ZFS combines the roles of file system and - volume manager, enabling additional storage devices to be added - to a live system and having the new space available on all of - the existing file systems in that pool immediately. By - combining the traditionally separate roles, - ZFS is able to overcome previous limitations - that prevented RAID groups being able to - grow. Each top level device in a pool is called a - vdev, which can be a simple disk or a - RAID transformation such as a mirror or - RAID-Z array. ZFS file - systems (called datasets) each have access - to the combined free space of the entire pool. As blocks are - allocated from the pool, the space available to each file system - decreases. This approach avoids the common pitfall with - extensive partitioning where free space becomes fragmented - across the partitions. + ZFS 是一個從本質上與眾不同的檔案系統,由於它並非只是一個檔案系統,ZFS 結合了檔案系統及磁碟區管理程式,讓額外的儲存裝置可以即時的加入到系統並可讓既有的檔案系統立即使用這些在儲存池中空間。透過結合傳統區分為二的兩個角色,ZFS 能夠克服以往 RAID 磁碟群組無法擴充的限制。每個在儲存池頂層的裝置稱作 vdev,其可以是一個簡單的磁碟或是一個 RAID 如鏡像或 RAID-Z 陣列。ZFS 的檔案系統 (稱作 資料集 (Dataset)) 每一個資料集均可存取整個存池所共通的可用空間,隨著使用儲存池來配置空間區塊,儲存池能給每個檔案系統使用的可用空間就會減少,這個方法可以避免擴大分割區會使的可用空間分散分割區之間的常見問題。 - pool - - A storage pool is the most - basic building block of ZFS. A pool - is made up of one or more vdevs, the underlying devices - that store the data. A pool is then used to create one - or more file systems (datasets) or block devices - (volumes). These datasets and volumes share the pool of - remaining free space. Each pool is uniquely identified - by a name and a GUID. The features - available are determined by the ZFS - version number on the pool. + 儲存池 (Pool) - - FreeBSD 9.0 and 9.1 include support for - ZFS version 28. Later versions - use ZFS version 5000 with feature - flags. The new feature flags system allows greater - cross-compatibility with other implementations of - ZFS. - - + 儲存池 (Pool) 是建構 ZFS 最基礎的單位。一個儲存池可由一個或多個 vdev 所組成,是用來儲存資料的底層裝置。儲存池會被拿來建立一個或多個檔案系統 (資料集 Dataset) 或區塊裝置 (磁碟區 Volume),這些資料集與磁碟區會共用儲存池的剩餘可用空間。每一個儲存池可由名稱與 GUID 來辨識。可用的功能會依儲存池上的 ZFS 版本而有不同。 + FreeBSD 9.0 與 9.1 支援 ZFS 版本 28,之後的版本使用 ZFS 版本 5000 與功能旗標,新的功能旗標 (Feature flags) 系統有更佳的相容性,能夠與其他人實作的 ZFS 相容。 + - vdev Types - - A pool is made up of one or more vdevs, which - themselves can be a single disk or a group of disks, in - the case of a RAID transform. When - multiple vdevs are used, ZFS spreads - data across the vdevs to increase performance and - maximize usable space. + vdev 型態 (vdev Types) - + 儲存池是由一個或多個 vdev 所組成,vdev 可以是一個磁碟或是 RAID Transform 的磁碟群組。當使用多個 vdev,ZFS 可以分散資料到各個 vdev 來增加效能與最大的可用空間。 - Disk - - The most basic type of vdev is a standard block - device. This can be an entire disk (such as - /dev/ada0 - or - /dev/da0) - or a partition - (/dev/ada0p3). - On FreeBSD, there is no performance penalty for using - a partition rather than the entire disk. This - differs from recommendations made by the Solaris - documentation. + 磁碟 (Disk) - 最基本的 vdev 型態便是一個標準的資料區塊裝置,這可以是一整個磁碟 (例如 /dev/ada0/dev/da0) 或一個分割區 (/dev/ada0p3)。在 FreeBSD 上,使用分割區來替代整個磁碟不會影響效能,這可能與 Solaris 說明文件所建議的有所不同。 - File - - In addition to disks, ZFS - pools can be backed by regular files, this is - especially useful for testing and experimentation. - Use the full path to the file as the device path - in zpool create. All vdevs must be - at least 128 MB in size. + 檔案 (File) - 除了磁碟外,ZFS 儲存池可以使用一般檔案為基礎,這在測試與實驗時特別有用。在 zpool create 時使用檔案的完整路徑作為裝置路徑。所有 vdev 必須至少有 128 MB 的大小。 - Mirror - - When creating a mirror, specify the - mirror keyword followed by the - list of member devices for the mirror. A mirror - consists of two or more devices, all data will be - written to all member devices. A mirror vdev will - only hold as much data as its smallest member. A - mirror vdev can withstand the failure of all but - one of its members without losing any data. + 鏡像 (Mirror) - 要建立鏡像,需使用 mirror 關鍵字,後面接著要做為該鏡像成員裝置的清單。一個鏡像需要由兩個或多個裝置來組成,所有的資料都會被寫入到所有的成員裝置。鏡像 vdev 可以對抗所有成員故障只剩其中一個而不損失任何資料。 - A regular single disk vdev can be upgraded - to a mirror vdev at any time with - zpool - attach. + 正常單一磁碟的 vdev 可以使用 zpool attach 隨時升級成為鏡像 vdev。 - RAID-Z - - ZFS implements - RAID-Z, a variation on standard - RAID-5 that offers better - distribution of parity and eliminates the - RAID-5 write - hole in which the data and parity - information become inconsistent after an - unexpected restart. ZFS - supports three levels of RAID-Z - which provide varying levels of redundancy in - exchange for decreasing levels of usable storage. - The types are named RAID-Z1 - through RAID-Z3 based on the - number of parity devices in the array and the - number of disks which can fail while the pool - remains operational. - - In a RAID-Z1 configuration - with four disks, each 1 TB, usable storage is - 3 TB and the pool will still be able to - operate in degraded mode with one faulted disk. - If an additional disk goes offline before the - faulted disk is replaced and resilvered, all data - in the pool can be lost. - - In a RAID-Z3 configuration - with eight disks of 1 TB, the volume will - provide 5 TB of usable space and still be - able to operate with three faulted disks. Sun - recommends no more than nine disks in a single - vdev. If the configuration has more disks, it is - recommended to divide them into separate vdevs and - the pool data will be striped across them. - - A configuration of two - RAID-Z2 vdevs consisting of 8 - disks each would create something similar to a - RAID-60 array. A - RAID-Z group's storage capacity - is approximately the size of the smallest disk - multiplied by the number of non-parity disks. - Four 1 TB disks in RAID-Z1 - has an effective size of approximately 3 TB, - and an array of eight 1 TB disks in - RAID-Z3 will yield 5 TB of - usable space. + RAID-Z - ZFS 實作了 RAID-Z,以標準的 RAID-5 修改而來,可提供奇偶校驗 (Parity) 更佳的分散性並去除了 RAID-5 write hole 導致在預期之外的重啟後資料與奇偶校驗資訊不一致的問題。ZFS 支援三個層級的 RAID-Z,可提供不同程度的備援來換取減少不同程度的可用空間,類型的名稱以陣列中奇偶校驗裝置的數量與儲存池可以容許磁碟故障的數量來命名,從 RAID-Z1RAID-Z3 + + RAID-Z1 配置 4 個磁碟,每個磁碟 1 TB,可用的儲存空間則為 3 TB,且若其中一個磁碟故障仍可以降級 (Degraded) 的模式運作,若在故障磁碟尚未更換並修復 (Resilver) 之前又有磁碟故障,所有在儲存池中的資料便會遺失。 + + RAID-Z3 配置 8 個 1 TB 的磁碟,磁碟區將會可以提供 5 TB 的可用空間且在 3 個磁碟故障的情況下仍可運作。Sun 建議單一個 vdev 不要使用超過 9 個磁碟。若配置需要使用更多磁碟,建議分成兩個 vdev,這樣儲存池的資料便會分散到這兩個 vdev。 + + 使用兩個 RAID-Z2 各由 8 個磁碟組成的 vdev 的配置可以建立一個類似 RAID-60 的陣列。RAID-Z 群組的儲存空量會接近其中最小的磁碟乘上非奇偶校驗磁碟的數量。4 個 1 TB 磁碟在 RAID-Z1 會有接近 3 TB 的實際大小,且一個由 8 個 1 TB 磁碟組成的 RAID-Z3 陣列會有 5 TB 的可用空間。 - Spare - - ZFS has a special pseudo-vdev - type for keeping track of available hot spares. - Note that installed hot spares are not deployed - automatically; they must manually be configured to - replace the failed device using - zfs replace. + 備援 (Spare) - ZFS 有特殊的虛擬 vdev 型態可用來持續追蹤可用的熱備援裝置 (Hot spare)。注意,安裝的熱備援裝置並不會自動佈署,熱備援裝置需要手動使用 zfs replace 設定替換故障的裝置。 - Log - - ZFS Log Devices, also known - as ZFS Intent Log (ZIL) - move the intent log from the regular pool devices - to a dedicated device, typically an - SSD. Having a dedicated log - device can significantly improve the performance - of applications with a high volume of synchronous - writes, especially databases. Log devices can be - mirrored, but RAID-Z is not - supported. If multiple log devices are used, - writes will be load balanced across them. + 日誌 (Log) - ZFS 記錄裝置,也被稱作 ZFS 意圖日誌 (ZFS Intent Log, ZIL) 會從正常的儲存池裝置移動意圖日誌到獨立的裝置上,通常是一個 SSD。有了獨立的日誌裝置,可以明顯的增進有大量同步寫入應用程式的效能,特別是資料庫。日誌裝置可以做成鏡像,但不支援 RAID-Z,若使用多個日誌裝置,寫入動作會被負載平衡分散到這些裝置。 - Cache - - Adding a cache vdev to a pool will add the - storage of the cache to the L2ARC. - Cache devices cannot be mirrored. Since a cache - device only stores additional copies of existing - data, there is no risk of data loss. + 快取 (Cache) - 加入快取 vdev 到儲存池可以增加儲存空間的 L2ARC 快取。快取裝置無法做鏡像,因快取裝置只會儲存額外的現有資料的複本,並沒有資料遺失的風險。 - Transaction Group - (TXG) - - Transaction Groups are the way changed blocks are - grouped together and eventually written to the pool. - Transaction groups are the atomic unit that - ZFS uses to assert consistency. Each - transaction group is assigned a unique 64-bit - consecutive identifier. There can be up to three active - transaction groups at a time, one in each of these three - states: + 交易群組 (Transaction Group, TXG) - + 交易群組是一種將更動的資料區塊包裝成一組的方式,最後再一次寫入到儲存池。交易群組是 ZFS 用來檢驗一致性的基本單位。每個交易群組會被分配一個獨一無二的 64-bit 連續代號。最多一次可以有三個活動中的交易群組,這三個交易群組的每一個都有這三種狀態: - Open - When a new - transaction group is created, it is in the open - state, and accepts new writes. There is always - a transaction group in the open state, however the - transaction group may refuse new writes if it has - reached a limit. Once the open transaction group - has reached a limit, or the vfs.zfs.txg.timeout - has been reached, the transaction group advances - to the next state. + 開放 (Open) - 新的交易群組建立之後便處於開放的狀態,可以接受新的寫入動作。永遠會有開放狀態的交易群組,即始交易群組可能會因到達上限而拒絕新的寫入動作。一但開放的交易群組到達上限或到達 vfs.zfs.txg.timeout,交易群組便會繼續進入下一個狀態。 - Quiescing - A short state - that allows any pending operations to finish while - not blocking the creation of a new open - transaction group. Once all of the transactions - in the group have completed, the transaction group - advances to the final state. + 靜置中 (Quiescing) - 一個短暫的狀態,會等候任何未完成的操作完成,不會阻擋新開放的交易群組建立。一旦所有在群組中的交易完成,交易群組便會進入到最終狀態。 - Syncing - All of the data - in the transaction group is written to stable - storage. This process will in turn modify other - data, such as metadata and space maps, that will - also need to be written to stable storage. The - process of syncing involves multiple passes. The - first, all of the changed data blocks, is the - biggest, followed by the metadata, which may take - multiple passes to complete. Since allocating - space for the data blocks generates new metadata, - the syncing state cannot finish until a pass - completes that does not allocate any additional - space. The syncing state is also where - synctasks are completed. - Synctasks are administrative operations, such as - creating or destroying snapshots and datasets, - that modify the uberblock are completed. Once the - sync state is complete, the transaction group in - the quiescing state is advanced to the syncing - state. + 同步中 (Syncing) - 所有在交易群組中的資料會被寫任到穩定的儲存空間,這個程序會依序修改其他也需同樣寫入到穩定儲存空間的資料,如 Metadata 與空間對應表。同步的程多會牽涉多個循環,首先是同步所有更改的資料區塊,也是最大的部份,接著是 Metadata,這可能會需要多個循環來完成。由於要配置空間供資料區塊使用會產生新的 Metadata,同步中狀態在到達循環完成而不再需要分配任何額外空間的狀態前無法結束。同步中狀態也是完成 synctask 的地方,Synctask 是指管理操作,如:建立或摧毀快照與資料集,會修改 uberblock,也會在此時完成。同步狀態完成後,其他處於狀態中狀態的交易群組便會進入同步中狀態。 - - - All administrative functions, such as snapshot - are written as part of the transaction group. When a - synctask is created, it is added to the currently open - transaction group, and that group is advanced as quickly - as possible to the syncing state to reduce the - latency of administrative commands. + 所有管理功能如快照 (Snapshot) 會作為交易群組的一部份寫入。當 synctask 建立之後,便會加入到目前開放的交易群組中,然後該群組會盡快的進入同步中狀態來減少管理指令的延遲。 Adaptive Replacement Cache (ARC) - ZFS uses an Adaptive Replacement - Cache (ARC), rather than a more - traditional Least Recently Used (LRU) - cache. An LRU cache is a simple list - of items in the cache, sorted by when each object was - most recently used. New items are added to the top of - the list. When the cache is full, items from the - bottom of the list are evicted to make room for more - active objects. An ARC consists of - four lists; the Most Recently Used - (MRU) and Most Frequently Used - (MFU) objects, plus a ghost list for - each. These ghost lists track recently evicted objects - to prevent them from being added back to the cache. - This increases the cache hit ratio by avoiding objects - that have a history of only being used occasionally. - Another advantage of using both an - MRU and MFU is - that scanning an entire file system would normally evict - all data from an MRU or - LRU cache in favor of this freshly - accessed content. With ZFS, there is - also an MFU that only tracks the most - frequently used objects, and the cache of the most - commonly accessed blocks remains. + ZFS 使用了自適應替換快取 (Adaptive Replacement Cache, ARC),而不是傳統的最近最少使用 (Least Recently Used, LRU) 快取,LRU 快取在快取中是一個簡單的項目清單,會依每個物件最近使用的時間來排序,新項會加入到清單的最上方,當快取額滿了便會去除清單最下方的項目來空出空間給較常使用的物件。ARC 結合了四種快取清單,最近最常使用 (Most Recently Used, MRU) 及最常使用 (Most Frequently Used, MFU) 物件加上兩個清單各自的幽靈清單 (Ghost list),這些幽靈清單會追蹤最近被去除的物件來避免又被加回到快取,避免過去只有偶爾被使用的物件加入清單可以增加快取的命中率。同時使用 MRUMFU 的另外一個優點是掃描一個完整檔案系統可以去除在 MRULRU 快取中的所有資料,有利於這些才剛存取的內容。使用 ZFS 也有 MFU 可只追蹤最常使用的物件並保留最常被存取的資料區塊快取。 L2ARC - L2ARC is the second level - of the ZFS caching system. The - primary ARC is stored in - RAM. Since the amount of - available RAM is often limited, - ZFS can also use - cache vdevs. - Solid State Disks (SSDs) are often - used as these cache devices due to their higher speed - and lower latency compared to traditional spinning - disks. L2ARC is entirely optional, - but having one will significantly increase read speeds - for files that are cached on the SSD - instead of having to be read from the regular disks. - L2ARC can also speed up deduplication - because a DDT that does not fit in - RAM but does fit in the - L2ARC will be much faster than a - DDT that must be read from disk. The - rate at which data is added to the cache devices is - limited to prevent prematurely wearing out - SSDs with too many writes. Until the - cache is full (the first block has been evicted to make - room), writing to the L2ARC is - limited to the sum of the write limit and the boost - limit, and afterwards limited to the write limit. A - pair of sysctl8 values control these rate limits. - vfs.zfs.l2arc_write_max - controls how many bytes are written to the cache per - second, while vfs.zfs.l2arc_write_boost - adds to this limit during the - Turbo Warmup Phase (Write Boost). + L2ARCZFS 快取系統的第二層,主要的 ARC 會儲存在 RAM 當中,但因為 RAM 可用的空間量通常有限,因此 ZFS 也可以使用 快取 vdev (Cache vdev)。固態磁碟 (Solid State Disk, SSD) 常被拿來此處作為快取裝置,因為比起傳統旋轉碟片的磁碟,固體磁碟有較快的速度與較低的延遲。L2ARC 是選用的,但使用可以明顯增進那些已使用 SSD 快取的檔案讀取速度,無須從一般磁碟讀取。L2ARC 也同樣可以加速去重複 (Deduplication),因為 DDT 並不適合放在 RAM,但適合放在 L2ARC,比起要從磁碟讀取,可以加快不少速度。為了避免 SSD 因寫入次速過多而過早耗損,加入到快取裝置的資料速率會被限制,直到快取用盡 (去除第一個資料區塊來騰出空間) 之前,寫入到 L2ARC 的資料速率會限制在寫入限制 (Write limit) 與加速限制 (Boost limit) 的總合,之後則會限制為寫入限制,可以控制這兩個速度限制的 sysctl8 數值分別為 vfs.zfs.l2arc_write_max 控制每秒有多少數位元組可寫入到快取,而 vfs.zfs.l2arc_write_boost 可在 渦輪預熱階段 (即寫入加速) 時增加寫入限制。 ZIL - ZIL accelerates synchronous - transactions by using storage devices like - SSDs that are faster than those used - in the main storage pool. When an application requests - a synchronous write (a guarantee that the data has been - safely stored to disk rather than merely cached to be - written later), the data is written to the faster - ZIL storage, then later flushed out - to the regular disks. This greatly reduces latency and - improves performance. Only synchronous workloads like - databases will benefit from a ZIL. - Regular asynchronous writes such as copying files will - not use the ZIL at all. + ZIL 會使用儲存裝置,例如,比那些用在主要儲存池還快的 SSD 來加速同步交易 (Synchronous transaction)。當應用程式請求做一個同步的寫入時 (保証資料會安全的儲存到磁碟,而不是先快取稍後再寫入),資料會先寫入到速度較快的 ZIL 儲存空間,之後再一併寫入到一般的磁碟。這可大量的減少延遲並增進效能。ZIL 只會有利於使用像資料庫這類的同步工作,一般非同步的寫入像複製檔案,則完全不會用到 ZIL - Copy-On-Write + 寫入時複製 (Copy-On-Write) - Unlike a traditional file system, when data is - overwritten on ZFS, the new data is - written to a different block rather than overwriting the - old data in place. Only when this write is complete is - the metadata then updated to point to the new location. - In the event of a shorn write (a system crash or power - loss in the middle of writing a file), the entire - original contents of the file are still available and - the incomplete write is discarded. This also means that - ZFS does not require a fsck8 - after an unexpected shutdown. + 不像傳統的檔案系統,在 ZFS,當資料要被覆寫時,不會直接覆寫舊資料所在的位置,而是將新資料會寫入到另一個資料區塊,只在資料寫入完成後才會更新 Metadata 指向新的位置。因此,在發生寫入中斷 (在寫入檔案的過程中系統當機或電源中斷) 時,原來檔案的完整內容並不會遺失,只會放棄未寫入完成的新資料,這也意謂著 ZFS 在發生預期之外的關機後不需要做 fsck8 - Dataset + 資料集 (Dataset) - Dataset is the generic term - for a ZFS file system, volume, - snapshot or clone. Each dataset has a unique name in - the format - poolname/path@snapshot. - The root of the pool is technically a dataset as well. - Child datasets are named hierarchically like - directories. For example, - mypool/home, the home - dataset, is a child of mypool - and inherits properties from it. This can be expanded - further by creating - mypool/home/user. This - grandchild dataset will inherit properties from the - parent and grandparent. Properties on a child can be - set to override the defaults inherited from the parents - and grandparents. Administration of datasets and their - children can be - delegated. + 資料集 (Dataset)ZFS 檔案系統、磁碟區、快照或複本的通用術語。每個資料集都有獨一無二的名稱使用 poolname/path@snapshot 格式。儲存池的根部技術上來說也算一個資料集,子資料集會採用像目錄一樣的層級來命名,例如 mypool/home,home 資料集是 mypool 的子資料集並且會繼承其屬性。這可以在往後繼續擴展成 mypool/home/user,這個孫資料集會繼承其父及祖父的屬性。在子資料集的屬性可以覆蓋預設繼承自父及祖父的屬性。資料集及其子資料級的管理權限可以委託 (Delegate) 給他人。 - File system + 檔案系統 (File system) - A ZFS dataset is most often used - as a file system. Like most other file systems, a - ZFS file system is mounted somewhere - in the systems directory hierarchy and contains files - and directories of its own with permissions, flags, and - other metadata. + ZFS 資料集最常被當做檔案系統使用。如同大多數其他的檔案系統,ZFS 檔案系統會被掛載在系統目錄層級的某一處且內含各自擁有權限、旗標及 Metadata 的檔案與目錄。 - Volume + 磁碟區 (Volume) - In additional to regular file system datasets, - ZFS can also create volumes, which - are block devices. Volumes have many of the same - features, including copy-on-write, snapshots, clones, - and checksumming. Volumes can be useful for running - other file system formats on top of - ZFS, such as UFS - virtualization, or exporting iSCSI - extents. + 除了一般的檔案系統資料集之外,ZFS 也可以建立磁碟區 (Volume),磁碟區是資料區塊裝置。磁碟區有許多與資料集相似的功能,包含複製時寫入、快照、複本以及資料校驗。要在 ZFS 的頂層執行其他檔案系統格式時使用磁碟區非常有用,例如 UFS 虛擬化或匯出 iSCSI 延伸磁區 (Extent)。 - Snapshot + 快照 (Snapshot) - The - copy-on-write - (COW) design of - ZFS allows for nearly instantaneous, - consistent snapshots with arbitrary names. After taking - a snapshot of a dataset, or a recursive snapshot of a - parent dataset that will include all child datasets, new - data is written to new blocks, but the old blocks are - not reclaimed as free space. The snapshot contains - the original version of the file system, and the live - file system contains any changes made since the snapshot - was taken. No additional space is used. As new data is - written to the live file system, new blocks are - allocated to store this data. The apparent size of the - snapshot will grow as the blocks are no longer used in - the live file system, but only in the snapshot. These - snapshots can be mounted read only to allow for the - recovery of previous versions of files. It is also - possible to - rollback a live - file system to a specific snapshot, undoing any changes - that took place after the snapshot was taken. Each - block in the pool has a reference counter which keeps - track of how many snapshots, clones, datasets, or - volumes make use of that block. As files and snapshots - are deleted, the reference count is decremented. When a - block is no longer referenced, it is reclaimed as free - space. Snapshots can also be marked with a - hold. When a - snapshot is held, any attempt to destroy it will return - an EBUSY error. Each snapshot can - have multiple holds, each with a unique name. The - release command - removes the hold so the snapshot can deleted. Snapshots - can be taken on volumes, but they can only be cloned or - rolled back, not mounted independently. + ZFS 的寫入時複製 (Copy-On-Write, COW) 設計可以使用任意的名稱做到幾乎即時、一致的快照。在製做資料集的快照或父資料集遞迴快照 (會包含其所有子資料集) 之後,新的資料會寫入到資的資料區塊,但不會回收舊的資料區塊為可用空間,快照中會使用原版本的檔案系統,而快照之後所做的變更則會儲存在目前的檔案系統,因此不會重複使用額外的空間。當新的資料寫入到目前的檔案系統,便會配置新的資料區塊來儲存這些資料。快照表面大小 (Apparent size) 會隨著在目前檔案系統停止使用的資料區塊而成長,但僅限於快照。可以用唯讀的方式掛載這些快照來復原先前版本的檔案,也可以還原 (Rollback) 目前的檔案系統到指定的快照,來還原任何在快照之後所做的變更。每個在儲存池中的資料區塊都會有一個參考記數器,可以用來持續追蹤有多少快照、複本、資料集或是磁碟區使用這個資料區塊,當刪除檔案與快照參照的計數變會滅少,直到沒有任何東西參考這個資料區塊才會被回收為可用空間。快照也可使用 hold 來標記,檔標記為 hold 時,任何嘗試要刪除該快照的動作便會回傳 EBUSY 的錯誤,每個快照可以標記多個不同唯一名稱的 hold,而 release 指令則可以移除 hold,這樣才可刪除快照。在磁碟區上快可以製作快照,但只能用來複製或還原,無法獨立掛載。 - Clone + 複本 (Clone) - Snapshots can also be cloned. A clone is a - writable version of a snapshot, allowing the file system - to be forked as a new dataset. As with a snapshot, a - clone initially consumes no additional space. As - new data is written to a clone and new blocks are - allocated, the apparent size of the clone grows. When - blocks are overwritten in the cloned file system or - volume, the reference count on the previous block is - decremented. The snapshot upon which a clone is based - cannot be deleted because the clone depends on it. The - snapshot is the parent, and the clone is the child. - Clones can be promoted, reversing - this dependency and making the clone the parent and the - previous parent the child. This operation requires no - additional space. Because the amount of space used by - the parent and child is reversed, existing quotas and - reservations might be affected. + 快照也可以做複本,複本是可寫入版本的快照,讓檔案系統可分支成為新的資料集。如同快照,複本一開始不會消耗任何額外空間,隨著新資料寫入到複本會配置新的資料區塊,複本的表面大小 (Apparent size) 才會成長,當在複本檔案系統或磁碟區的資料區塊被覆寫時,在先前資料區塊的參考計數則會減少。建立複本所使用的快照無法被刪除,因為複本會相依該快照,快照為父,複本為子。複本可以被提升 (promoted)、反轉相依關係,來讓複本成為父,之前的父變為子,這個操作不需要額外的空間。由於反轉了父與子使用的空間量,所以可能會影響既有的配額 (Quota) 與保留空間 (Reservation)。 - Checksum + 校驗碼 (Checksum) - Every block that is allocated is also checksummed. - The checksum algorithm used is a per-dataset property, - see set. - The checksum of each block is transparently validated as - it is read, allowing ZFS to detect - silent corruption. If the data that is read does not - match the expected checksum, ZFS will - attempt to recover the data from any available - redundancy, like mirrors or RAID-Z). - Validation of all checksums can be triggered with scrub. - Checksum algorithms include: - - + 配置每個資料區塊快的同時也會做資料校驗,資料校驗用的演算法是依資料集屬性而有所不同的,請參考 set。每個資料區塊會在讀取的過成便完成校驗,讓 ZFS 可以偵測到隱藏的損壞,若資料不符合預期的校驗碼,ZFS 會嘗試從任何可用的備援來還原資料,例如鏡像 (Mirror) 或 RAID-Z。要檢驗所有資料的校驗碼可以使用清潔 (Scrub),資料校驗的演算法有: - fletcher2 + fletcher2 - fletcher4 + fletcher4 - sha256 + sha256 - - - The fletcher algorithms are faster, - but sha256 is a strong cryptographic - hash and has a much lower chance of collisions at the - cost of some performance. Checksums can be disabled, - but it is not recommended. + fletcher 演算法最快,而 sha256 雖較消耗效能,但其有強大的密碼雜湊與較低的衝突率。也可關閉資料校驗,但並不建議。 壓縮 (Compression) - Each dataset has a compression property, which - defaults to off. This property can be set to one of a - number of compression algorithms. This will cause all - new data that is written to the dataset to be - compressed. Beyond a reduction in space used, read and - write throughput often increases because fewer blocks - are read or written. - - + 每個資料集都有壓縮 (Compression) 屬性,預設是關閉的,這個屬性可以設定使用以下幾個壓縮演算法的其中一個來壓縮寫入到資料集的新資料。壓縮除了減少空間使用量外,常也會增加讀取與寫入的吞吐量,因為會減少讀取與寫入的資料區塊。 - LZ4 - - Added in ZFS pool version - 5000 (feature flags), LZ4 is - now the recommended compression algorithm. - LZ4 compresses approximately - 50% faster than LZJB when - operating on compressible data, and is over three - times faster when operating on uncompressible - data. LZ4 also decompresses - approximately 80% faster than - LZJB. On modern - CPUs, LZ4 - can often compress at over 500 MB/s, and - decompress at over 1.5 GB/s (per single CPU - core). + LZ4 - ZFS 儲存池版本 5000 (功能旗標) 後所增加,LZ4 現在是建議的壓縮演算法,在處理可壓縮的資料時 LZ4 壓縮比 LZJB 快將近 50%,在處理不可壓縮的資料時快將近三倍,LZ4 解壓縮也比 LZJB 將近 80%。在現代的 CPU 上,LZ4 經常平均可用 500 MB/s 的速度壓縮,而解壓縮可到達 1.5 GB/s (每個 CPU 核心)。 - LZ4 compression is - only available after FreeBSD 9.2. + LZ4 壓縮只在 FreeBSD 9.2 之後可使用。 - LZJB - - The default compression algorithm. Created by - Jeff Bonwick (one of the original creators of - ZFS). LZJB - offers good compression with less - CPU overhead compared to - GZIP. In the future, the - default compression algorithm will likely change - to LZ4. + LZJB - 預設的壓縮演算法。由 Jeff Bonwick 所開發 (ZFS 的創始人之一)。LZJBGZIP 相比,可以較低的 CPU 提供較佳的壓縮功能。在未來預設的壓縮演算法將會更換為 LZ4 - GZIP - - A popular stream compression algorithm available - in ZFS. One of the main - advantages of using GZIP is its - configurable level of compression. When setting - the compress property, the - administrator can choose the level of compression, - ranging from gzip1, the lowest - level of compression, to gzip9, - the highest level of compression. This gives the - administrator control over how much - CPU time to trade for saved - disk space. + GZIP - 在 ZFS 可用的熱門串流壓縮演算法。使用 GZIP 主要的優點之一便是可設定壓縮層級。當設定 compress 屬性,管理者可以選擇壓縮層級範圍從最低的壓縮層級 gzip1 到最高的壓縮層級 gzip9。這讓管理者可以控制要使用多少 CPU 來節省磁碟空間。 - ZLE - - Zero Length Encoding is a special compression - algorithm that only compresses continuous runs of - zeros. This compression algorithm is only useful - when the dataset contains large blocks of - zeros. + ZLE - 零長度編號是一個特殊的壓縮演算法,它只會壓縮連續的零。這種壓縮演算法只在資料集中含有大量為零的資料區塊時有用。 - Copies + 備份數 (Copies) - When set to a value greater than 1, the - copies property instructs - ZFS to maintain multiple copies of - each block in the - File System - or - Volume. Setting - this property on important datasets provides additional - redundancy from which to recover a block that does not - match its checksum. In pools without redundancy, the - copies feature is the only form of redundancy. The - copies feature can recover from a single bad sector or - other forms of minor corruption, but it does not protect - the pool from the loss of an entire disk. + 當設定大於 1 的數值時,copies 屬性會指示 ZFS 備份每個在檔案系統 (File System) 或磁碟區 (Volume) 的資料區塊數份。在重要的資料集上設定這個屬性可以做額外的備援以在資料校驗碼不相符時可做復原。在沒有做備援的儲存池上,備份功能提供只是一種資料的備援方式,備份功能可以復原單一壞軌或其他情況的次要損壞,但無法復原儲存池中整個磁碟損壞所損失的資料。 去重複 (Deduplication) - Checksums make it possible to detect duplicate - blocks of data as they are written. With deduplication, - the reference count of an existing, identical block is - increased, saving storage space. To detect duplicate - blocks, a deduplication table (DDT) - is kept in memory. The table contains a list of unique - checksums, the location of those blocks, and a reference - count. When new data is written, the checksum is - calculated and compared to the list. If a match is - found, the existing block is used. The - SHA256 checksum algorithm is used - with deduplication to provide a secure cryptographic - hash. Deduplication is tunable. If - dedup is on, then - a matching checksum is assumed to mean that the data is - identical. If dedup is set to - verify, then the data in the two - blocks will be checked byte-for-byte to ensure it is - actually identical. If the data is not identical, the - hash collision will be noted and the two blocks will be - stored separately. Because DDT must - store the hash of each unique block, it consumes a very - large amount of memory. A general rule of thumb is - 5-6 GB of ram per 1 TB of deduplicated data). - In situations where it is not practical to have enough - RAM to keep the entire - DDT in memory, performance will - suffer greatly as the DDT must be - read from disk before each new block is written. - Deduplication can use L2ARC to store - the DDT, providing a middle ground - between fast system memory and slower disks. Consider - using compression instead, which often provides nearly - as much space savings without the additional memory - requirement. + 校驗碼讓在寫入時可以偵測重複資料區塊,使用去重複,可以增加既有、完全相同的資料區塊參考數來節省儲存空間。要偵測重複的資料區塊需要在記憶體中儲存去重複資料表 (Deduplication table, DDT),這個資料表中會有唯一的校驗碼清單、這些資料區塊的所在位置以及參考數。當寫入新資料時,便會計算校驗碼然後比對清單中是否有符合的既有資料區塊已在清單。去重複使用了 SHA256 校驗碼演算法來提供一個安全的加密雜湊,去重複功能是可以調校的,若 dedup 設為 on 只要符合校驗碼便會認為資料完全相同,若 dedup 設為 verify 則會一個一個位元檢查兩個資料區塊的資料來確保資料真的完全相同,若資料不同便會註記與雜湊衝突並會分別儲存兩個資料區塊。由於 DDT 須要儲存每個唯一資料區塊的雜湊,所以會消耗大量的記憶體,一般的經驗法則是每 1 TB 的去重複資料需要使用 5-6 GB 的記憶體。由於要有足夠的 RAM 來儲存整個 DDT 在實務上並不實際,導致在每個新資料區塊寫入前需要從磁碟來讀取 DDT 會對效能有很大的影響,去重複功能可以使用 L2ARC 儲存 DDT 以在快速的系統記憶體及較慢的磁碟之間取得一個平衡點。也可以考慮使用壓縮功能來取代此功能,因為壓縮也能節省相近的空間使用量而不需要大量額外的記憶體。 - Scrub + 清潔 (Scrub) - Instead of a consistency check like fsck8, - ZFS has scrub. - scrub reads all data blocks stored on - the pool and verifies their checksums against the known - good checksums stored in the metadata. A periodic check - of all the data stored on the pool ensures the recovery - of any corrupted blocks before they are needed. A scrub - is not required after an unclean shutdown, but is - recommended at least once every three months. The - checksum of each block is verified as blocks are read - during normal use, but a scrub makes certain that even - infrequently used blocks are checked for silent - corruption. Data security is improved, especially in - archival storage situations. The relative priority of - scrub can be adjusted with vfs.zfs.scrub_delay - to prevent the scrub from degrading the performance of - other workloads on the pool. + ZFSscrub 來替代 fsck8 來做一致性的檢查。scrub 會讀取所有儲存在儲存池中的資料區塊並且根據儲存在 Metadata 中已知良好的校驗碼來檢驗這些資料區塊的校驗碼,定期檢查儲存池中儲存的所有資料可以確保實際使用這些資料前已將所有損壞的資料區塊復原。在不正常的關閉之後並不需要做清潔動作,但建議每三個月至少執行一次。在正常使用讀取時便會檢查每個資料區塊的校驗碼,但清潔動作可以確保那些不常用的資料也會被檢查以避免隱藏的損壞,如此便能增進資料的安全性,特別是對用來保存資料的儲存裝置。scrub 可以使用 vfs.zfs.scrub_delay 調整相對優先權來避免清潔動作降低儲存池上其他工作的效率。 - Dataset Quota - - ZFS provides very fast and - accurate dataset, user, and group space accounting in - addition to quotas and space reservations. This gives - the administrator fine grained control over how space is - allocated and allows space to be reserved for critical - file systems. + 資料集配額 (Dataset Quota) - ZFS supports different types of + 除了配額及空間保留外,ZFS 提供非常快速且準確的資料集、使用者及群組空間的計算功能,這可讓管理者調整空間配置的方式且可為重要的檔案系統保留空間。 ZFS supports different types of quotas: the dataset quota, the reference quota (refquota), the user quota, and the group - quota. - - Quotas limit the amount of space that a dataset - and all of its descendants, including snapshots of the - dataset, child datasets, and the snapshots of those - datasets, can consume. - - - Quotas cannot be set on volumes, as the - volsize property acts as an - implicit quota. + quota. 配額會限制資料集及後裔包含資料集的快照、子資料集及子資料集的快照能使用的空間量。 + 磁碟區上無法設定配額,因為 volsize 屬性已經被用來做內定的配額。 - Reference - Quota + 參考配額 (Reference Quota) - A reference quota limits the amount of space a - dataset can consume by enforcing a hard limit. However, - this hard limit includes only space that the dataset - references and does not include space used by - descendants, such as file systems or snapshots. + 參考配額可以設定一個硬性限制 (Hard limit) 來限制資料集能使用的空間量,而這個硬性限制只包含了資料集參考的空間,並不含其後裔所使用的空間,如:檔案系統或快照。 - User - Quota + 使用者配額 (User Quota) - User quotas are useful to limit the amount of space - that can be used by the specified user. + 使用者配額在用來限制特定使用者能使用的空間量時非常有用。 - Group - Quota + 群組配額 (Group Quota) - The group quota limits the amount of space that a - specified group can consume. + 群組配額可以限制特定群組能使用的空間量。 - Dataset - Reservation + 資料集保留空間 (Dataset Reservation) - The reservation property makes - it possible to guarantee a minimum amount of space for a - specific dataset and its descendants. If a 10 GB - reservation is set on - storage/home/bob, and another - dataset tries to use all of the free space, at least - 10 GB of space is reserved for this dataset. If a - snapshot is taken of - storage/home/bob, the space used by - that snapshot is counted against the reservation. The - refreservation - property works in a similar way, but it - excludes descendants like - snapshots. - - Reservations of any sort are useful in many - situations, such as planning and testing the - suitability of disk space allocation in a new system, - or ensuring that enough space is available on file - systems for audio logs or system recovery procedures - and files. - + reservation 屬性可以確保對特定資料集及其後裔最小可用的空間量,若在 storage/home/bob 設定 10 GB 的保留空間且其他資料集嘗試使用所有剩餘的空間時,會保留至少 10 GB 的空間供這個資料集使用。若要製作 storage/home/bob 的快照,該快照所使用的空間也會被列入保留空間計算。 refreservation 屬性也以類似的方式運作,但是他 不包含 後裔,例如:快照。 不管那一種保留空間在許多情境皆很有用,例如:要規劃與測試磁碟空間配置在新系統上的適應性,或是確保有足夠的空間供稽查日誌或系統還原程序及檔案使用。 - Reference - Reservation + 參考保留空間 (Reference Reservation) - The refreservation property - makes it possible to guarantee a minimum amount of - space for the use of a specific dataset - excluding its descendants. This - means that if a 10 GB reservation is set on - storage/home/bob, and another - dataset tries to use all of the free space, at least - 10 GB of space is reserved for this dataset. In - contrast to a regular - reservation, - space used by snapshots and descendant datasets is not - counted against the reservation. For example, if a - snapshot is taken of - storage/home/bob, enough disk space - must exist outside of the - refreservation amount for the - operation to succeed. Descendants of the main data set - are not counted in the refreservation - amount and so do not encroach on the space set. + refreservation 屬性可以確保對特定資料集 不包含 其後裔最小可用的空間,這代表若在 storage/home/bob 設定 10 GB 的保留空間且其他資料集嘗試使用所有剩餘的空間時,會保留至少 10 GB 的空間供這個資料集使用。於正常 reservation 不同的是,由快照及後裔資料集所使用的空間並不會列入保留空間計算。例如,若要製作一個 storage/home/bob 的快照,在 refreservation 空間之外必須要有足夠的空間才能成功完成這項操作,主資料集的後裔並不會列入 refreservation 空間額計算,所以也不會佔用保留空間。 - Resilver + 修復 (Resilver) - When a disk fails and is replaced, the new disk - must be filled with the data that was lost. The process - of using the parity information distributed across the - remaining drives to calculate and write the missing data - to the new drive is called - resilvering. + 當有磁碟故障且被更換後,新的磁碟必須回存先前所遺失的資料,會使用分散在其他磁碟上的奇偶校驗資訊來計算並寫入遺失的資料到新的磁碟機的這個程序稱作 修復 (Resilvering) - Online + 上線 (Online) - A pool or vdev in the Online - state has all of its member devices connected and fully - operational. Individual devices in the - Online state are functioning - normally. + 一個儲存池或 vdev 處於線上 (Online) 狀態時代表所有該裝置的成員均已連結且正常運作。個別裝置處於線上 (Online) 狀態時代表功能正常。 - Offline + 離線 (Offline) - Individual devices can be put in an - Offline state by the administrator if - there is sufficient redundancy to avoid putting the pool - or vdev into a - Faulted state. - An administrator may choose to offline a disk in - preparation for replacing it, or to make it easier to - identify. + 若有足夠的備援可避免儲存池或 vdev 進入故障 (Faulted) 狀態,個別裝置若可由管理者設為離線 (Offline) 狀態,管理者可以選擇要設定那一個磁碟為離線來準備更換或是讓其更容易辨識。 - Degraded + 降級 (Degraded) - A pool or vdev in the Degraded - state has one or more disks that have been disconnected - or have failed. The pool is still usable, but if - additional devices fail, the pool could become - unrecoverable. Reconnecting the missing devices or - replacing the failed disks will return the pool to an - Online state - after the reconnected or new device has completed the - Resilver - process. + 一個儲存池或 vdev 處於降級 (Degraded) 狀態代表其有一個或多個磁碟已斷線或故障,此時儲存池仍可以使用,但只要再有其他的裝置故障,儲存池會無法復原。重新連線缺少的裝置或更換故障的磁碟,並在新裝置完成修復 (Resilver) 程序可讓儲存池返回線上 (Online) 狀態。 - Faulted + 故障 (Faulted) - A pool or vdev in the Faulted - state is no longer operational. The data on it can no - longer be accessed. A pool or vdev enters the - Faulted state when the number of - missing or failed devices exceeds the level of - redundancy in the vdev. If missing devices can be - reconnected, the pool will return to a - Online state. If - there is insufficient redundancy to compensate for the - number of failed disks, then the contents of the pool - are lost and must be restored from backups. + 一個儲存池或 vdev 處於故障 (Faulted) 狀態代表無法運作,會無法存取在該裝置上的資料。當在 vdev 中缺少或故障的裝置數超過備援的層級,儲存池或 vdev 會進入故障 (Faulted) 狀態。若缺少的裝置可以重新連結上,儲存池便會返回線上 (Online) 狀態。若沒有足夠的備援可補償故障的磁碟數量便會遺失儲存池中的內容且只能從備份還原。 @@ -35976,7 +34144,7 @@ - 了解UNIX 與 FreeBSD 的基礎。 + 了解 UNIX 與 FreeBSD 的基礎。 @@ -36405,8 +34573,8 @@ - - 安裝 <trademark>VirtualBox</trademark> Guest Additions 於 FreeBSD 客端 + + 在 <trademark>VirtualBox</trademark> 使用 FreeBSD 作為客端 FreeBSD works well as a guest in VirtualBox. The virtualization @@ -36760,8 +34928,8 @@ Download an installation image of FreeBSD to install: - # fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/10.2/FreeBSD-10.2-RELEASE-amd64-bootonly.iso -FreeBSD-10.2-RELEASE-amd64-bootonly.iso 100% of 230 MB 570 kBps 06m17s + # fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/10.3/FreeBSD-10.3-RELEASE-amd64-bootonly.iso +FreeBSD-10.3-RELEASE-amd64-bootonly.iso 100% of 230 MB 570 kBps 06m17s FreeBSD comes with an example script for running a virtual machine in bhyve. The script will @@ -36780,7 +34948,7 @@ machine, used to track the running machines. This example starts the virtual machine in installation mode: - # sh /usr/share/examples/bhyve/vmrun.sh -c 4 -m 1024M -t tap0 -d guest.img -i -I FreeBSD-10.0-RELEASE-amd64-bootonly.iso guestname + # sh /usr/share/examples/bhyve/vmrun.sh -c 4 -m 1024M -t tap0 -d guest.img -i -I FreeBSD-10.3-RELEASE-amd64-bootonly.iso guestname The virtual machine will boot and start the installer. After installing a system in the virtual machine, when the @@ -46499,8 +44667,8 @@ # service autounmountd start The autofs5 map format is the same as in other - operating systems, it might be desirable to consult - information from other operating systems, such as the Mac + operating systems. Information about this format from other + sources can be useful, like the Mac OS X document. Consult the automount8, automountd8, @@ -48839,7 +47007,7 @@ disable-empty-zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA"; disable-empty-zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA"; -// If you've got a DNS server around at your upstream provider, enter +// If you have a DNS server around at your upstream provider, enter // its IP address here, and enable the line below. This will make you // benefit from its cache, thus reduce overall DNS traffic in the Internet. /* @@ -48895,7 +47063,7 @@ // query-source address * port NNNNN; }; -// If you enable a local name server, don't forget to enter 127.0.0.1 +// If you enable a local name server, do not forget to enter 127.0.0.1 // first in your /etc/resolv.conf so this server will be queried. // Also, make sure to enable it in /etc/rc.conf. @@ -49091,7 +47259,7 @@ // understand how DNS and BIND work. There are sometimes // non-obvious pitfalls. Setting up a slave zone is usually simpler. // -// NB: Don't blindly enable the examples below. :-) Use actual names +// NB: Do not blindly enable the examples below. :-) Use actual names // and addresses instead. /* An example dynamic zone @@ -50196,7 +48364,7 @@ LoadModule php5_module libexec/apache24/libphp5.so