參考 : http://linux.vbird.org/linux_basic/0420quota.php#lvm1 x9 P% X' {- W q w4 @2 i
http://linux.vbird.org/linux_basic/0230filesystem.php#gdisk9 Z; B7 K$ ?% ?* S* o
% ^8 ?- X/ w7 M2 e7 u[彈性放大LV容量]4 K0 B c7 k' m2 K$ R' L
, z% W. \$ w$ G1 X2 M% W! M
: n% s1 y+ f, A; t, i8 [! ~4 l1) lvextend -l 178813 /dev/11HD_vg/11HD_lv
+ D$ ?& @0 b: q3 \* \8 n
: I G7 h9 W. h/ R' k- C: R7 A
" {5 L1 _( s3 [& _178813是欲加大的size,如2.7T=178813 PE, 1 PE=16MB
: i. R8 |+ P) Q9 D4 I
: J$ W/ ]2 J& Y2 x; Q4 i" j2 z. F8 n4 e2 c
2)lvresize -l 1966943 /dev/11HD_vg/11HD_lv
% E- o9 [4 g6 z+ W A. K9 e, |5 v: h# Q! H4 Y+ ?
3 H" T. H2 j) v
1966943是加大後的總size,如30T=1966943 PE , 可以用 vgdisplay 11HD_vg 查目前的 vg 詳細資料,包含total size and free size ,單位都是 PE8 u" _2 h l' r1 z
5 C* A+ U% _' a: P, ]5 B2 F+ i" q: |
4 |, h0 M' B# C* w+ \: n% m3 E3)resize2fs /dev/11HD_vg/11HD_lv
' F" P+ L5 n; c- [5 A* M
; T$ U: o$ w) N1 K, x2 C( P' k
3 z2 F& G( \4 D& p5 aP.S假如找不到gdisk指令,使用 yum install gdisk 安裝
% r$ l r, w, M; _. w' Q使用 gdisk 分割磁區時, : p7 E. G$ W5 ?# u( K* t3 L5 m5 q
Hex code or GUID (L to show codes, Enter = 8300): 輸入8e00 ===> LVM (logical volumn manager)
2 G# B& J) s" u x( y: ~* x7 Z( F, L5 r+ ], H
7 s. @ u; P0 U" i, g5 g P
[移除pv]1 [$ L* S X5 Y8 Y
pvscan or pvdisplay 毀損的硬碟會顯示:9 p J4 u3 b, g* D/ [! @
Couldn't find device with uuid WWeM0m-MLX2-o0da-tf7q-fJJu-eiGl-e7UmM3
6 L& z5 o/ W# t% ]8 g9 t. vPV Name unknown device
E/ f( D# P/ ?) w' T2 k H% H$ z/ Z, F7 Z, e3 x2 ]0 \
由於硬碟毀損,紀錄還留在VG內,因此需移除 PV:
% z+ n- T! q/ x* i% |% uvgreduce --removemissing --force 11HD_vg #但也會把所有 LV刪除,故須重建 LV
0 D' {, F/ e/ e# T* Spvscan or pvdisplay 就不會顯示 "unknown device"
9 i5 o _3 V6 u+ n, i8 ^
( y7 p7 U( j# ^ P! U/ \1 h
, i2 V$ Q A/ o# Z[如何mount 已存在於一顆硬碟內之LVM的partition]& D$ Y5 C P! t) i+ l
#pvscan
8 `. J p2 }" V) Q6 `& I PV /dev/sdc2 VG vg_centos6 lvm2 [27.46 GiB / 0 free] <===== 吾人想要mount 的LVM (已存在於別顆硬碟)
) |5 N" w" T! Q( B' x9 I PV /dev/sdb2 VG vg_test lvm2 [18.92 GiB / 0 free]* p) b% v0 @( E1 c7 s2 x
Total: 2 [46.39 GiB] / in use: 2 [46.39 GiB] / in no VG: 0 [0 ]
( h b: O' d- f& \2 `: u* |* U" N$ F0 x" P) k9 o: t
#vgscan. A7 f) E0 p) n# X. A5 g
Reading all physical volumes. This may take a while...
: h; D ^/ [# t# K Found volume group "vg_centos6" using metadata type lvm2" ]7 Q7 z4 C: {( K
Found volume group "vg_test" using metadata type lvm2
0 m! D7 L) _) e; o' l7 x+ M! c, c$ ^) w
7 U9 _% T/ z( p: t
#lvscan. `7 W. q7 a1 d5 a4 }- g- V
inactive '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====未啟用0 E% e* w3 f( `7 t1 N8 B
inactive '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====未啟用
- A: c- \/ l8 f6 w+ @ ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit" k! q0 F; Z+ F1 f8 U& G" }5 R
ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit
, B5 q! f ]% g' t- d1 o/ h B' t& o0 @: [
. x4 R" Z0 T) m. x; a3 S- q
#lvdisplay /dev/vg_centos6/lv_root
3 U$ j, E% z, u: ^2 K" }! Q U; J3 R --- Logical volume ---. h4 o7 X$ a* P' ~
LV Path /dev/vg_centos6/lv_root
; D. J4 B9 [+ c$ N; M5 H+ q2 Q LV Name lv_root
& p* s; V6 ^1 ~& [. G3 Z/ x2 q VG Name vg_centos67 \. e' N1 f3 u
LV UUID 0nFiiu-yDQG-1JUB-JI2r-uoTe-Hupi-WGisCe
& ~; V- b; e$ h9 D% _ LV Write Access read/write
B; Z" ~$ A" e1 V w LV Creation host, time ," D) y! R6 V6 m- h; C: @: B) @
LV Status unavailable <==== 不可用
) U1 _, r* R. G3 i/ N8 J # open 1# [5 \% m3 E" ^2 u
LV Size 21.84 GiB
& Y6 s: y5 S) S. k: M7 R" S Current LE 5591& b- R2 D0 N- X+ }) [. ^3 r1 q
Segments 1
( g) N7 M2 a' E f9 m Allocation inherit
5 W! t& I' p# U% f) X( p Read ahead sectors auto
# W. q7 r" Y* X- C, ~( r7 S" i! W2 ^ - currently set to 256/ ~4 [2 ?3 \$ K: U/ f: w: z% A. o
Block device 253:27 n5 |9 L1 U& ]5 ?% T0 }' G
, X4 ]- n' O% s, Z6 F2 r( p5 V7 _6 `" w; ^* K
重點在這裡:$ x. Y$ {. L5 h) I/ s0 i
vgchange -ay vg_centos6 <====== 啟動 VG (假如 關閉VG ==> vgchange -an vg_centos6)
9 L5 D' B( P. d& s7 j再查一次 LV:/ h9 d# X9 j. T" ~! x
#lvscan
. J7 q8 O% h. T6 p& k( c0 i1 ` ACTIVE '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====已啟動了
0 [# p. D+ K; D8 d) d ACTIVE '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====已啟動了: y5 z1 ^3 K7 \! T; K" @2 u3 \
ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit
# b' U: T! w/ n2 D: O8 P ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit
, W# Q, C8 r/ z! @# X5 R8 R6 P; j, }& l7 U8 U. C; Z
6 t4 [0 S1 d$ |' O7 k5 E; }4 K) Wmount LVM:
/ ?* @6 P' G6 Vmkdir /mnt/lvmdisk" [; o" H. @" _& r& J' d1 \
mount /dev/vg_centos6/lv_root /mnt/lvmdisk) Y F1 P" e$ x/ F2 Z [ W6 g r/ y
大功告成!7 S; i+ r2 E" n4 C8 {' l7 w
* C9 D: j/ W) k/ u- A- U9 G$ ?- ^* ^
0 x# s$ R- H9 V+ c! h3 H3 B |
|