參考 : http://linux.vbird.org/linux_basic/0420quota.php#lvm; X8 q' H( H2 u
http://linux.vbird.org/linux_basic/0230filesystem.php#gdisk
% Q# J, c- j2 y# J0 y- _, n) s" n/ l+ r1 @6 A0 j3 u0 N
[彈性放大LV容量]1 u2 P: R3 M! `8 o" b7 J7 M
8 O& w: [% ]9 ^/ `9 ]0 s9 _
l; k( {; u& ~! n, }( E9 \ D" B1) lvextend -l 178813 /dev/11HD_vg/11HD_lv / H% g* j' A( h( l" N( B& q
! t6 b* C7 L. x4 t4 j' r7 D
) z; Q$ u, l, Q$ p/ O4 e8 R( Z178813是欲加大的size,如2.7T=178813 PE, 1 PE=16MB
$ W7 l( W8 o" i' e1 E
2 A) n' f/ D, Y. ~9 i
1 S+ v8 h, r+ _- C2)lvresize -l 1966943 /dev/11HD_vg/11HD_lv$ }. t% M8 u7 }( U% z* Y
7 F# G. C/ G1 M; W/ z: o# X' M3 T# m2 b6 ~5 _
1966943是加大後的總size,如30T=1966943 PE , 可以用 vgdisplay 11HD_vg 查目前的 vg 詳細資料,包含total size and free size ,單位都是 PE* k7 N% G0 Q( a
; U, {/ _; e% G9 C+ X' L
& e# _1 U9 E3 D
3)resize2fs /dev/11HD_vg/11HD_lv/ w! n( a, h* x2 H0 {: O8 A! D
- G* |0 {/ H- D8 s
; N; b% `( }2 n" C3 w
P.S假如找不到gdisk指令,使用 yum install gdisk 安裝
# Y# w, {9 B& `- x使用 gdisk 分割磁區時,
( ^4 C" @, w0 O; W0 c# U- PHex code or GUID (L to show codes, Enter = 8300): 輸入8e00 ===> LVM (logical volumn manager)
5 ]& {5 d# o& q1 _/ ~! z9 x/ F2 r5 z% [. y" G% O2 P
- w. Q! b8 a: T, F3 ?" Q3 B[移除pv]
. u5 ]6 ]8 l3 u' G2 Ipvscan or pvdisplay 毀損的硬碟會顯示:
1 l" q+ w! J) NCouldn't find device with uuid WWeM0m-MLX2-o0da-tf7q-fJJu-eiGl-e7UmM3
4 y, N8 c% P2 `4 j% I+ U% PPV Name unknown device
( S ~7 w4 D8 ?% @6 j( t& d8 c; t2 r1 U5 x2 }
由於硬碟毀損,紀錄還留在VG內,因此需移除 PV:4 _: Y! R; b- Q/ O! K Z# ~7 m
vgreduce --removemissing --force 11HD_vg #但也會把所有 LV刪除,故須重建 LV
" o5 P1 M1 r/ V9 p5 lpvscan or pvdisplay 就不會顯示 "unknown device"
5 T$ N' Z, f" U: w) A) r3 u4 e5 {7 f8 q9 `
( W/ z( G: D0 z2 L
[如何mount 已存在於一顆硬碟內之LVM的partition]7 \& ?% Z6 r4 B; e+ ^7 K
#pvscan. O+ |: I- g- b- N7 d2 j+ v
PV /dev/sdc2 VG vg_centos6 lvm2 [27.46 GiB / 0 free] <===== 吾人想要mount 的LVM (已存在於別顆硬碟)
1 V9 [3 j% w7 H4 [6 ` PV /dev/sdb2 VG vg_test lvm2 [18.92 GiB / 0 free]/ _4 P% x2 \7 E. u) I1 C/ C
Total: 2 [46.39 GiB] / in use: 2 [46.39 GiB] / in no VG: 0 [0 ]. e {9 U4 C8 n8 J. v
7 i' P1 R# h1 a* F6 J# {. ^* [#vgscan' [9 ~* z8 B; m4 q3 [, P% L
Reading all physical volumes. This may take a while...! i& Z% F. \* M4 X
Found volume group "vg_centos6" using metadata type lvm2
( }" X% |/ {' e( O3 s7 \- E Found volume group "vg_test" using metadata type lvm2
8 j. [; |) [# q0 ?$ Y k" `* {. \. |" A% l# g! M4 s" A
. \4 ^$ m+ |; L& O6 W4 G
#lvscan
7 q/ x+ M2 G, |0 J0 C6 o2 F' l inactive '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====未啟用1 j1 ~' n# L& J6 g9 O
inactive '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====未啟用
% v! S2 l" [. e% m+ v ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit
5 N2 \2 I7 a) F ~8 x# A ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit
6 m0 G9 r1 W+ d* e" k+ M& G
* `( J1 ~2 h4 d$ l; p: s. Z& X0 T# ~3 [$ g' ^7 W7 Q
#lvdisplay /dev/vg_centos6/lv_root& |' n/ Z, ?( x z. W
--- Logical volume ---
. d, P# I- _$ d0 ^& F9 f6 y0 A q `0 s LV Path /dev/vg_centos6/lv_root
4 `6 ~! [! @! w2 d# L; x LV Name lv_root
2 P7 u# u( L% ~: t VG Name vg_centos6
3 i5 G4 B" \+ b7 K$ L7 Q LV UUID 0nFiiu-yDQG-1JUB-JI2r-uoTe-Hupi-WGisCe
# C# O& G( ^3 C& r$ k1 x- S LV Write Access read/write
( A- V3 M, S. l+ c! a LV Creation host, time ,
& m1 I2 m! i1 [1 s LV Status unavailable <==== 不可用* A) `* B+ j" ^ |$ s
# open 1
& M8 T9 m7 ~+ E/ {% v, O LV Size 21.84 GiB' e: d: h, x% }. a
Current LE 5591$ h, W! v; B: K: b5 f, n3 U, A
Segments 1% G$ T) E+ u c4 V
Allocation inherit$ H& Z( D7 p8 Z# f
Read ahead sectors auto" ]2 P. \4 r7 U$ s
- currently set to 256# S& u+ F# f# K9 v- ], {2 o
Block device 253:2! l1 i+ S1 L" x9 e$ f) c0 q
! c' N: }! x5 \7 O t' B( I8 k; w* t/ `: G
重點在這裡:
8 w) @7 I5 D R% Q1 b- Vvgchange -ay vg_centos6 <====== 啟動 VG (假如 關閉VG ==> vgchange -an vg_centos6)
4 Y, i5 g6 O0 }5 z3 z ]* D再查一次 LV:) E9 ?$ F; p/ z/ O
#lvscan, o8 z6 W" A- u9 H
ACTIVE '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====已啟動了
: a7 v/ R' d: ]1 d! I1 D5 H4 D2 M ACTIVE '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====已啟動了
) {& W3 W6 \# @. D5 G/ i9 } ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit
' o7 S/ j. D! v* B ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit
: f" S4 X7 n" g3 R9 g
K: T8 \ \ v) }* y( ]
2 l1 A# q- t( P* `: y* Jmount LVM:
% I$ F i @& smkdir /mnt/lvmdisk
) r2 z7 i$ i0 S2 [+ r* y+ y/ Xmount /dev/vg_centos6/lv_root /mnt/lvmdisk
! w/ }, t- i. K大功告成!- h$ `6 L- s' A. z: \9 s' X0 {
4 b$ O6 \ L' S# G) G
* p9 ]6 O' j2 G
|
|