Show Table of Contents
章 5. LVM 配置範例
本章節提供了一些基本的 LVM 配置範例。
5.1. 在三個磁碟上建立一個 LVM 邏輯卷冊
此範例建立了一個稱為
new_logical_volume 的 LVM 邏輯卷冊,它包含著位於 /dev/sda1、/dev/sdb1 以及 /dev/sdc1 的磁碟。
5.1.1. 建立實體卷冊(Physical Volumes)
若要使用卷冊群組中的磁碟,您必須將它們標記為 LVM 實體卷冊。
警告
這項指令會將
/dev/sda1、/dev/sdb1 以及 /dev/sdc1 上的所有資料都損毀。
# pvcreate /dev/sda1 /dev/sdb1 /dev/sdc1
Physical volume "/dev/sda1" successfully created
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdc1" successfully created
5.1.2. 建立卷冊群組
下列指令將會建立卷冊群組
new_vol_group。
# vgcreate new_vol_group /dev/sda1 /dev/sdb1 /dev/sdc1
Volume group "new_vol_group" successfully created
您可使用
vgs 指令來顯示新卷冊群組的屬性。
# vgs
VG #PV #LV #SN Attr VSize VFree
new_vol_group 3 0 0 wz--n- 51.45G 51.45G
5.1.3. 建立邏輯卷冊
下列指令會由
new_vol_group 卷冊群組建立邏輯卷冊 new_logical_volume。此範例會建立一個使用卷冊群組 2GB 的邏輯卷冊。
# lvcreate -L2G -n new_logical_volume new_vol_group
Logical volume "new_logical_volume" created
5.1.4. 建立檔案系統
下列指令可在邏輯卷冊上建立一個 GFS2 檔案系統。
#mkfs.gfs2 -plock_nolock -j 1 /dev/new_vol_group/new_logical_volumeThis will destroy any data on /dev/new_vol_group/new_logical_volume. Are you sure you want to proceed? [y/n]yDevice: /dev/new_vol_group/new_logical_volume Blocksize: 4096 Filesystem Size: 491460 Journals: 1 Resource Groups: 8 Locking Protocol: lock_nolock Lock Table: Syncing... All Done
下列指令會將邏輯卷冊掛載並回報檔案系統磁碟空間上的使用量。
#mount /dev/new_vol_group/new_logical_volume /mnt[root@tng3-1 ~]#dfFilesystem 1K-blocks Used Available Use% Mounted on /dev/new_vol_group/new_logical_volume 1965840 20 1965820 1% /mnt

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.