Menu Close

Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

章 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 上​​​​​​​的​​​​​​​所​​​​​​​有​​​​​​​資​​​​​​​料​​​​​​​都​​​​​​​損​​​​​​​毀​​​​​​​。​​​​​​​
[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