|
|
楼主 |
发表于 2022-9-29 10:12:14
|
显示全部楼层
[root@llf-uos-1 ~]# lvresize /dev/uniontechos/
- R- e2 J4 v6 R- u5 Q) w/dev/uniontechos/root /dev/uniontechos/swap 5 d& k2 {* f& A
[root@llf-uos-1 ~]# lvresize /dev/uniontechos/root 9 Q/ ]: q7 z% ]- X
No command with matching syntax recognised. Run 'lvresize --help' for more information.4 I U- k! d8 L; z5 O
[root@llf-uos-1 ~]# lvresize -f /dev/uniontechos/root 2 ^1 K1 S' h* H& i+ s* x
No command with matching syntax recognised. Run 'lvresize --help' for more information.1 D. M. F, s. A. x0 q$ S$ W" @
[root@llf-uos-1 ~]# lvresize -r -l +100%FREE /dev/uniontechos/root
3 J$ D. u- w. l% j. T1 ? Size of logical volume uniontechos/root unchanged from <2.95 GiB (754 extents).
8 Q) t/ b& P/ ]# U Logical volume uniontechos/root successfully resized.
" c$ O! v% }' y[root@llf-uos-1 ~]# lvextend -l +100%FREE /dev/uniontechos/root
# P0 v- T2 L0 {. A) E New size (754 extents) matches existing size (754 extents).+ O3 M! M/ S3 k
[root@llf-uos-1 ~]# xfs_growfs /9 T8 [ R/ `% M( F
meta-data=/dev/mapper/uniontechos-root isize=512 agcount=4, agsize=193024 blks
" x' x5 I% y9 s; d, | x = sectsz=512 attr=2, projid32bit=1
0 o$ f3 Q- b) `. E3 B- c = crc=1 finobt=1, sparse=1, rmapbt=0: Q+ h7 a$ i I
= reflink=1
* Q, l" F) d2 G" r: Qdata = bsize=4096 blocks=772096, imaxpct=25 k! y4 p1 a [' F5 E. J
= sunit=0 swidth=0 blks
, N e* l! `0 unaming =version 2 bsize=4096 ascii-ci=0, ftype=1
* G6 B+ \2 y1 c' B7 h6 qlog =internal log bsize=4096 blocks=2560, version=2
" F9 N- I6 K: _* p' ]$ G: h- K = sectsz=512 sunit=0 blks, lazy-count=1, d# e+ c4 O5 E3 g$ e
realtime =none extsz=4096 blocks=0, rtextents=04 [9 [4 S- C% U& ~, D! `
[root@llf-uos-1 ~]# lsblk 7 P* S: Y6 a" n2 r ]
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
7 q! u& `- @& C, |. \- q( U' v( vvda 252:0 0 50G 0 disk
6 ~. P! Y* S, k├─vda1 252:1 0 512M 0 part /boot
0 P& V6 D% L5 T1 k u% A├─vda2 252:2 0 1.3G 0 part /backup
0 `0 ]" a6 Y4 a! ?/ l└─vda3 252:3 0 48.2G 0 part 2 v% ~/ V+ @4 I& e! ]0 |
├─uniontechos-root 253:0 0 3G 0 lvm /" S( M( E! r7 J& j! j; S; B
└─uniontechos-swap 253:1 0 256M 0 lvm [SWAP]" B* A% @+ r/ u5 d4 C0 v" q) w2 e
[root@llf-uos-1 ~]# xfs_2 z$ }8 h z" L4 F8 I2 f( t) U
xfs_admin xfs_db xfs_fsr xfs_io xfs_metadump xfs_quota xfs_spaceman
- D$ p/ x: n/ n5 f+ V- W: o+ O$ S, yxfs_bmap xfs_estimate xfs_growfs xfs_logprint xfs_mkfile xfs_repair
: k/ V! n& `; Y; i1 M2 p% txfs_copy xfs_freeze xfs_info xfs_mdrestore xfs_ncheck xfs_rtcp ; ~8 h4 ]! O4 J
[root@llf-uos-1 ~]# xfs_growfs
% E: w! ?: z# `: K& Yanaconda-ks.cfg .bash_logout .bashrc .ssh/ .viminfo
! _# o8 M' c( t1 A0 J: }5 i3 L: Y.bash_history .bash_profile .cshrc .tcshrc
/ Z7 o( D0 U: s[root@llf-uos-1 ~]# xfs_growfs /dev/vda- m+ O$ o# m2 u& N6 {
vda vda1 vda2 vda3
e6 N) T: q: P6 r7 n% k3 j _[root@llf-uos-1 ~]# xfs_growfs /dev/vda
- z9 c& T D4 C$ W- zvda vda1 vda2 vda3 + p1 e3 `* T" l9 s0 D2 _8 O
[root@llf-uos-1 ~]# xfs_growfs /dev/vda3 , ^& d5 A. a+ v2 F% S
xfs_growfs: /dev/vda3 is not a mounted XFS filesystem! O- k5 I7 l i- [3 y( f- D6 B" ^
[root@llf-uos-1 ~]# growpart /dev/vda
; t6 \) y: ~" G" A6 m; S& P9 evda vda1 vda2 vda3
: c% D2 F1 l. N* W( L, Q" I" q. F[root@llf-uos-1 ~]# growpart /dev/vda' b* b+ d2 n4 y7 o
vda vda1 vda2 vda3
1 h1 v' V" @) K e* f+ q4 h( ~[root@llf-uos-1 ~]# growpart /dev/vda
: K0 L9 p3 h+ k! ]( ?# d& tvda vda1 vda2 vda3
, m1 ^: h! Z4 `: u; Q& B[root@llf-uos-1 ~]# growpart /dev/vda 3
5 d* s3 E4 ?3 U& A0 ENOCHANGE: partition 3 is size 101081055. it cannot be grown- |9 [, e9 h- [, o( }9 [
[root@llf-uos-1 ~]# growpart /dev/vda3+ r. u6 V+ {+ U
growpart disk partition
3 A1 d) L {" i2 g rewrite partition table so that partition takes up all the space it can& O- T. s8 S+ P1 L
options:) a6 j' g: x# y# D$ g
-h | --help print Usage and exit
! S! Z( B: h" S6 q- l+ a* y5 \3 M --fudge F if part could be resized, but change would be: @% R/ Z9 ^8 G% x% G1 k% i
less than 'F' bytes, do not resize (default: 1048576)1 I" e9 y5 Q; V6 }: P& A" e5 Q8 G$ f
-N | --dry-run only report what would be done, show new 'sfdisk -d'
/ m& E0 ^3 u2 M: W) B -v | --verbose increase verbosity / debug5 {7 o# `" k- S n% F
-u | --update R update the the kernel partition table info after growing$ t: G) V, y- o( o2 ]1 x
this requires kernel support and 'partx --update'
6 _" X7 o8 @: c R is one of:
* y* g" B& F* H. ?, S3 E+ I: B - 'auto' : [default] update partition if possible5 v" c) i( C0 N
- 'force' : try despite sanity checks (fail on failure)& d8 `/ J9 w% f! h3 P) t
- 'off' : do not attempt, R: i; k# ]5 m. T% |/ e
- 'on' : fail if sanity checks indicate no support
% h, U2 L& d( O: _+ P9 ^) @* {' q: a& F1 a3 C' z
Example:
! M; w, d4 w; \ - growpart /dev/sda 1- A3 v1 j& `+ \! n
Resize partition 1 on /dev/sda+ V9 ^$ r" e1 E4 F# ?5 ?3 E2 H
must supply partition-number
% R# `4 E! s1 D* e% G, T0 ~2 \[root@llf-uos-1 ~]# lvextend -l +100%FREE /dev/uniontechos/root6 V0 v# w& v4 P z
New size (754 extents) matches existing size (754 extents).
- L: V9 M: s/ t$ R$ R; i- J[root@llf-uos-1 ~]# lvresize -r -l +100%FREE /dev/uniontechos/root
3 c* t, Z1 e* V; F) h6 \ Size of logical volume uniontechos/root unchanged from <2.95 GiB (754 extents).6 e5 c7 f; g: I1 d& Y- y, b
Logical volume uniontechos/root successfully resized.2 N* n9 R5 W6 m8 u# w
[root@llf-uos-1 ~]# lvresize -r -l +100%FREE /dev/mapper/^C
- y+ j. M/ V0 S[root@llf-uos-1 ~]# ls /dev/m
' Z! l6 ~ \. h/ a1 [1 y) F! J3 l! Emapper/ mcelog mem memory_bandwidth mqueue/ 1 ^9 R# J* Y0 H' Q0 X
[root@llf-uos-1 ~]# ls /dev/mapper/
2 N6 }0 u1 O& r0 @control uniontechos-root uniontechos-swap 4 |. }2 O( C$ E: I, w
[root@llf-uos-1 ~]# ls /dev/mapper/
+ F U/ a3 l2 Q; h1 y2 ~1 ~control uniontechos-root uniontechos-swap
+ o* f3 |- _/ Y F: }9 _[root@llf-uos-1 ~]# ls /dev/mapper/uniontechos-root
b- |) G. Z. w7 Q: e/dev/mapper/uniontechos-root
- [* x) R1 n, G" m: l[root@llf-uos-1 ~]# lvextend -l +100%FREE /dev/mapper/uniontechos-root
o4 A) A- y D; |$ v4 m New size (754 extents) matches existing size (754 extents).% A( A7 a! `3 H) r3 e5 U/ @
[root@llf-uos-1 ~]# lvresize -r -l +100%FREE /dev/mapper/uniontechos-root
+ i K2 m' x( k2 v9 l, l% Q Size of logical volume uniontechos/root unchanged from <2.95 GiB (754 extents).
' _$ y' s7 L w" n Logical volume uniontechos/root successfully resized.
/ |+ ]; P! S) x i1 a3 P) l$ G[root@llf-uos-1 ~]# lsblk $ t) K& N2 A& t q0 y* k: j: M
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT$ Y1 I3 x+ u1 L& ^5 R& J
vda 252:0 0 50G 0 disk 4 ~) W' U4 |5 i2 M7 V7 i2 b; i- k
├─vda1 252:1 0 512M 0 part /boot6 |0 z8 c$ F) j9 N, b
├─vda2 252:2 0 1.3G 0 part /backup
& M, ^! Q. y( `, l3 O: w└─vda3 252:3 0 48.2G 0 part / J) ^! o" P( X. R1 R0 |
├─uniontechos-root 253:0 0 3G 0 lvm /
+ O! x- f1 P) n E& [ └─uniontechos-swap 253:1 0 256M 0 lvm [SWAP]" [ Z: l5 @% l/ `' N7 l9 Q2 [
[root@llf-uos-1 ~]# df -Th5 }1 S3 _. j0 s! e- Y/ R c: q8 I
Filesystem Type Size Used Avail Use% Mounted on
" H0 ?* S# p7 {6 o/ Edevtmpfs devtmpfs 3.8G 0 3.8G 0% /dev7 i# q2 Q _$ i8 _# E
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
, G* T1 v6 I3 W9 U8 [tmpfs tmpfs 3.9G 17M 3.8G 1% /run& A( x- ?7 y4 _/ |, c
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
& I! s: ~( S6 s, p( j9 t3 K/dev/mapper/uniontechos-root xfs 3.0G 1.8G 1.2G 61% /3 D* K1 a3 |3 }+ L
/dev/vda2 xfs 1.3G 1.2G 148M 89% /backup
& l: L7 {: B6 @" A. R/dev/vda1 xfs 507M 266M 242M 53% /boot
6 A$ W" X* \7 x Ztmpfs tmpfs 782M 0 782M 0% /run/user/06 r7 t8 G4 G$ v5 o0 ?
[root@llf-uos-1 ~]# xfs_growfs /
$ j4 U c+ H2 h/ Q {: v( i1 Hmeta-data=/dev/mapper/uniontechos-root isize=512 agcount=4, agsize=193024 blks
$ P/ r* s0 Z, `5 A. n = sectsz=512 attr=2, projid32bit=1
+ Y' ~; @' }0 o$ y" i3 w = crc=1 finobt=1, sparse=1, rmapbt=0
6 p, G' N. R4 i1 g+ ~1 n3 a = reflink=1
! G9 ~% x4 x' c, Gdata = bsize=4096 blocks=772096, imaxpct=25
, t+ c; R, `& D0 K = sunit=0 swidth=0 blks
2 U5 J5 o* P, s6 P, v# h _naming =version 2 bsize=4096 ascii-ci=0, ftype=1
/ p2 h5 k. w- Q) A& c( olog =internal log bsize=4096 blocks=2560, version=2/ d$ z x, J* R" E8 o8 W/ A, r' W
= sectsz=512 sunit=0 blks, lazy-count=1# p% S# F% Y0 [
realtime =none extsz=4096 blocks=0, rtextents=0
+ I& f: g: B- @% h4 s[root@llf-uos-1 ~]# xfs_growfs /dev/mapper/uniontechos-root
: W% p1 C$ U/ e+ [$ r1 i9 Dmeta-data=/dev/mapper/uniontechos-root isize=512 agcount=4, agsize=193024 blks
& N f! K/ i. Q: r = sectsz=512 attr=2, projid32bit=1, B& c6 U K6 V
= crc=1 finobt=1, sparse=1, rmapbt=0
# P, n( M3 O, s: H4 R5 I8 A; f = reflink=1
: {4 M7 V2 a- A4 u$ ?) Kdata = bsize=4096 blocks=772096, imaxpct=25, [2 b- x+ x$ u7 E7 p3 ? Z
= sunit=0 swidth=0 blks4 N5 `6 f' K. M; D: \
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
% f5 Y, _* E mlog =internal log bsize=4096 blocks=2560, version=2
$ q( e6 N: @. ]1 {! y W- z9 ] = sectsz=512 sunit=0 blks, lazy-count=1& V- N- Q$ i* P, R
realtime =none extsz=4096 blocks=0, rtextents=0
3 v( w& m8 {& n3 F U6 O) e[root@llf-uos-1 ~]# df -Th `7 i' n3 W, |; B: @8 m i
Filesystem Type Size Used Avail Use% Mounted on# A/ L) S0 n1 B+ H* i
devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev2 f+ d9 ~& A$ {) T
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm" v) X A9 A4 X& ]
tmpfs tmpfs 3.9G 17M 3.8G 1% /run, f6 B5 a0 i, |
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
7 f, ~8 O D) {$ ?/dev/mapper/uniontechos-root xfs 3.0G 1.8G 1.2G 61% /
. m/ i G) X' \) M8 ]0 K$ h/dev/vda2 xfs 1.3G 1.2G 148M 89% /backup+ @; F N/ H) l! E: A
/dev/vda1 xfs 507M 266M 242M 53% /boot
* A8 ^- T& J* V6 r4 |; ]tmpfs tmpfs 782M 0 782M 0% /run/user/0& y. k7 M( B5 [5 b) [# V
[root@llf-uos-1 ~]# ls
) {$ f" G4 ]3 f! v' k+ \1 Canaconda-ks.cfg* A# ]- Q, w( I; i% |0 J
[root@llf-uos-1 ~]# cd /var/l8 v; L: x0 O+ r. O- K }0 N
lib/ local/ lock/ log/ & L4 I/ ]# S; ^) H5 W$ @# H
[root@llf-uos-1 ~]# cd /etc/cloud/
4 o4 K6 P5 d! T) Z3 R" z[root@llf-uos-1 cloud]# ls
" t) E3 h; T' q" O9 Acloud.cfg cloud.cfg.d extend_root_fs templates
: K- e! g0 p8 f8 U[root@llf-uos-1 cloud]# vim cloud.cfg
+ |8 z/ }% C- ?0 b3 g1 G[root@llf-uos-1 cloud]# ls$ p" A2 _& V; x) A! L
cloud.cfg cloud.cfg.d extend_root_fs templates3 p, }0 A" N4 c( I# V" q
[root@llf-uos-1 cloud]# cat extend_root_fs
6 H- Z& M' { J; y#!/bin/bash' }* x `4 d7 r7 s2 H7 C. K4 ^
###get / disk tag value+ x9 c( K" c6 v, V# t
#tag=`(lsblk -nl |grep / |grep part|awk '{print $2}' |awk -F ":" '{print $2}')`5 z% N* [) s2 w; l4 R# T
tag=`(lsblk -nl |grep part |awk "NR==3" |awk '{print $2}' |awk -F ":" '{print $2}')`: I2 s* m! Y/ e2 S9 M
##get block tag
% Q+ k5 K; p1 f7 o$ Oblock=`(lsblk -nl |grep disk | awk '{print $1}')`3 g1 F+ {: g: r! {
##grow disk size6 I) }7 [. j- r( M
growpart /dev/$block $tag
, k9 P: _! r E###xfs file system grow! G2 F) ~ I; ~2 z$ Q/ r/ k
lvextend -l +100%FREE /dev/uniontechos/root/ }/ B: }1 g: k3 ]8 K* B2 y0 `
2 ^! y9 n, a. } o w7 X- Cxfs_growfs /
; Z7 C. {; U' O0 F" \$ r" } z5 {
break;
" i! f$ f) f4 H3 V' i0 J" J" D+ jexit 0;
C( T: g% E) w; y* a2 R; d$ z( ]7 L5 S! r x. U7 O& x& W
[root@llf-uos-1 cloud]# xfs_growfs 5 `4 w- N# g! L; W7 `5 h% z0 Y
Usage: xfs_growfs [options] mountpoint1 H5 h# J# I3 B3 U3 P
# [& |$ s1 x1 lOptions:- D* x, w% ^, R; Y. Y
-d grow data/metadata section
, Q" {1 p3 p. \: E -l grow log section: k4 t. [1 m2 I J4 @, D* Y% I7 X) K
-r grow realtime section# F- T- C+ ]# G$ R
-n don't change anything, just show geometry
+ t% i$ }( P$ p2 y6 P -i convert log from external to internal format
) k8 g4 V. {1 v2 w5 B3 P -t alternate location for mount table (/etc/mtab)
+ f+ y7 C' i5 \3 C -x convert log from internal to external format
0 G$ Y E$ k* l% I* E -D size grow data/metadata section to size blks
9 p9 u3 s) S2 q0 N -L size grow/shrink log section to size blks
9 c8 i5 o1 B# V7 @3 y -R size grow realtime section to size blks
- o% p* v( x3 Z4 f -e size set realtime extent size to size blks! L3 Y$ n* @( @1 r
-m imaxpct set inode max percent to imaxpct
, e. |1 W9 O4 x$ A: t! k" G& z- {. i -V print version information3 N$ ]0 _0 h1 p* C' A) p
[root@llf-uos-1 cloud]# xfs_growfs -i /dev/vda t, R. W+ i4 g# d/ N: @) |
vda vda1 vda2 vda3 1 c6 X ?7 q. V0 N
[root@llf-uos-1 cloud]# xfs_growfs -i /dev/vda4 }5 s1 _) b3 T* F0 v
vda vda1 vda2 vda3
5 P+ o$ t; @0 b) D' {# v[root@llf-uos-1 cloud]# xfs_growfs -i /dev/vda3
4 r9 G$ `1 Q( }: `" O5 p5 bxfs_growfs: /dev/vda3 is not a mounted XFS filesystem& h6 {# v( t5 Z& r9 d1 s2 B. L
[root@llf-uos-1 cloud]# xfs_growfs -r /, e, q* g- w9 r4 M; d5 |0 C; S
xfs_growfs: failed to access realtime device for /
+ d9 O0 z9 X1 q[root@llf-uos-1 cloud]# xfs_growfs -d /4 J. t E7 ~1 q! H2 k/ o& ^
meta-data=/dev/mapper/uniontechos-root isize=512 agcount=4, agsize=193024 blks
6 E$ l0 k( w% H- [# c7 I7 x = sectsz=512 attr=2, projid32bit=1" F+ R/ w+ L$ ]* N" \- S2 j7 \9 G
= crc=1 finobt=1, sparse=1, rmapbt=0- @& Y/ j3 \. I1 ?% l9 R6 m3 |
= reflink=1
8 T! o# n: w; sdata = bsize=4096 blocks=772096, imaxpct=25
, ^0 P5 N% L0 W/ H& t# z9 A = sunit=0 swidth=0 blks: e% u/ N; x: r8 D, K+ q
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
1 C3 l' h: @3 X, g* ^log =internal log bsize=4096 blocks=2560, version=2
{" g6 a8 ^) z6 E& j6 h = sectsz=512 sunit=0 blks, lazy-count=1
. T; I6 f6 v. L% l3 S4 Lrealtime =none extsz=4096 blocks=0, rtextents=0
: }4 v9 W7 ~3 b) F" ^- n1 Mdata size unchanged, skipping
, P* n, {; ~+ ]# d9 z4 J[root@llf-uos-1 cloud]# df -Th, d" p! l. `: V$ H+ r! h% e
Filesystem Type Size Used Avail Use% Mounted on
, @" k$ T) k! r# h" X$ }devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev
) T. S7 D6 c/ n4 Atmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm* S7 w0 n1 w, B* ~% ~
tmpfs tmpfs 3.9G 17M 3.8G 1% /run
& i* X# _1 Q; @, w! F" q# Ztmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
1 i# u1 v5 R& i/dev/mapper/uniontechos-root xfs 3.0G 1.8G 1.2G 61% /
& g) l& P% r9 a* v1 d7 y/dev/vda2 xfs 1.3G 1.2G 148M 89% /backup
8 W m9 |6 O+ x/ I4 J$ r/dev/vda1 xfs 507M 266M 242M 53% /boot+ b8 a' V2 X" c
tmpfs tmpfs 782M 0 782M 0% /run/user/0
; Q6 e. S+ z6 n6 S2 ]+ m# p[root@llf-uos-1 cloud]# lsblk
" ?4 I1 n* m9 \: r8 g/ u+ J3 V2 }$ BNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
0 Y5 J3 ?: T$ R$ _; G4 ?4 f# mvda 252:0 0 50G 0 disk ; b4 X! @, U/ `! k
├─vda1 252:1 0 512M 0 part /boot$ h |6 ?9 k" ~; p) e" A
├─vda2 252:2 0 1.3G 0 part /backup
9 c0 m2 C* x* T8 N└─vda3 252:3 0 48.2G 0 part
# c# U1 o" ]# v6 X. r6 G9 x1 f' a& z ├─uniontechos-root 253:0 0 3G 0 lvm /% C; Q/ U+ U6 E2 c/ k
└─uniontechos-swap 253:1 0 256M 0 lvm [SWAP] |
|