tid=27827&參考 : http://linux.vbird.org/linux_basic/0420quota.php#lvm4 f0 L, x) j7 A8 f3 o/ f# Q
http://linux.vbird.org/linux_basic/0230filesystem.php#gdisk
$ ~# h7 e" v3 p5 C, R" X
. a! w( y2 ~- n1 r/ }[彈性放大LV容量]
. n, y; o# r9 r* Q6 k z. b) s' L6 v* e5 G: t& F1 S
: p5 |/ O4 O4 b5 c: |1) lvextend -l 178813 /dev/11HD_vg/11HD_lv 2 J) W% e2 u0 ]1 l! K+ l6 R& \
# u$ V/ q+ W( H7 ` q0 N
9 D# C- q- G- O9 ^178813是欲加大的size,如2.7T=178813 PE, 1 PE=16MB
' O# ~3 P, S4 K# u, n5 Z5 I. s( N" N
' C6 L- u' O& ] ~$ l" r& h5 j
2)lvresize -l 1966943 /dev/11HD_vg/11HD_lv
! b R' w4 J% ^/ a
* G9 M# y9 W2 ^5 ^5 {( }
& {/ y6 q: \& v) P- u) ~3 d1966943是加大後的總size,如30T=1966943 PE , 可以用 vgdisplay 11HD_vg 查目前的 vg 詳細資料,包含total size and free size ,單位都是 PE
/ Y4 g N1 d( [
8 u+ Y3 G ]& F- e5 R+ h5 g
. z6 n, x% G9 @1 u1 k3)resize2fs /dev/11HD_vg/11HD_lv
" n! u1 ^% u* h3 u
; U5 f6 y4 G& s9 A x7 @+ g$ i: Q$ F h3 o' K9 K( {% n
P.S假如找不到gdisk指令,使用 yum install gdisk 安裝
$ G5 O) K# s& t$ h- `% \使用 gdisk 分割磁區時,
' v5 \9 f8 q& a8 p1 F% xHex code or GUID (L to show codes, Enter = 8300): 輸入8e00 ===> LVM (logical volumn manager)( U. `* y u# g7 M# P8 \
7 [! F/ s: ~& H0 f) h1 G0 Y- S+ n3 Z0 Q5 S4 w2 m$ N
[移除pv]
/ b5 \1 X3 B/ x! v2 o& Spvscan or pvdisplay 毀損的硬碟會顯示:
( s9 x3 @2 T6 g* `0 o% MCouldn't find device with uuid WWeM0m-MLX2-o0da-tf7q-fJJu-eiGl-e7UmM3
; \6 k! F6 l1 {% |$ _& c7 R6 nPV Name unknown device
& } N V ?7 T/ Y
4 R; N$ [* G9 i5 K1 A2 R由於硬碟毀損,紀錄還留在VG內,因此需移除 PV:
5 `3 A- ~3 `0 m8 d) k( lvgreduce --removemissing --force 11HD_vg #但也會把所有 LV刪除,故須重建 LV( z0 }8 j3 {; g; z" L8 D/ e
pvscan or pvdisplay 就不會顯示 "unknown device"
. f+ ]8 o! r" o* l7 k1 G% C2 J# R, c+ M4 I/ ^$ F$ m
8 u2 ~" j! W: @, ]; u* i6 [9 R$ r4 }[如何mount 已存在於一顆硬碟內之LVM的partition]
- D/ {- q+ j! O9 `#pvscan2 w [7 A8 \: ?; I K+ a' P
PV /dev/sdc2 VG vg_centos6 lvm2 [27.46 GiB / 0 free] <===== 吾人想要mount 的LVM (已存在於別顆硬碟)% w7 _! Z9 f+ D0 C: z
PV /dev/sdb2 VG vg_test lvm2 [18.92 GiB / 0 free]
# s# S& L! h) O% D9 T Total: 2 [46.39 GiB] / in use: 2 [46.39 GiB] / in no VG: 0 [0 ]
0 A0 Y Y5 H3 R7 W2 i) z
' X" Z5 }3 f. j& y& ]" W#vgscan' J* E! w& [7 B/ q6 s' d# g' D
Reading all physical volumes. This may take a while...
; }7 r: A& ^- Q* u* w5 A, A Found volume group "vg_centos6" using metadata type lvm23 H, W2 j9 T: k3 E% T* c
Found volume group "vg_test" using metadata type lvm2- n; L! k4 c" t
' n) @+ x2 t( y. D( X( s
. [. R6 i x4 i6 D' q- C
#lvscan, x$ X: J% b2 Y3 s, F4 v D' n) u
inactive '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====未啟用. J, [ X+ ~( c) [4 _9 Q4 C
inactive '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====未啟用
; P3 T& j# z3 ? e ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit# `' E1 L" S1 ]3 a% e! ]/ |
ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit1 S: _+ v9 b. n, _+ V. V/ Z; O
$ _5 ^! n' X% X0 D* E/ c- J
. I" h1 \* G8 r4 y- c+ F# N1 [#lvdisplay /dev/vg_centos6/lv_root
7 Y0 E5 B( a7 s! t0 F --- Logical volume ---
0 n% r8 i2 F3 m8 | LV Path /dev/vg_centos6/lv_root
2 B$ L% h1 R6 s& j2 G2 _ LV Name lv_root: ~6 g3 A9 ^1 `8 A7 H
VG Name vg_centos6
, R' w& ^' V1 C8 z LV UUID 0nFiiu-yDQG-1JUB-JI2r-uoTe-Hupi-WGisCe
% y1 G! [- i9 c d6 I LV Write Access read/write8 f) T+ ]7 a; [
LV Creation host, time ,
0 G4 m! b2 c: l5 Y LV Status unavailable <==== 不可用, K/ _8 O8 {' A+ T: ~5 g
# open 19 [& x8 ], O! O+ R- W9 M
LV Size 21.84 GiB! ~1 O3 N! j- G+ e# y0 q
Current LE 5591& U& a# z. K2 C4 s( i0 u6 @3 j
Segments 1
+ l9 v: f. a) P Allocation inherit
+ R- Y# Y3 x+ A' X1 `9 E Read ahead sectors auto$ l. b) T: e& U6 ?% \1 Z% R
- currently set to 256
' o; e5 x. r3 C4 ? Block device 253:2
6 t, B9 f- Q1 I' j- q! f6 \) h$ y7 Z4 z4 \; t& r: d8 g4 V( {6 I# {
: _) f$ i5 W7 s! s/ }/ G重點在這裡:
6 ~# @0 r1 g2 K5 z* p; M2 {, Dvgchange -ay vg_centos6 <====== 啟動 VG (假如 關閉VG ==> vgchange -an vg_centos6)
. i- o: ~8 a0 k; K8 g$ y# w3 O再查一次 LV:
$ E6 @% A C6 P2 B. c6 B2 o6 g#lvscan! j9 O ?$ I( D, d
ACTIVE '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====已啟動了
- `0 T; r0 O% X% X ACTIVE '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====已啟動了 S1 O) A7 p; d! Y, Z: @! R4 K
ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit
+ n5 A @" ]9 U3 D. z0 G0 t- s1 E ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit/ M' b% t8 h1 K% l& w% S) _
& c; ~$ ]+ l! }4 ^! h: m9 R6 Y; G! k0 {) `+ C
mount LVM:
4 _. r4 `& U- D0 k' y. J( E. [- r" kmkdir /mnt/lvmdisk$ K* t7 q* h2 j* G, l7 l
mount /dev/vg_centos6/lv_root /mnt/lvmdisk
* Z8 v$ w5 |" K大功告成!0 m: W1 K; q0 d$ A8 G5 t
0 \7 {2 ~4 q. e5 i2 E2 }! T9 R& ]8 A) W. D
|