5 B% Q3 O7 m5 q+ i1 l' \. V) ~3 ]3 U
3)resize2fs /dev/11HD_vg/11HD_lv* x g( |( B. Z1 e" |# i: _' x, v' s
5 {2 ~: Z9 ]: C
1 _; |7 ^/ t7 h6 i
P.S假如找不到gdisk指令,使用 yum install gdisk 安裝 ) N0 X" |+ j5 Y( S$ G6 Y$ L( K( `使用 gdisk 分割磁區時, 0 I7 ~2 P' r8 n8 kHex code or GUID (L to show codes, Enter = 8300): 輸入8e00 ===> LVM (logical volumn manager)5 @! S$ h( L3 @7 U6 b
0 ], f% B+ N$ z4 j7 ~7 {0 u( ?5 n $ A1 T8 P. ]$ O- }9 U* ?" e; j. p[移除pv] & h% u% H: h5 Gpvscan or pvdisplay 毀損的硬碟會顯示:% @, F4 [2 t% L! o* g% {3 H
Couldn't find device with uuid WWeM0m-MLX2-o0da-tf7q-fJJu-eiGl-e7UmM3 , _1 }6 @( D( O3 [PV Name unknown device; Z7 G$ U1 U- U* P- @" x
7 |, W3 W' ]% A4 {5 ]* C6 {" L1 x
由於硬碟毀損,紀錄還留在VG內,因此需移除 PV: 5 z! J. l, f9 c: X5 |$ p# |vgreduce --removemissing --force 11HD_vg #但也會把所有 LV刪除,故須重建 LV9 ^9 S. T ~0 U! w6 w4 m) W
pvscan or pvdisplay 就不會顯示 "unknown device") \1 L8 ^8 r0 S
7 E1 z4 |" \; {7 V, { u3 E! I: h: @) D. Q! u" T [如何mount 已存在於一顆硬碟內之LVM的partition] L q1 X: @7 E) p: j" L" s
#pvscan 1 u! ^) X- q3 G6 y1 y5 B, r PV /dev/sdc2 VG vg_centos6 lvm2 [27.46 GiB / 0 free] <===== 吾人想要mount 的LVM (已存在於別顆硬碟)% L0 Q* R5 p; f1 l, e
PV /dev/sdb2 VG vg_test lvm2 [18.92 GiB / 0 free] j: ?+ R, a5 j: @4 @# p Total: 2 [46.39 GiB] / in use: 2 [46.39 GiB] / in no VG: 0 [0 ]$ ]" p( t1 I) Y, L6 J7 U
7 j4 u% j) d$ B+ t#vgscan - E4 @8 y4 h, H1 h* } Reading all physical volumes. This may take a while... [% R7 d! }! c
Found volume group "vg_centos6" using metadata type lvm24 U# B C+ a+ E( B4 \
Found volume group "vg_test" using metadata type lvm2: m+ G- e0 w% G8 _+ ?4 g; q
" k/ [7 r4 p l3 I- {$ x$ X
/ Y$ F5 I) {& @9 h
#lvscan: _4 v) o w' u3 L7 b8 k' w* z4 {
inactive '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====未啟用: p8 m; l$ O- B& ~
inactive '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====未啟用 . n0 b0 ?+ v8 k% \; _ ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit # G* R0 f z+ i8 k4 J6 ~ ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit9 q: d: p5 n% d$ n5 m# C0 |. ?" [
0 Q+ I C& q8 u. y2 p" v
) \# z( |% \9 h& z# f0 [9 G
#lvdisplay /dev/vg_centos6/lv_root , ?+ X* w5 Q2 ]* S6 A& ? --- Logical volume --- $ Y- V3 Q% w0 @ LV Path /dev/vg_centos6/lv_root( E, B& l2 H- v' i# {
LV Name lv_root - K; v2 {4 ^& q$ N |2 s VG Name vg_centos6) R5 W& S8 Q) A) H- v4 ^. i
LV UUID 0nFiiu-yDQG-1JUB-JI2r-uoTe-Hupi-WGisCe 0 M3 X+ s0 Z5 F; H: I3 |) E+ A LV Write Access read/write% b8 G: s3 w% B: ^
LV Creation host, time , 1 D% G' c/ ~0 F8 X; J# ] | LV Status unavailable <==== 不可用4 b P- ]" V( x2 ]6 S% A1 w1 B
# open 1, S. c2 T! |! S0 d$ o n
LV Size 21.84 GiB# J: g& q- a4 c3 [# \( ^
Current LE 5591 : n0 O/ h. u7 o1 r/ h: B Segments 1, K- ~8 c2 p8 Y2 N; y/ t% M: t
Allocation inherit. {- V& S+ ~4 c6 |: `; n
Read ahead sectors auto # j ?5 b. y0 }" C - currently set to 256 4 c6 Q- O3 L s/ {+ d( ]( w8 f1 u Block device 253:2 b$ c3 g( L( @9 J& l
/ G3 F6 G- N; A+ h( P t " e2 U$ B& F9 g' x @/ i重點在這裡:9 }" k Q9 w! ?
vgchange -ay vg_centos6 <====== 啟動 VG (假如 關閉VG ==> vgchange -an vg_centos6) " `8 o# R7 v O3 v' O再查一次 LV:6 T9 }4 s, p- e' J
#lvscan ) S5 a$ w ]0 c: y ACTIVE '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====已啟動了 " s' _; P/ W4 o% I% F ACTIVE '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====已啟動了% ~& b$ q& c" Y0 z8 E* x" D
ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit 1 L0 n5 H7 J% d5 H* d! P ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit' K5 R [/ F" l* U+ B
4 ~5 @* _' |5 h( V$ m. p5 ]% H' ^+ C
mount LVM:" A( c i5 i. X/ p
mkdir /mnt/lvmdisk. _+ U5 w: t( @
mount /dev/vg_centos6/lv_root /mnt/lvmdisk . U& b1 V3 k, b大功告成!- B) V. t5 R( V) Q, P' A/ G
0 s5 T# i7 G9 ~$ E( _# V8 @