第 5 章 LVM 配​​​​​​​置​​​​​​​示​​​​​​​例​​​​​​​

本​​​​​​​章​​​​​​​提​​​​​​​供​​​​​​​了​​​​​​​一​​​​​​​些​​​​​​​基​​​​​​​本​​​​​​​ LVM 配​​​​​​​置​​​​​​​示​​​​​​​例​​​​​​​。​​​​​​​

5.1. 在​​​​​​​三​​​​​​​个​​​​​​​磁​​​​​​​盘​​​​​​​中​​​​​​​创​​​​​​​建​​​​​​​ LVM 逻​​​​​​​辑​​​​​​​卷​​​​​​​

本​​​​​​​示​​​​​​​例​​​​​​​为​​​​​​​创​​​​​​​建​​​​​​​一​​​​​​​个​​​​​​​名​​​​​​​为​​​​​​​ new_logical_volume 的​​​​​​​逻​​​​​​​辑​​​​​​​卷​​​​​​​,它​​​​​​​由​​​​​​​磁​​​​​​​盘​​​​​​​ /dev/sda1、​​​​​​​/dev/sdb1 和​​​​​​​ /dev/sdc1 组​​​​​​​成​​​​​​​。​​​​​​​

5.1.1. 创​​​​​​​建​​​​​​​物​​​​​​​理​​​​​​​卷​​​​​​​

要​​​​​​​在​​​​​​​某​​​​​​​个​​​​​​​卷​​​​​​​组​​​​​​​中​​​​​​​使​​​​​​​用​​​​​​​磁​​​​​​​盘​​​​​​​,您​​​​​​​需​​​​​​​要​​​​​​​将​​​​​​​它​​​​​​​们​​​​​​​标​​​​​​​记​​​​​​​为​​​​​​​ LVM 物​​​​​​​理​​​​​​​卷​​​​​​​。​​​​​​​

警告

这​​​​​​​个​​​​​​​命​​​​​​​令​​​​​​​会​​​​​​​破​​​​​​​坏​​​​​​​ /dev/sda1、​​​​​​​/dev/sdb1 和​​​​​​​/dev/sdc1 中​​​​​​​的​​​​​​​所​​​​​​​有​​​​​​​数​​​​​​​据​​​​​​​。​​​​​​​
[root@tng3-1 ~]# 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。​​​​​​​
[root@tng3-1 ~]# vgcreate new_vol_group /dev/sda1 /dev/sdb1 /dev/sdc1
  Volume group "new_vol_group" successfully created
您​​​​​​​可​​​​​​​以​​​​​​​使​​​​​​​用​​​​​​​ vgs 命​​​​​​​令​​​​​​​来​​​​​​​显​​​​​​​示​​​​​​​新​​​​​​​卷​​​​​​​组​​​​​​​的​​​​​​​属​​​​​​​性​​​​​​​。​​​​​​​
[root@tng3-1 ~]# 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 容​​​​​​​量​​​​​​​。​​​​​​​
[root@tng3-1 ~]# lvcreate -L2G -n new_logical_volume new_vol_group
  Logical volume "new_logical_volume" created

5.1.4. 创​​​​​​​建​​​​​​​文​​​​​​​件​​​​​​​系​​​​​​​统​​​​​​​

以​​​​​​​下​​​​​​​命​​​​​​​令​​​​​​​在​​​​​​​逻​​​​​​​辑​​​​​​​卷​​​​​​​中​​​​​​​创​​​​​​​建​​​​​​​了​​​​​​​一​​​​​​​个​​​​​​​ GFS 文​​​​​​​件​​​​​​​系​​​​​​​统​​​​​​​。​​​​​​​
[root@tng3-1 ~]# gfs_mkfs -plock_nolock -j 1 /dev/new_vol_group/new_logical_volume
This will destroy any data on /dev/new_vol_group/new_logical_volume.

Are you sure you want to proceed? [y/n] y

Device:                    /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
下​​​​​​​面​​​​​​​的​​​​​​​命​​​​​​​令​​​​​​​将​​​​​​​逻​​​​​​​辑​​​​​​​卷​​​​​​​挂​​​​​​​载​​​​​​​到​​​​​​​文​​​​​​​件​​​​​​​系​​​​​​​统​​​​​​​并​​​​​​​报​​​​​​​告​​​​​​​磁​​​​​​​盘​​​​​​​空​​​​​​​间​​​​​​​用​​​​​​​量​​​​​​​。​​​​​​​
[root@tng3-1 ~]# mount /dev/new_vol_group/new_logical_volume /mnt
[root@tng3-1 ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/new_vol_group/new_logical_volume
                       1965840        20   1965820   1% /mnt