LVM - Linux Volume Manager 主要是用於把多個實體的硬碟partition合併成一個磁區
讓硬碟空間的使用更具彈性!!
要實作LVM先來了解一些相關的名詞
Physical Volume 簡稱 PV:代表實體的硬碟partition,要規劃LVM必須將分隔磁區的代號改為8e
Volume Group 簡稱 VG:LVM最主要就是在建立VG,用來整合所有的partition成為一個大的partition
Physical Extend 簡稱 PE:建立 VG 的時候,同時要指定 PE 這個數值,PE主要是來控制VG的最大值
當 PE 為4MB時,VG最大的容量就是 256G,要VG大於預設的256GB時,記得要修改這個數值
接下來就來把LVM給架起來...
假設今天有一顆掛在/dev/hdb的10G硬碟,我們將它分割成兩個5G的partition
1.#fidk -l
Disk /dev/hdb: 30.7 GB, 30738677760 bytes
16 heads, 63 sectors/track, 59560 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 xxx 4965976+ 83 Linux
/dev/hdb2 xxxxx xxx 4866008 83 Linux
可以看到現在系統當中的分割表,找到我們想要建立LVM的partition
2.建立8e磁區編號
#fdisl /dev/hdb
#Command (m for help): p
Device Boot Start End Blocks Id System
/dev/hdb1 1 xxx 4965976+ 83 Linux
/dev/hdb2 xxxxx xxx 4866008 83 Linux
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
依序將兩個partition都建立完成,最後儲存離開
Command (m for help): w
The partition table has been altered!
3.#partprobe
立即讀取partition table,不必重新開機
4.開始建立PV
#pvcreate /dev/hdb1
Physical volume "/dev/hdb1" successfully created
# pvcreate /dev/hdb2
Physical volume "/dev/hdb1" successfully created
pvscan和pvdisplay可以檢視目前系統上PV的資訊
5.建立VG
# vgcreate testvg /dev/hdb1 /dev/hdb2
testvg是自行訂義的名稱
#vgdisplay
查看VG的資訊
--- Volume group ---
VG Name testvg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 9.82 GB
PE Size 4.00 MB
註:VG的相關指令
vgcreate :建立 VG 的指令
vgremove :刪除一個 VG
vgscan :檢查系統上面是否有 VG 存在
vgdisplay :顯示目前VG
vgextend :增加額外的 PV
vgreduce :移除 PV
6.最後建立LV
#lvcreate -L 9.82G -n testlv testvg
Rounding up size to full physical extent 9.82 GB
Logical volume "tsetlv" created
testlv是我們自定的LV名稱,LV建立完成啦!!
# lvdisplay
--- Logical volume ---
LV Name /dev/testvg/testlv
VG Name testvg
LV UUID B6kSrg-9LMG-gqVy-jjz8-x0gM-ya9S-XLFcZN
LV Write Access read/write
LV Status available
# open 0
LV Size 9.82 GB
Current LE 4767
Segments 2
Allocation inherit
Read ahead sectors 0
Block device 253:0
7.當然不要忘了做mke2fs和mount
#mke2fs -j /dev/testvg/testlv
#mkdir /mnt/lvm
#mount -t ext3 /dev/testvg/testlv /mnt/lvm
完成!!
- Dec 31 Mon 2007 11:57
LVM筆記一
close
全站熱搜
留言列表
發表留言