找回密码
 注册
查看: 3788|回复: 2

kvm 镜像增加,添加磁盘

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2019-12-30 18:59:06 | 显示全部楼层 |阅读模式
购买主题 本主题需向作者支付 2 金钱 才能浏览

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-12-30 19:43:50 | 显示全部楼层
当我们需要扩展模板镜像的虚拟磁盘大小时,比如原来的虚拟磁盘大小为20G,现在我们想将其扩展到30G,那么我们可以根据如下步骤来操作。' p1 _! |. ]+ p- g) E3 m
- B8 ?% Z1 }+ e9 O2 k% s
整个流程可以分为三个阶段:, C" y, t/ ]2 g' z9 o8 }
  z( @- F; P0 M: g0 u- g
1、扩展KVM镜像磁盘文件大小到30G。6 R+ Y6 U+ g& J4 a5 A0 }# |

! u! w1 _6 R. ^" n2、扩展磁盘分区大小为30G。( I9 a' ~/ {  F1 V' D$ G) @4 p

4 |, @2 A' ^) n, |1 u5 f: w3、扩展文件系统大小为30G。: F1 G7 {: u( ^' k& Q' x# e* I8 o
3 V, z6 R, T- S7 `6 z. t  H
假若当前有一个名为 test_extend.img 的模板镜像,其格式为 qcow2, virtual_size为 20G! Y! u% z$ Q2 N1 d  h
5 c9 B) E* a4 N) j' d
1、首先可以使用qemu-img来查看该模板镜像的元信息:$ e1 L4 V7 M& g- B' A

/ F6 J6 P% G( F% C* x5 v复制代码% b8 ], a$ _% F7 v% A4 W
qemu-img info test_extend.img ! A2 T. @3 ?  Q6 l! E- [$ u9 E
image: test_extend.img3 x9 T# J% f. _' O4 X  j
file format: qcow29 Z% E, h4 o. }. |# \+ i. l! A$ Y
virtual size: 20G (21474836480 bytes)9 L2 J; P7 F( [' |. N) `
disk size: 309M+ |6 ^# M4 f8 I" n* F
cluster_size: 65536
( X: H5 W: i% MFormat specific information:
; s$ @" q1 n0 N+ y    compat: 1.1
. x. n+ ^. Y( w' R. J    lazy refcounts: false2 g* ?5 o( L8 A

+ i9 L+ \, T# a" a7 P$ R复制代码5 f( m+ C, I& ~( L% r
2、由于需要使用到qemu-nbd,因此我们需要先确认nbd模板已经被load:
+ D0 X- Q) I: D; L, ~# H  a; Y3 m3 u8 Y+ b% i. Y
   lsmod | grep nbd/ Z" B: I1 b) ]* i: G
  
9 l. G  @* x0 _7 P     执行如上命令发现没有任何输出,则表示当前系统并没有加载nbd模块
9 {- b  f" N# e. t3 G8 ?$ j+ e( U
3、加载nbd模板,并再次确认(若没有nbd模块,则可以参考这里进行编译安装):5 P, l6 }8 O' l$ }

/ b7 |, V4 s; m3 |  modprobe nbd max_part=8
0 n" V, q. i/ e! a" G. {. }0 k, o  lsmod | grep nbd
( k. h3 X# s2 L/ U" Anbd                    17603  0 / W# E) v; v' g" i- v# W1 [
  - e# Y# Q' I$ l3 k
     此时nbd模板已经正常加载了6 x) I+ q) i* M+ b

3 M; X5 u/ q! ?; {1 D- u4、通过qemu-img命令来扩展虚拟磁盘的virtual_size为 30G:
! }0 d! @; \7 W4 u6 }! x- y; U4 D/ b: O
, d7 C& p, d" z2 D% v$ K1 `3 q6 D2 R# k
  qemu-img resize test_extend.img 32212254720. T2 y( h: J/ e& T9 p. E2 }
