跳轉到內容

LPI Linux 認證/設計硬碟佈局

來自 Wikibooks,開放的書籍,為開放的世界

詳細目標

[編輯 | 編輯原始碼]

(LPIC-1 版本 5.0)

權重:2

描述
考生應該能夠為 Linux 系統設計磁碟分割槽方案。

關鍵知識領域

  • 將檔案系統和交換空間分配到單獨的分割槽或磁碟。
  • 根據系統的預期用途定製設計。
  • 確保 /boot 分割槽符合啟動的硬體要求。

以下是一些常用的檔案、術語和實用程式的列表

  • / (根) 檔案系統
  • /var 檔案系統
  • /home 檔案系統
  • /boot 檔案系統
  • EFI 系統分割槽 (ESP)
  • 交換空間
  • 掛載點
  • 分割槽

檔案系統

[編輯 | 編輯原始碼]

檔案系統只是在硬碟或其他媒體上以計算機可訪問的形式組織資料的 一種方式。 不同的檔案系統具有不同的組織結構,以確定資料和索引資訊 將儲存在何處。一些流行的檔案系統包括

ext2      one of the oldest and most universally supported filesystems on Linux, Unix, and BSD operating systems
ext3      an extended version of ext2 which overcomes some limitations and adds journaling
ext4      fourth extended filesystem - it is a journaling file system for Linux, developed as the successor to ext3.
btrfs
reiserfs  an enhanced journaling filesystem written by Hans Reiser and extended by the open source community since his incarceration
jfs
xfs
fat or  
vfat      the file allocation table-based filesystem used by MS-DOS and Windows 9x
NTFS      A more advanced (than fat) filesystem used by Windows NT, 2000, XP and Vista

分割槽

[編輯 | 編輯原始碼]

在進行安裝時,通常需要建立至少兩個分割槽的磁碟配置

  • / (根):包含 Linux 發行版的目錄。
  • 交換空間:允許核心執行比通常可以放入 RAM 中更多的程序的分割槽。

如果有多個磁碟可用,最好將 /usr 和 /home 目錄放在不同的分割槽中。每個分割槽都將包含一個檔案系統型別,並且可以掛載到活動系統中的檔案系統全域性樹中。要列印活動掛載的檔案系統,請使用 mount

$ mount
dev/hda3 on / type reiserfs (rw)
proc on /proc type proc (rw)
devpts on /dev/pts type devpts (rw)
/dev/hda1 on /boot type ext2 (rw)
shmfs on /dev/shm type shm (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)

交換分割槽不需要檔案系統。它將以原始模式由核心訪問,沒有檔案系統系統呼叫作為開銷。

磁碟速度問題

[編輯 | 編輯原始碼]

在決定分割槽方案之前,您真的需要確切地知道將執行哪些型別的應用程式。

  • 郵件伺服器
  • Web 伺服器
  • 基於圖形 X 視窗的應用程式
  • 等等

如果您的系統有多個磁碟,請使用最快的磁碟來儲存大部分資料。

  • / 包含大多數系統實用程式,並且使用頻率不高。這些可以被運送到最慢的磁碟。
  • /var/log 包含大量日誌資訊。最好放在快速磁碟上。
  • /usr 通常位於單獨的分割槽中,如果您有很多客戶端啟動大量 X 應用程式,請使用快速磁碟。

系統應用程式示例

對於電子郵件服務,Sendmail 寫入兩個主要位置:郵件佇列,通常為 /var/spool/mqueue 和 /var/spool/mail,以及其他位置。Apache 使用幾個不同的檔案,每個託管站點有兩個日誌檔案用於記錄和訪問實際頁面。Apache 在 /var/log(或配置為這樣做的位置)中寫入日誌檔案時花費相當多的時間。

虛擬記憶體 (交換)

[編輯 | 編輯原始碼]

當您設定新系統時,交換空間應為實際 RAM 的兩倍。然而,這在現實世界中的場景中並不總是合理的,但它是一個傳統的指導方針,也是在考試中給出的保守答案。swapon 用於啟用指定用於交換的裝置/分割槽。相反,swapoff 用於停用指定用於交換的裝置/分割槽。這兩個命令都可以使用 -a 選項,該選項迭代在 /proc/swaps 或 /etc/fstab 中找到的所有交換裝置。

可以使用 swapon 顯示關於交換分割槽的 資訊。

swapon -s # Display the active partition

要獲取有關虛擬記憶體使用情況的資訊,請使用 vmstat。

$ vmstat -n 1
  procs                      memory    swap          io     system         cpu
r  b  w   swpd   free   buff  cache  si  so    bi    bo   in    cs  us  sy  id
5  0  1    184   3228  37684  92828   0   0    37    19  124   228   3   0  97
1  0  0    184   3476  37684  92596   0   0     0     0  102   368   0   0 100
2  0  0    184   3476  37684  92596   0   0     0     0  101   328   0   0 100
 
R:processes waiting for run time.
b: processes in uninterruptable sleep.
w: processes swapped out.
swpd: virtual memory used (kB).
free: Idle memory (kB).
buff: Memory used as buffers (kB).
si: Memory swapped in from disk (kB/s).
so: Memory swapped to disk (kB/s).
bi: Blocks received from a block device (blocks/s).
bo: Blocks sent to a block device (blocks/s).
in: The number of interrupts per second.
cs: The number of context switches per second.
us: user time
sy: system time
id: idle time
  1. 開啟兩個終端:在一個終端中定期顯示虛擬記憶體使用情況。在第二個終端中停用虛擬記憶體並重新啟用它。在第一個終端中通知更改。
  2. 您系統的磁碟佈局是什麼,您有多少個磁碟?
  3. 您可以使用多少交換空間?


華夏公益教科書