tid=27827&參考 : http://linux.vbird.org/linux_basic/0420quota.php#lvm
& p G' e- W8 z- b http://linux.vbird.org/linux_basic/0230filesystem.php#gdisk' l2 q0 c1 e6 p; I1 r7 ^4 G* t; W
! y! H3 N _& ^, i# \0 w8 s* O1 E[彈性放大LV容量]
/ U$ U1 [2 |( s9 n) `" h; N9 B3 t8 M; o# f: z) ^5 a$ F
0 y: B# |$ c) ~7 K: ?: Z
1) lvextend -l 178813 /dev/11HD_vg/11HD_lv 3 A" B6 p: P9 u! ^: c4 T1 L. Z
4 g* G' E# D4 {2 C" j% r* l
! A% p* `# @1 U5 X- P1 I ?
178813是欲加大的size,如2.7T=178813 PE, 1 PE=16MB; z2 ?5 W* W0 A2 R; x- i
. @% |! b$ r% `" O0 w- s" s7 E: C( N& K4 u7 ?
2)lvresize -l 1966943 /dev/11HD_vg/11HD_lv
+ S& @- N0 q) f3 v5 u
2 e# R5 `( v8 x8 u. Z" l/ B; ~
% ]8 F/ C9 V# R6 b* k, S: S, W1966943是加大後的總size,如30T=1966943 PE , 可以用 vgdisplay 11HD_vg 查目前的 vg 詳細資料,包含total size and free size ,單位都是 PE8 O- f: n8 I" w% q
, ~3 d! \ e9 R O: X! @. C. \* f4 V/ ^6 G! V
3)resize2fs /dev/11HD_vg/11HD_lv9 c2 U) j$ |3 g) V/ W$ [! A7 B- i; ]
7 R+ F- {8 K' S
4 D" V; j0 x) I+ I! _P.S假如找不到gdisk指令,使用 yum install gdisk 安裝
8 s5 T5 \& N, a4 }使用 gdisk 分割磁區時,
) j; n, N6 w8 X4 ~# j) ZHex code or GUID (L to show codes, Enter = 8300): 輸入8e00 ===> LVM (logical volumn manager)- \" v& l* u) B+ ]+ U
9 k. L( \3 ~2 r& i+ ~6 [- {4 o- a& `3 F6 T% h
[移除pv]
5 k& \7 T0 X/ `8 F F3 Fpvscan or pvdisplay 毀損的硬碟會顯示:+ v2 q. B$ s: j- `
Couldn't find device with uuid WWeM0m-MLX2-o0da-tf7q-fJJu-eiGl-e7UmM3* Z2 a- F5 C5 u( f/ c) [
PV Name unknown device
: ~6 W6 R$ ?% o, V, h
& ?* z2 q u: c; A& @3 C& a由於硬碟毀損,紀錄還留在VG內,因此需移除 PV:
, V2 U% t0 R- r& a5 p/ i: |vgreduce --removemissing --force 11HD_vg #但也會把所有 LV刪除,故須重建 LV7 Q8 @" C$ h. g( R. W
pvscan or pvdisplay 就不會顯示 "unknown device"
. P. n( o( u. D( }
& U: Q0 i1 |: D8 T; s( n: @4 y" e: h) f" T) R! c; {- o5 D
[如何mount 已存在於一顆硬碟內之LVM的partition]& T/ Q( P7 \& f1 c( j
#pvscan0 w \/ D! n2 v- |# f3 n
PV /dev/sdc2 VG vg_centos6 lvm2 [27.46 GiB / 0 free] <===== 吾人想要mount 的LVM (已存在於別顆硬碟)
0 n2 Y+ q% _' V" a- [7 E/ u( z" E6 g# g PV /dev/sdb2 VG vg_test lvm2 [18.92 GiB / 0 free]
, ?; [0 { d8 D6 [- f Total: 2 [46.39 GiB] / in use: 2 [46.39 GiB] / in no VG: 0 [0 ]
" N: h7 b' l9 F3 h/ M, A2 t7 X4 a0 N* s
#vgscan
% d H8 A8 V. C Reading all physical volumes. This may take a while...: @/ z0 l6 a$ ^4 E$ |
Found volume group "vg_centos6" using metadata type lvm2
, P" j9 q9 p+ X' N Found volume group "vg_test" using metadata type lvm2) G$ e! y1 v, d- K1 C- i
; S' t5 B& I" ^7 n; x$ o# V
' t6 p0 l. G4 J4 x
#lvscan# e: R( [, K$ c1 j
inactive '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====未啟用
9 T& d# J- {7 `2 j" C* X2 V' | inactive '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====未啟用1 z6 u3 D! S! v4 m6 V
ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit
6 Y8 z" ~0 J8 F$ z; u ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit/ {- W0 _2 |. ?5 R
& o- E; l$ v! |* S4 B1 r' Q
' z: M3 d% C" U5 Q8 N#lvdisplay /dev/vg_centos6/lv_root
, ?; _! v+ _7 e# _2 d, P --- Logical volume ---
u6 M7 A! C3 V W0 j0 [% {$ z LV Path /dev/vg_centos6/lv_root. z* G1 Q6 p. B' [# P
LV Name lv_root
9 o* T5 n- M. d VG Name vg_centos6) t3 J0 y5 p! S2 |
LV UUID 0nFiiu-yDQG-1JUB-JI2r-uoTe-Hupi-WGisCe
) u4 h/ i. b/ f# E LV Write Access read/write4 E4 m F V9 p" i( J
LV Creation host, time ," x$ {, A4 J0 c& t8 Y
LV Status unavailable <==== 不可用- u b+ j& B' R' `$ D
# open 1; ]; v+ N6 x1 `& a: e$ @
LV Size 21.84 GiB
# ^2 Y' D2 l: I( Y$ m' D Current LE 55910 [- g3 P* U9 p/ h( y+ B' m9 Z" D
Segments 18 N; i/ |8 ]# y% ?& b5 b. t
Allocation inherit [% m3 R0 ^. l7 \- ?3 e3 V/ C
Read ahead sectors auto$ C" ~$ d6 z3 G& X* D3 j
- currently set to 256
0 [* D$ Q( n. W6 v4 ~# B- b Block device 253:2
8 o+ c- Q. s# { C2 ?
% Z, t" ^* }8 w* E+ |) s" a' F% P8 q0 z
重點在這裡:6 c) a1 B% Q0 ]/ O. h; r3 c! c
vgchange -ay vg_centos6 <====== 啟動 VG (假如 關閉VG ==> vgchange -an vg_centos6)
* v$ x# _) ]8 X4 y1 o再查一次 LV:
( j' @4 u4 q! O& L#lvscan
4 ]! S U0 l8 `3 H9 N: [9 k ACTIVE '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====已啟動了
) c: F3 C- t2 [( F: B: s" Y% g ACTIVE '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====已啟動了: J' X; u, F% D% X
ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit
3 i2 |' q/ ?9 j ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit
9 r; N8 p# R' D6 \) k% ]9 r3 X' Q7 ~" {1 n4 ]$ Y5 O
2 W/ l3 V$ f6 p! K
mount LVM:
$ K3 g5 c; m _& ~mkdir /mnt/lvmdisk$ s* v9 u3 X% y' X
mount /dev/vg_centos6/lv_root /mnt/lvmdisk
[) u! Z3 u4 K, r大功告成!
7 x* P. z+ B; Z3 y2 c! e+ z" }+ C( @. S- ^, z! O9 z3 o8 h% V; }
7 \3 X1 M* H, ~6 u& w |