tid=27827&參考 : http://linux.vbird.org/linux_basic/0420quota.php#lvm
1 g* z. T0 U/ G- n http://linux.vbird.org/linux_basic/0230filesystem.php#gdisk
. a! X/ _! J8 x7 f* J: j! m
9 Y& n" L# P4 r" R3 U; ]/ [9 O: h[彈性放大LV容量]
4 s! D* h9 `; k7 k5 i& a, U$ \0 J4 C! ?6 j) s
9 n8 C2 s+ I( v1 u6 x9 M1) lvextend -l 178813 /dev/11HD_vg/11HD_lv 6 M9 l G* a& {. t
0 G/ u# G j# K
" U: g6 E5 A' U4 i; F/ D178813是欲加大的size,如2.7T=178813 PE, 1 PE=16MB
`* D! p& O& X% Z1 _' ?7 V9 U
0 \* S! V1 K' k ?# x( K" J
' Z: [ H) n8 ?7 m2)lvresize -l 1966943 /dev/11HD_vg/11HD_lv/ \1 E8 @+ }- D& L' q# c
5 L$ S4 S* d5 L$ Z0 A2 n" y# l) p
" f2 C% I8 @ l+ O1 a& g9 s1966943是加大後的總size,如30T=1966943 PE , 可以用 vgdisplay 11HD_vg 查目前的 vg 詳細資料,包含total size and free size ,單位都是 PE3 I$ R7 d6 s- [ m- u7 Q
4 P7 P! A0 l2 v Q; R" k, Z8 r: J' |. x! u: M7 B q- Y
3)resize2fs /dev/11HD_vg/11HD_lv4 u+ I" }8 [3 z: B5 C' x
$ H* Q; O6 B1 p; Z" z' d9 x2 r
# y! ~; O2 u3 H9 x: ?3 XP.S假如找不到gdisk指令,使用 yum install gdisk 安裝
A, L9 @1 H" a; {使用 gdisk 分割磁區時,
1 C% B: l5 l# T$ i# xHex code or GUID (L to show codes, Enter = 8300): 輸入8e00 ===> LVM (logical volumn manager)
m: J4 z# t6 `) P4 Q1 K) B1 G
6 U9 D8 e2 R/ y& O9 k
! O7 ]; `& q- Y2 c0 r" V[移除pv]
7 C, _' `) [) I7 q. S# Tpvscan or pvdisplay 毀損的硬碟會顯示:: @% w. _4 E1 N* p" B8 }; Z
Couldn't find device with uuid WWeM0m-MLX2-o0da-tf7q-fJJu-eiGl-e7UmM3. `7 j. Z- t# m6 R
PV Name unknown device
+ l+ w7 B. n( U4 r4 Q
% L9 k% b/ f+ v5 l P由於硬碟毀損,紀錄還留在VG內,因此需移除 PV:
% T4 J- W. H& @ ?vgreduce --removemissing --force 11HD_vg #但也會把所有 LV刪除,故須重建 LV3 h" r: w# R$ x4 w. n7 v
pvscan or pvdisplay 就不會顯示 "unknown device"
0 F* L/ ^, v+ d0 @. n' w
3 j, D3 M0 z; o( I; \& ]( _3 q; W' d$ p! v
[如何mount 已存在於一顆硬碟內之LVM的partition]7 h! B. o7 d/ w. U
#pvscan
! |! A: \7 o8 w+ n2 ` PV /dev/sdc2 VG vg_centos6 lvm2 [27.46 GiB / 0 free] <===== 吾人想要mount 的LVM (已存在於別顆硬碟)* y% w& W+ y" N
PV /dev/sdb2 VG vg_test lvm2 [18.92 GiB / 0 free]
0 I! N+ ~0 n- F0 |- {2 F& y! M% G7 { Total: 2 [46.39 GiB] / in use: 2 [46.39 GiB] / in no VG: 0 [0 ]
8 z5 E& E: M2 N h Y! L( `9 g0 c# u6 L. h, O
#vgscan
/ l; ?8 F0 m9 D Reading all physical volumes. This may take a while...6 @7 g0 e9 W, m# S8 v) M
Found volume group "vg_centos6" using metadata type lvm2
7 j9 C# y8 m" \# b: Q Found volume group "vg_test" using metadata type lvm2
& q& x5 i( R, V* J5 [' f: W
- b; k1 c' T% W) g- ?% x2 c5 N; \ a
#lvscan
% G& o# ~# Q5 q/ r9 F# d inactive '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====未啟用
# b( D; l1 ^: o# k6 q3 A; A inactive '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====未啟用
- ~* D* O6 l0 Z/ M: Q ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit! |' Z! l$ @, Z3 ?2 \ w6 v
ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit
4 L) @) X' m$ ~0 R+ W8 Y5 m0 i1 S7 F4 o7 z
1 q S7 m% x. t, z" `/ d0 B! {
#lvdisplay /dev/vg_centos6/lv_root8 B- Q4 b; u& K: A( R Y
--- Logical volume ---5 ]1 c- M1 N) j. S/ Q
LV Path /dev/vg_centos6/lv_root
5 }% ?7 _- G, X7 t# J& v/ ^ LV Name lv_root! J7 A9 h q* v, R1 O: B' D
VG Name vg_centos60 b$ r! q# [% A3 E9 ^' B# U
LV UUID 0nFiiu-yDQG-1JUB-JI2r-uoTe-Hupi-WGisCe% ~ f* m' C$ b% X
LV Write Access read/write! h. l; G$ l9 e6 F
LV Creation host, time ,
6 I7 Q% K0 c5 d: d2 U2 a2 k9 a LV Status unavailable <==== 不可用" K$ b& X1 o |2 u8 K
# open 1
3 X7 ^& n5 F) t LV Size 21.84 GiB
! S b5 g9 Y9 T; X' G Current LE 5591
. w# E. ~4 y! l/ P% T Segments 17 V* o1 L) s; [! N
Allocation inherit
; `; i8 a# Z/ j1 e/ I. c: q Read ahead sectors auto+ Y( S$ A$ X$ m" }; q
- currently set to 256
/ r% ]$ T; W2 p3 k Block device 253:2
% m( P" A, U9 s; ]! B. K9 A- _! i; i; p& ~4 n, [
* ~' I3 c; ]; {) a2 _8 ~3 `1 z) c
重點在這裡:+ t& P1 X0 Z' U- T% I# S( Y
vgchange -ay vg_centos6 <====== 啟動 VG (假如 關閉VG ==> vgchange -an vg_centos6)
$ }1 m6 q1 n' q4 d4 o( {1 D8 S再查一次 LV:1 E2 o3 D+ r$ K0 M
#lvscan* ^( F# D2 p/ k6 C! f1 _
ACTIVE '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====已啟動了2 T( M+ z2 b# q' i$ T
ACTIVE '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====已啟動了- ]9 s+ j: R; R# y* c
ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit5 p, ~) P" Q3 |9 |7 V. ?
ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit0 U+ |0 r0 c) [. p+ P
! n# H$ S2 ]! _/ W) @4 W: o, U( m" ]. R6 a" P `
mount LVM:. X/ J1 O6 l' y
mkdir /mnt/lvmdisk
% E0 r* `! E8 v) h% rmount /dev/vg_centos6/lv_root /mnt/lvmdisk
! j7 v3 p1 N( [" X9 s* Y大功告成!% z& x1 c% l* W
8 M, g9 w* V- ?
1 k) F/ A! d3 u' `* B
|