Image resized.
# g' l" Z6 \% H1 v' w  qemu-img info test_extend.img 9 G$ b. x, h( F  s+ {( h' e
image: test_extend.img) c0 l  d& |3 j+ X
file format: qcow2) c1 U( y* c( u8 {" i: _
virtual size: 30G (32212254720 bytes)! d" B* K% f& v+ |! C  T. ~
disk size: 309M) a+ R4 L, \; l; E
cluster_size: 65536
2 p; C5 P$ M* H3 ?  V/ UFormat specific information:
& i" z4 K3 Z: ]1 x& `" d6 H    compat: 1.1
# r" a* F7 ~  I0 V: N! a' I; s% ?' e    lazy refcounts: false/ l4 a4 h" q7 N/ l, N0 P: Y5 B

' P# H) M  f! v  I2 `& Y3 B
) `/ `* `4 L7 T" S$ q( W' i  H4 f9 A- S% V. z: _
5、下面通过qemu-nbd挂载test_extend.img到/dev/nbd0设备上:
. }. l4 z1 |) B# _
0 Z, E2 t. h6 v. X- v9 A  w qemu-nbd -c /dev/nbd0 ./test_extend.img
* L6 s6 D( ~; K ll /dev/nbd* | grep nbd0
6 J( q& P; G6 j) Q5 w$ I/ `2 Hbrw-rw---- 1 root disk 43,   0 11月 20 18:09 /dev/nbd0* L- P6 n5 O% s2 [8 R& R
brw-rw---- 1 root disk 43,   1 11月 20 18:09 /dev/nbd0p19 F# K( i- E3 E

# I5 H: T1 G% X. X# y* q: B& {3 ~  |9 O     挂载成功后,在/dev/下会看到如上信息,其中/dev/nbd0p1表示该虚拟磁盘仅有一个分区
. h7 r% X( c0 l: |- ~# U+ I8 y: f* ]
6、下面开始通过fdisk来扩展虚拟磁盘分区大小:
" _1 U5 V9 _4 a3 f) L& R/ C& |, s3 |
fdisk /dev/nbd08 F5 O* W- ^! J8 A
) p5 }$ `$ R5 f) s, R$ `
Command (m for help): p" H4 n- C. R5 ~, B1 V

3 ~. u6 ~3 E  K1 h& p& UDisk /dev/nbd0: 32.2 GB, 32212254720 bytes9 s, M, z+ s, V4 P& X! G; _
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
6 L% ^) r1 n8 K: g' AUnits = sectors of 1 * 512 = 512 bytes: x, K: x4 R+ x9 q# I  V4 p& S% x
Sector size (logical/physical): 512 bytes / 512 bytes% N: c9 n( ~+ [+ H) c& r+ ~
I/O size (minimum/optimal): 512 bytes / 512 bytes
9 x4 D* [" h- A% K% s3 l: f1 a5 D, `+ iDisk identifier: 0x000e8e8d4 B, Y3 W4 B1 _5 h2 T. U6 I5 V2 c" |

5 z, l6 `% N; q* C" x2 O/ q  Q     Device Boot      Start         End      Blocks   Id  System
: l% u7 L! f( q0 x( D% O. j* x- y2 S/dev/nbd0p1   *        2048    41943039    20970496   83  Linux1 l9 h; {8 @# H# y- y; c; A

/ D0 ^, D- H1 UCommand (m for help): d- n' A, b; D# J. N1 d
Selected partition 1# T6 \& x9 B4 x: e
  E5 e( j8 k* h7 ?2 `
Command (m for help): p
0 t3 B! K8 X! Y- _( t) c+ F9 U" k3 L# G2 c" M3 d" ]! N
Disk /dev/nbd0: 32.2 GB, 32212254720 bytes
6 e9 q* @4 Y& N( q9 }255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
; j% _7 ~7 k" H8 R" f0 vUnits = sectors of 1 * 512 = 512 bytes( i$ G/ w: C5 \' {- k2 B
Sector size (logical/physical): 512 bytes / 512 bytes
$ @- h1 N; _9 l% v, ~! QI/O size (minimum/optimal): 512 bytes / 512 bytes0 @2 T# A: K; h7 _  D
Disk identifier: 0x000e8e8d
" I, g' k) I6 }- I% j& G0 u6 w: z" Z6 Y) ?0 h
     Device Boot      Start         End      Blocks   Id  System
& M1 `5 D5 G9 p% Y$ ]% ~% i% x/ P0 f4 u/ V# B/ _- r2 i/ E
Command (m for help): n
* R) W0 i  p( fPartition type:' j! u3 b" B$ c  N) b0 `& i
   p   primary (0 primary, 0 extended, 4 free)( @6 P% Z# ^7 w2 {7 d4 }
   e   extended
0 T( k- O; Z  XSelect (default p): p
" l6 v; }' P$ aPartition number (1-4, default 1): 3 z3 |+ H5 ?9 a% {5 y8 }
Using default value 1
" |2 l' m6 d. x* H: Q! KFirst sector (2048-62914559, default 2048): - B/ x- L! M1 t! f3 x8 N6 F& m
Using default value 2048
: j* w) v( x: D: M2 J- p7 iLast sector, +sectors or +size{K,M,G} (2048-62914559, default 62914559): . `2 P, t% z# A5 c6 Q/ M" T
Using default value 62914559/ J5 \# p  G3 r
) F6 b2 C  V( K$ Z2 j% n
Command (m for help): p
  z8 i; E4 ?8 w% Y) R* M, U% X1 r6 P9 u# q6 d+ {
Disk /dev/nbd0: 32.2 GB, 32212254720 bytes
# f$ G% T7 \% v1 S255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
  @$ u7 D6 E1 g. e5 u& VUnits = sectors of 1 * 512 = 512 bytes
( q+ D1 ?9 p2 H/ o" XSector size (logical/physical): 512 bytes / 512 bytes
9 B/ |8 t' a5 H. YI/O size (minimum/optimal): 512 bytes / 512 bytes( B9 E& c% u! p& I
Disk identifier: 0x000e8e8d2 v4 |2 {/ l9 W; ~. G

+ M6 Y. J8 p1 V( v' V- _) r! z+ [6 D     Device Boot      Start         End      Blocks   Id  System) L) h5 V2 [. C% e0 F* Y8 y% s
/dev/nbd0p1            2048    62914559    31456256   83  Linux
* s9 G' R; ~7 T; T. a8 H+ z1 F5 a3 A% A3 b
Command (m for help): a
* y( y6 ]. c1 n  |( ^& pPartition number (1-4): 12 Y- P. b) L3 b1 |# q
, k2 E! O& e' N4 s1 ~' _
Command (m for help): p
2 {. y6 D* f4 g
/ y/ S6 F( T6 bDisk /dev/nbd0: 32.2 GB, 32212254720 bytes7 S+ _! s, q+ n) @8 E
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
( J4 t8 d$ |$ ~) C& k" KUnits = sectors of 1 * 512 = 512 bytes
% Z- E1 l( }. e6 o4 F" cSector size (logical/physical): 512 bytes / 512 bytes6 R6 m) K$ H* c
I/O size (minimum/optimal): 512 bytes / 512 bytes
: r3 r! Z) Z# A3 K2 x  GDisk identifier: 0x000e8e8d
+ V5 _  o3 O2 A/ O5 s9 h  `" I3 A5 z6 ]: N$ F
     Device Boot      Start         End      Blocks   Id  System
/ g1 G* Q# o3 X+ ^+ [/dev/nbd0p1   *        2048    62914559    31456256   83  Linux% H( ~7 H+ W. Z7 X# y  r

! f6 \' T& C, h1 z1 H3 pCommand (m for help): w, ?3 R! `) d6 W& A- O8 @- O0 C4 |9 Z5 |5 x
The partition table has been altered!
. M* O) f% Z7 r; D
: S# E- w% u2 r  E6 HCalling ioctl() to re-read partition table.
5 A2 l: j4 ?2 c7 P: |- n/ U2 ~' |Syncing disks.
4 H" E- z3 v* l4 U3 x4 F9 N/ h; A# O0 A# D$ f- J. `' @/ i- e
复制代码
( L! H' I3 E$ ]     如此以来,我们已经将该虚拟磁盘的分区大小扩展到了30G
2 f. ]/ i; J$ b, Z3 }5 ?
) _4 A9 v3 Q0 w5 z# u7、至此,我们还需要将文件系统扩展到30G:: z0 h* F  C8 n3 ]0 H
- s6 @  V- Y: k! j: W- X3 o
复制代码; V: U7 {; I6 H& p) W) y  {
e2fsck -fp /dev/nbd0p1 , l3 H$ N% n* ?( t( f
/dev/nbd0p1: Deleted inode 131076 has zero dtime.  FIXED.$ W( \" }0 o9 s. G, \
/dev/nbd0p1: 18489/1310720 files (0.2% non-contiguous), 281286/5242624 blocks0 Y6 d4 C- p% Q$ J6 Y9 W

/ ]5 y" I$ i* f  n" T resize2fs /dev/nbd0p1 / G5 f, C4 z2 G
resize2fs 1.42.9 (4-Feb-2014)' {) G7 i  Z! x9 p
Resizing the filesystem on /dev/nbd0p1 to 7864064 (4k) blocks.6 |8 i$ o" r4 r) _7 N: ?
The filesystem on /dev/nbd0p1 is now 7864064 blocks long.: V% G. {& H& ~0 E
qemu-nbd -d /dev/nbd0. {& [- O& R" r* M
/dev/nbd0 disconnected

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-12-30 19:48:01 | 显示全部楼层
当我们需要扩展模板镜像的虚拟磁盘大小时,比如原来的虚拟磁盘大小为20G,现在我们想将其扩展到30G,那么我们可以根据如下步骤来操作。
- h/ l" S% _6 g; L+ E' S7 g  W; }, ?! ~& }3 {
整个流程可以分为三个阶段:
. `& n4 t$ A( x) ]" y/ w- e9 K8 r9 B0 R  K" \% w" g
1、扩展KVM镜像磁盘文件大小到30G。
+ o2 x3 o, P0 ~7 w
( l, n+ M. K) s2 ~  \; h7 V$ U& T& \2、扩展磁盘分区大小为30G。  E4 l0 \+ c9 t

6 l/ k. r+ k% c  i, ]3、扩展文件系统大小为30G。
  }0 Y$ O4 g$ ?7 G) |, V( Z- s2 U( M" V4 Q
假若当前有一个名为 test_extend.img 的模板镜像,其格式为 qcow2, virtual_size为 20G
  z7 a6 P6 A# e/ Y: r0 L+ |& u# n6 o* Z: e/ R6 k8 j7 r
1、首先可以使用qemu-img来查看该模板镜像的元信息:
( |% o# F" t( P: P6 K
  v0 o0 n0 \' |7 {2 |' Z复制代码6 g- m- i" u0 q8 x" ~. C
root@# qemu-img info test_extend.img & \0 ~. g, x, I% O3 M
image: test_extend.img
& c; b9 A2 J8 bfile format: qcow2* z5 |( Y# q+ Y- K) m) F2 h4 `3 U
virtual size: 20G (21474836480 bytes)
) k' G0 F+ z$ J; _disk size: 309M5 C) S( m- w& F4 n9 I" i
cluster_size: 65536
: r* h' A: K# F' {3 k6 i1 \$ xFormat specific information:
7 f8 I5 o9 W0 |# E6 I" {( F    compat: 1.1
% Y% I0 Z  B8 g3 [# C/ L    lazy refcounts: false
* P# S- P5 f. S8 D' k+ Y/ Croot@ #
) B. A5 w  k: V5 D& f, W7 w( _复制代码- T. R9 z$ H' C) }) u
2、由于需要使用到qemu-nbd,因此我们需要先确认nbd模板已经被load:- a- Q7 c# e. V8 r  n( m$ l
* D3 k5 L& b% X: ~
root@  # lsmod | grep nbd' ]& M2 O8 W, D0 G3 C
root@  #- L$ ]3 K) b, o* F( t0 N# v
     执行如上命令发现没有任何输出,则表示当前系统并没有加载nbd模块
, A0 j: z! u5 ]  e5 ]) a
8 P5 O- y2 r6 B3、加载nbd模板,并再次确认(若没有nbd模块,则可以参考这里进行编译安装):- q8 S: K9 Y6 g9 `  D% _' }

5 u; P& E" }9 i- o/ t2 x1 i1 h2 Groot@ # modprobe nbd max_part=8; P- z7 \, m& ?; b/ N- d
root@ # lsmod | grep nbd5 N8 u& S9 X9 Y; `6 U0 k
nbd                    17603  0
+ A  g/ `2 G) S- iroot@ # * D( a' h/ S3 i6 @6 Y- N. w: E
     此时nbd模板已经正常加载了  u! v$ k4 ~2 g$ p1 N! z( N2 k
0 N, U& W/ B' e0 ?
4、通过qemu-img命令来扩展虚拟磁盘的virtual_size为 30G:
+ V+ ]! a2 x6 Y& i- y! V$ d. ]" d& z( S
复制代码, \& I  v# g( `+ Z; _
root@ # qemu-img resize test_extend.img 32212254720
' f3 `( V* a, k- v* @Image resized., M1 I# S' }4 o& A7 E
root@  # qemu-img info test_extend.img
" S6 U0 |' [2 T8 E% l, M5 c% ?image: test_extend.img
5 j$ \; j# S) O, h3 [4 t6 f, Ofile format: qcow24 G% W* X: p: Z  H6 R4 w: f$ {
virtual size: 30G (32212254720 bytes)
' `. S9 H+ c3 z9 @: C; Adisk size: 309M
. k3 e( L" K% rcluster_size: 65536
1 G. d! Q$ i' P7 G  AFormat specific information:
( [# ~( T) \& c) O    compat: 1.1" r7 @( `& m$ x' [' `
    lazy refcounts: false& |+ {& D3 c2 D: _$ R  ^  K
root@#
+ R" z' o/ R2 p. q2 r9 z
% A, s! f/ D5 l# {) O5 m4 r( A! ?5 I6 o5 z( ^( ^7 [) V
5、下面通过qemu-nbd挂载test_extend.img到/dev/nbd0设备上:0 t( K; x, l( x7 W: w
3 e' L9 x& c/ Y/ ?$ j# o4 p
root@   # qemu-nbd -c /dev/nbd0 ./test_extend.img
1 Z  H9 ]5 p5 `. Rroot@   # ll /dev/nbd* | grep nbd0
, u# @2 L3 a  j% I# [brw-rw---- 1 root disk 43,   0 11月 20 18:09 /dev/nbd0
! G. ^: t: c2 C1 {' Ibrw-rw---- 1 root disk 43,   1 11月 20 18:09 /dev/nbd0p1: j# x: _( K$ y6 X1 j) ?3 q* {8 x
root@cason:~/image#
; ^- k0 k9 T' P6 t3 i     挂载成功后,在/dev/下会看到如上信息,其中/dev/nbd0p1表示该虚拟磁盘仅有一个分区
6 U) |8 ^( A( |0 T  J0 S" B6 _1 K! f; ~% y9 r
6、下面开始通过fdisk来扩展虚拟磁盘分区大小:/ G3 O. c9 |7 o3 l# ]
* W/ o6 N! D7 {3 ~4 j/ I# L  _' c
复制代码
4 |% k& R# g& h: Zroot@# fdisk /dev/nbd0! z6 S9 w& p  i& a) O' Q

# v6 U2 X, m1 \$ ~* O7 k; o, X' wCommand (m for help): p
7 Z3 q! J9 G) Y7 J: |" ?1 Q; V4 ~& o" s
Disk /dev/nbd0: 32.2 GB, 32212254720 bytes
% A& ?% ?) |: m7 P  S255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
+ M; U. e8 S; V5 K% [Units = sectors of 1 * 512 = 512 bytes% l" t8 W& M' S/ I
Sector size (logical/physical): 512 bytes / 512 bytes1 ~3 r" C( i9 `0 s8 s9 n* O3 p
I/O size (minimum/optimal): 512 bytes / 512 bytes
1 E0 T/ H) U' J' Y) B/ @  I% WDisk identifier: 0x000e8e8d
: A# D# }9 w/ N- Y/ {3 y7 e/ H) B5 b) s
     Device Boot      Start         End      Blocks   Id  System& G' q, i' U8 q$ X1 l( I
/dev/nbd0p1   *        2048    41943039    20970496   83  Linux5 A  r3 D9 `; \$ T2 e
5 Q* F3 ]; J9 p* [: n+ X8 ?, c
Command (m for help): d
" D. E1 B( }& |% ?% l; P; y! I  Y) zSelected partition 1+ M  s' W; `% F, D5 Q

7 s& S% s! J0 Z# ^- o1 w. \' ]- P5 LCommand (m for help): p# r& I# o8 m( G9 ^) m8 j1 {
5 N1 w5 q) {/ R
Disk /dev/nbd0: 32.2 GB, 32212254720 bytes
6 r# l  F- ?, I, ]' |255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
0 A$ l. u& W- U6 l! j* [Units = sectors of 1 * 512 = 512 bytes
" ]3 c" e. c7 k- {  j# O9 VSector size (logical/physical): 512 bytes / 512 bytes. Q; p9 A% p; Y% d% ^2 s
I/O size (minimum/optimal): 512 bytes / 512 bytes
! M* V. Q& l, p0 a( KDisk identifier: 0x000e8e8d
: G0 ]" w3 v/ w$ Z
( s  X2 N. y; |7 E     Device Boot      Start         End      Blocks   Id  System# x2 k5 P6 a% ^1 K( \
4 X, U2 c* }5 ]! ~1 m" J
Command (m for help): n! A4 {# e; u- `/ t
Partition type:# @9 y0 F/ N$ u- q/ |
   p   primary (0 primary, 0 extended, 4 free)
1 P" Z& I" C; n3 o- T0 V   e   extended
$ K9 k8 G8 c$ Y# i1 `Select (default p): p3 }1 _8 }# `1 U' ^% |7 b: Z5 \
Partition number (1-4, default 1): / u6 R1 I- P8 [& E7 y$ n$ y* j
Using default value 1
4 P. ?3 ]9 H( Z# I+ U6 O! R8 L' ZFirst sector (2048-62914559, default 2048):
. t1 M/ t# O  P3 A0 tUsing default value 2048
, D- v+ s3 v# r: ^Last sector, +sectors or +size{K,M,G} (2048-62914559, default 62914559):
/ z: `" M! p+ |3 [& UUsing default value 62914559
5 K! Q9 l: V5 }* {+ D9 i% h) ^8 }
  F" u% @; t; m2 U& TCommand (m for help): p
% P  B4 |/ |7 e/ C7 d, [1 {$ ?0 [) ~* t' S% b+ m9 N2 |0 Y: o* \. [
Disk /dev/nbd0: 32.2 GB, 32212254720 bytes4 e6 M* r0 w( q. v
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
0 z( R/ P+ Z. l' l; n& d8 mUnits = sectors of 1 * 512 = 512 bytes
( `6 X+ x* M+ u; f9 b# r% ESector size (logical/physical): 512 bytes / 512 bytes
0 u3 g% i' d! k5 u' k: H" dI/O size (minimum/optimal): 512 bytes / 512 bytes* Q! d% }5 l- ?. s/ i$ v6 m* D
Disk identifier: 0x000e8e8d
1 B0 Q% `* \/ {8 i$ n/ @
. _. P" A3 q5 T9 e5 i7 F     Device Boot      Start         End      Blocks   Id  System3 ]! m8 }6 \  M& y2 O  Y
/dev/nbd0p1            2048    62914559    31456256   83  Linux' z6 g/ h3 I" P) R- A

- y" y- Q/ O( F4 r6 I( ?. ^Command (m for help): a2 o, e+ ~' w6 n9 m3 W
Partition number (1-4): 1
' E3 L4 S5 m$ N' u/ t
# F0 J: Q& @( ?7 SCommand (m for help): p
5 d; _5 y: I0 ]9 v5 \7 X
# a2 d2 q& o/ dDisk /dev/nbd0: 32.2 GB, 32212254720 bytes& V; t4 y+ p. H+ f' S9 h
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors$ O/ o1 x0 b  t- z" @! U
Units = sectors of 1 * 512 = 512 bytes
0 w4 J* W) a5 L# JSector size (logical/physical): 512 bytes / 512 bytes& |0 u2 d8 r$ C- G1 h& ?3 T, H
I/O size (minimum/optimal): 512 bytes / 512 bytes3 p0 n: h+ A  a9 c
Disk identifier: 0x000e8e8d
) h: r; n7 g6 v  [1 g1 m8 v5 q; ]" Y8 h
8 ~/ a0 m; N# z5 N* L     Device Boot      Start         End      Blocks   Id  System/ o9 y- ]; j4 g. k, a$ |
/dev/nbd0p1   *        2048    62914559    31456256   83  Linux
. p  j! i3 k* H" E. r- c# n' n. A4 k# E/ |; g
Command (m for help): w  W5 a; @& I1 K. r* H$ l
The partition table has been altered!
" J' D- J3 c- u; E8 T, J# V1 z4 Y2 V: c; {8 W! F
Calling ioctl() to re-read partition table.$ S# A1 }# |2 ?1 y) |0 _- ?
Syncing disks.
: N2 B! f* s3 L% q; `" C0 T/ ?root@#
7 s. @* c" a) ~. J' g  P9 ^% B复制代码
, c* ?: C/ t7 r. ~$ l3 c/ w9 X     如此以来,我们已经将该虚拟磁盘的分区大小扩展到了30G6 J2 M. a7 r1 }& @! M8 \/ n

! A: m% P/ I+ F# l, R7、至此,我们还需要将文件系统扩展到30G:& Z+ F* z5 z8 O! D/ n

$ H+ M1 p) j2 T$ n2 \- d复制代码5 v* x9 b& i+ N4 D# ^
root@# e2fsck -fp /dev/nbd0p1 ( B; E5 s1 |* l2 D  F
/dev/nbd0p1: Deleted inode 131076 has zero dtime.  FIXED.5 o0 l& g0 ?! f, `  F. I# D) ~) ]
/dev/nbd0p1: 18489/1310720 files (0.2% non-contiguous), 281286/5242624 blocks/ {1 y# v* A' k7 v9 D

8 S7 j, g; ?. N/ n* A* Iroot@# resize2fs /dev/nbd0p1
" ^9 B: O$ h1 k" M% K+ |. L1 Fresize2fs 1.42.9 (4-Feb-2014)
- z7 G' O- g3 |3 FResizing the filesystem on /dev/nbd0p1 to 7864064 (4k) blocks.
5 X9 Z( _1 ]5 M7 g% h* CThe filesystem on /dev/nbd0p1 is now 7864064 blocks long., `  t, L+ f9 a+ Q$ R

0 Y( S/ v, C2 [  R/ _/ [5 I' |! Iroot@# qemu-nbd -d /dev/nbd0
$ Y" G8 ~4 @& h) k3 v4 H/dev/nbd0 disconnected
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 02:46 , Processed in 0.022370 second(s), 26 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表