參考 : http://linux.vbird.org/linux_basic/0420quota.php#lvm
$ R" j) j! K+ E& O: Z, D+ p& | http://linux.vbird.org/linux_basic/0230filesystem.php#gdisk
( C" D8 G3 P2 f4 s9 F+ Y
3 p" j8 r6 q: }( o[彈性放大LV容量]
' L/ F- ]9 C6 u( {' }/ b' l& `7 `2 F! ^
. c$ [" p. P. }9 [9 v+ y9 T1) lvextend -l 178813 /dev/11HD_vg/11HD_lv + [0 a2 O Z1 l w/ C% B6 ]$ o
/ I' {8 J4 `" _& r2 h! X( N
5 w" r7 a* e9 l$ W& M0 U" s
178813是欲加大的size,如2.7T=178813 PE, 1 PE=16MB
4 \8 k( x3 e8 w9 z7 B( d6 h
( e& \( |" G8 \* f6 s) V1 M: i; ?5 B$ R( G1 M* R9 L
2)lvresize -l 1966943 /dev/11HD_vg/11HD_lv6 q; A( r2 e4 Z6 Z
. v0 e1 i* V! R( O) y, i
/ G5 {! X8 l: V1966943是加大後的總size,如30T=1966943 PE , 可以用 vgdisplay 11HD_vg 查目前的 vg 詳細資料,包含total size and free size ,單位都是 PE
" o; Y+ e+ z/ D; `) q! M% z. J
+ X. j- Y+ ]( `7 E/ m& f# C+ c, s9 ~. R4 t! q8 t$ r
3)resize2fs /dev/11HD_vg/11HD_lv
* t* F) u+ M# x" \
" |" f. d' I1 c& P2 B: h) ?; Y( ]$ M5 |( v H- z: T- M
P.S假如找不到gdisk指令,使用 yum install gdisk 安裝* D2 {; b- m0 ]+ j1 R# O, Z6 g0 D
使用 gdisk 分割磁區時, : ]- T. V9 M( j$ }
Hex code or GUID (L to show codes, Enter = 8300): 輸入8e00 ===> LVM (logical volumn manager)
4 U4 D( I! f0 Q7 s2 p$ P
/ _, i: t5 x5 R' t
! ]! b+ d. ^6 B M8 K$ T5 E[移除pv]8 _3 `- k1 ~; }
pvscan or pvdisplay 毀損的硬碟會顯示:# Y5 [* V$ W% S! w
Couldn't find device with uuid WWeM0m-MLX2-o0da-tf7q-fJJu-eiGl-e7UmM3. V" z6 B5 }9 _
PV Name unknown device; s5 l7 r! c1 I. W! ^. j
- }4 ]% J% {0 U% p# j1 C- g由於硬碟毀損,紀錄還留在VG內,因此需移除 PV:
* L. o7 l/ \6 R* ?vgreduce --removemissing --force 11HD_vg #但也會把所有 LV刪除,故須重建 LV+ m' m. g+ x- V3 K0 O" Y; W
pvscan or pvdisplay 就不會顯示 "unknown device"' }: I5 i4 x- D5 P' K& I
5 z* t9 n; q4 i6 j
2 W/ L2 \1 P; D: A[如何mount 已存在於一顆硬碟內之LVM的partition], r( y, x5 ] [2 ~# u& u% |! j
#pvscan
) S0 U( {$ o# e3 l( H! e PV /dev/sdc2 VG vg_centos6 lvm2 [27.46 GiB / 0 free] <===== 吾人想要mount 的LVM (已存在於別顆硬碟)6 L" M4 E, w; b, A1 Y" m
PV /dev/sdb2 VG vg_test lvm2 [18.92 GiB / 0 free]
* ?& N6 h7 V& g Total: 2 [46.39 GiB] / in use: 2 [46.39 GiB] / in no VG: 0 [0 ]
5 |) Q, N9 y7 x* H
) s4 \4 S( j; O2 q6 G9 ]/ F#vgscan
5 x' u$ {' `8 a Reading all physical volumes. This may take a while...
4 v; ] c5 I8 i/ V( |; @ Found volume group "vg_centos6" using metadata type lvm2
. H _& X. D$ V( W2 ] Found volume group "vg_test" using metadata type lvm2
0 F" @; x ~: J' j9 S+ F) w
# k* O! {1 @8 H; Y6 b
~7 o3 V$ p8 u4 u! ^#lvscan5 D) t# M4 g7 @
inactive '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====未啟用
r! f/ M# d' P: J inactive '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====未啟用
* \& J7 w, g8 ^' a" A ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit7 [6 }! N( q! W$ n# m
ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit
$ y* m7 q' l3 ~9 U8 A
* c0 T9 M& M& s2 V7 p! o j2 ]
n- ~+ d' C' |3 ~0 \3 T% I#lvdisplay /dev/vg_centos6/lv_root/ }, Y& O G" d$ F, Y, M! l
--- Logical volume ---% s0 c$ k- n) \; u+ q7 P
LV Path /dev/vg_centos6/lv_root/ A! v8 Q3 B; r, w
LV Name lv_root
; `7 o( S: @; f7 u& B! ~# M3 ]3 b1 ` VG Name vg_centos6
# w9 J v9 c* | LV UUID 0nFiiu-yDQG-1JUB-JI2r-uoTe-Hupi-WGisCe
! a# V6 D# c8 y4 z+ U$ q( e6 H LV Write Access read/write/ Q+ V9 S: `8 ` {$ k
LV Creation host, time ," P7 R4 C% ~- l* W
LV Status unavailable <==== 不可用5 X3 ?5 ? P9 }. M! W9 G
# open 1: i2 O+ d; y* O; X# {
LV Size 21.84 GiB
- d) e' L" K/ A* r% l' b) y) x$ H; [8 { Current LE 5591
) H1 ~. Q% p! O0 I Segments 1
2 h; v6 @3 X7 R, F5 m8 i Allocation inherit3 @/ p9 N0 B" T
Read ahead sectors auto
2 J% V. W9 m1 J* F( K# w* } - currently set to 256
* H# ^' P% E K1 g5 K, {; O J0 A* f Block device 253:2
" g! g! X2 i5 h b. V- V0 Y2 E' Z
1 X1 s0 S6 G h$ r+ B0 D1 z. U4 @
重點在這裡:
6 U# i$ R# {; d% z6 pvgchange -ay vg_centos6 <====== 啟動 VG (假如 關閉VG ==> vgchange -an vg_centos6)
- M+ W2 D- W. G# z" l S再查一次 LV:3 L% }8 F/ ~- O2 y Y, r) i& m' k2 g
#lvscan; p5 p% Q, H1 k. `! o
ACTIVE '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====已啟動了5 c, K4 K1 o( X4 I, l
ACTIVE '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====已啟動了
9 f4 {7 ~; Z7 C ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit+ ?" j# ?8 z" @; _
ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit6 g' z( k1 H" ^7 I2 u i3 d/ s; A
7 `# T( p6 J" X7 ]* n* F9 @; n
, n1 O f) r& \mount LVM:2 C+ w2 T2 W4 {$ [7 E+ ^
mkdir /mnt/lvmdisk/ a3 L+ `8 |) x/ E6 A# G
mount /dev/vg_centos6/lv_root /mnt/lvmdisk
- W: _5 G4 f7 t- [. n大功告成!* _3 Y+ f5 S6 t* }; M" Z& K/ e
1 {- G8 s+ y5 x9 f& x. C& d1 ^) a
|
|