52AV手機A片王|52AV.ONE
標題:
LVM 教學
[打印本頁]
作者:
IT_man
時間:
2016-1-20 16:52
標題:
LVM 教學
參考 :
http://linux.vbird.org/linux_basic/0420quota.php#lvm
. q7 Z9 w4 t; G6 p- R" O
http://linux.vbird.org/linux_basic/0230filesystem.php#gdisk
. N$ X/ m% s4 y6 k. P! i k. W
0 X; g6 ^; H% S0 R
[彈性放大LV容量]
; T6 e+ |- N( h5 M1 G
' x! N, n L* A9 E& D* I
) B0 A' s( t% ~ f" K
1) lvextend -l 178813 /dev/11HD_vg/11HD_lv
' I: O- o. q0 B
9 q; e; k# N' r' @
8 s9 J3 |: q# y- |7 g
178813是欲加大的size,如2.7T=178813 PE, 1 PE=16MB
* q4 z& y( z9 P; ~3 j" F0 h% a- O
U. N. _" e- c0 w2 d+ [* U! \# f
7 n( Y6 i5 b8 n3 L& M) J% C
2)lvresize -l 1966943 /dev/11HD_vg/11HD_lv
0 J9 H' p% E% |# j" j! a1 y! {
, W4 H; |7 i4 W) |% q# Z* @
' g# k# v/ K# u1 Y9 A. Z% k7 x
1966943是加大後的總size,如30T=1966943 PE , 可以用 vgdisplay 11HD_vg 查目前的 vg 詳細資料,包含total size and free size ,單位都是 PE
! p4 K$ b$ u( M& Q; M
1 v0 ], T' U2 ?7 m* ~6 r5 M
% @' N3 Q+ E+ I# S! C o
3)resize2fs /dev/11HD_vg/11HD_lv
" G2 h+ }5 [( l% n7 S( O
4 H! d( w- `" B& Q$ V$ ^
; |; V$ T: w& }' J
P.S
假如找不到gdisk指令,使用 yum install gdisk 安裝
# m# g+ u$ i0 _7 H0 Y. d* @
使用 gdisk 分割磁區時,
" y! d$ S+ q) {2 G
Hex code or GUID (L to show codes, Enter = 8300): 輸入8e00 ===> LVM (logical volumn manager)
' ?! `4 r- C2 m# I
. d/ \3 H1 C9 c
( k ~+ L( b' ]1 `
[移除pv]
9 g% k) P `9 F W& _
pvscan or pvdisplay 毀損的硬碟會顯示:
: A" x$ D- J7 `- H" `5 i
Couldn't find device with uuid WWeM0m-MLX2-o0da-tf7q-fJJu-eiGl-e7UmM3
6 g0 J% x* d7 i* b8 j* s
PV Name unknown device
. A8 E# k; X2 j/ M5 e, d8 |
( d) D* D- [2 m
由於硬碟毀損,紀錄還留在VG內,因此需移除 PV:
) ?. R4 g) h! B
vgreduce --removemissing --force 11HD_vg #但也會把所有 LV刪除,故須重建 LV
5 w X. s$ ?% b$ t' T' p! |, e0 Y V
pvscan or pvdisplay 就不會顯示 "
unknown device
"
" o0 i0 f( I5 c8 Y0 H" @" x
3 ~# o" `$ H9 J( Q: z* S
& d6 e, G, Y$ t. [3 L9 O
[如何mount 已存在於一顆硬碟內之LVM的partition]
5 p3 E" K h! v* v
#pvscan
0 _; |4 O; v3 @" G
PV /dev/sdc2 VG vg_centos6 lvm2 [27.46 GiB / 0 free] <===== 吾人想要mount 的LVM (已存在於別顆硬碟)
' O6 T' [9 a, i4 z
PV /dev/sdb2 VG vg_test lvm2 [18.92 GiB / 0 free]
2 N' [1 b$ V9 Y% N
Total: 2 [46.39 GiB] / in use: 2 [46.39 GiB] / in no VG: 0 [0 ]
" o, G9 B+ H7 D* J& q
2 Q; j8 r$ {1 P. H) W
#vgscan
1 l% B: S( v8 L7 P" f
Reading all physical volumes. This may take a while...
% ]9 G: q! v: ?2 O8 n O! U
Found volume group "vg_centos6" using metadata type lvm2
v2 D% n% Q0 z5 ]# [' s- j
Found volume group "vg_test" using metadata type lvm2
' k& p- b N- b: v# U; g% u/ R
# I. a6 q+ c- y" \5 ?4 e
+ ?; C, u) ?4 I' p! H( i
#lvscan
8 Y. g) ]! X/ l" ~
inactive '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====未啟用
# |) Y( d: U( U( y- a7 v ~
inactive '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====未啟用
! Y5 G8 _& _1 @
ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit
5 H; [4 J2 k( ?( \" G
ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit
1 F `' C3 ?$ \: U
, t. v4 b+ c# u Q0 m% V- r$ n2 {
8 ]: p8 O4 G! M: K5 n- A/ w
#lvdisplay /dev/vg_centos6/lv_root
3 e1 T5 R k5 u1 ?/ ]
--- Logical volume ---
8 f/ \8 @/ W/ k! F
LV Path /dev/vg_centos6/lv_root
0 {8 \) D: f7 Y; I
LV Name lv_root
4 q8 w7 ]" c, `# a! u% r( L
VG Name vg_centos6
( J/ `/ |/ F# M- e4 B
LV UUID 0nFiiu-yDQG-1JUB-JI2r-uoTe-Hupi-WGisCe
0 W- t& e$ X, @8 \3 ~$ [
LV Write Access read/write
/ Q( ] n+ m' }3 ^
LV Creation host, time ,
0 N4 n3 a/ b% n4 A* l, ]
LV Status unavailable <==== 不可用
+ g0 o. m1 `( ^( @
# open 1
$ n& | l" ^ a: E
LV Size 21.84 GiB
; K6 h% |$ O% V: Z( ^# \! j
Current LE 5591
+ X# ~* h6 h& x; C0 W* J/ H+ x- `
Segments 1
; A5 @! h2 U) x5 K9 L
Allocation inherit
3 f) ]& {' t4 e0 m3 ]: c( X
Read ahead sectors auto
% o8 X) |4 \, {; F) s4 H
- currently set to 256
- o/ `9 u; g; D- C
Block device 253:2
5 R) d( w8 ]( e( R+ b3 m' e
5 ~. W$ N- y1 O4 M1 T5 z" _
: k6 t1 T' q8 v9 S0 V% P" T$ M
重點在這裡:
- E3 l+ x2 {, P+ a& G7 e( \% Z
vgchange -ay
vg_centos6 <====== 啟動 VG (假如 關閉VG ==> vgchange -an vg_centos6)
/ d, ?$ J+ ?$ x' D
再查一次 LV:
# D- Q' r! u' a! f5 x
#lvscan
, E- C2 S( ?4 C, y: Y/ R4 u
ACTIVE '/dev/vg_centos6/lv_root' [21.84 GiB] inherit <====已啟動了
A9 H$ Q7 Q* \0 M7 \! ~9 T Z
ACTIVE '/dev/vg_centos6/lv_swap' [5.62 GiB] inherit <====已啟動了
- [3 A6 b, g- _
ACTIVE '/dev/vg_test/lv_root' [16.98 GiB] inherit
2 M& Y- o, t) ?+ L7 w, l
ACTIVE '/dev/vg_test/lv_swap' [1.94 GiB] inherit
& u4 _- U. a4 f8 d& C; h7 m* e& b
, c( a) \1 i% s1 i: J( u }
5 H% U8 E; g& b
mount LVM:
v! R5 X/ f0 e, J1 E: j! P
mkdir /mnt/lvmdisk
# H$ Y: c% ~7 ^
mount /dev/vg_centos6/lv_root /mnt/lvmdisk
5 b8 B: P h1 l( k2 k8 x4 E$ w* Y
大功告成!
- T+ l/ b/ V4 l3 J6 i- V( ?5 r
3 ^4 l" Y9 b- K7 ~
! Y, w# o: h2 T$ K3 U, D
歡迎光臨 52AV手機A片王|52AV.ONE (https://www.itech.casa/)
Powered by Discuz! X3.2