|
|
楼主 |
发表于 2022-9-29 10:12:14
|
显示全部楼层
[root@llf-uos-1 ~]# lvresize /dev/uniontechos/
& i( Y$ w6 `# C9 u/dev/uniontechos/root /dev/uniontechos/swap % {' X5 A" B' G' R
[root@llf-uos-1 ~]# lvresize /dev/uniontechos/root ! _ ^6 O) y& Y
No command with matching syntax recognised. Run 'lvresize --help' for more information.
5 l7 j o# G7 T3 Q- v/ l3 _[root@llf-uos-1 ~]# lvresize -f /dev/uniontechos/root , x9 |: u) A% D( B! i i
No command with matching syntax recognised. Run 'lvresize --help' for more information.
( Q7 W5 G& G* b0 Z( W[root@llf-uos-1 ~]# lvresize -r -l +100%FREE /dev/uniontechos/root , V6 D4 I. V9 W/ b" o/ t$ `
Size of logical volume uniontechos/root unchanged from <2.95 GiB (754 extents)., s |( a2 q) Y8 K5 B
Logical volume uniontechos/root successfully resized.
3 n- j$ S; F- g3 x[root@llf-uos-1 ~]# lvextend -l +100%FREE /dev/uniontechos/root
* V. C8 E5 ~( I% I# y New size (754 extents) matches existing size (754 extents).4 j9 G7 L0 h' r% z& W# r) W
[root@llf-uos-1 ~]# xfs_growfs // N u! ~# a! B6 N' M
meta-data=/dev/mapper/uniontechos-root isize=512 agcount=4, agsize=193024 blks1 U/ o8 m: m$ Q1 W0 g
= sectsz=512 attr=2, projid32bit=18 d& A, x0 [ }- e
= crc=1 finobt=1, sparse=1, rmapbt=0
/ y* B5 T; Y7 D: B) d = reflink=1* I4 d' \" S+ _: e
data = bsize=4096 blocks=772096, imaxpct=250 Q2 l% m8 C* s* T/ `' z6 R1 u4 i4 v6 B) f
= sunit=0 swidth=0 blks2 P1 ]+ I: t8 P, s1 e
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
+ J) e) C i8 c/ \1 B, P1 P" Y6 z% llog =internal log bsize=4096 blocks=2560, version=22 l# W8 D& x5 U# T% ^
= sectsz=512 sunit=0 blks, lazy-count=17 u; s: Q& e% H9 C* O$ v/ e
realtime =none extsz=4096 blocks=0, rtextents=0
9 }1 u- l1 e% a" |/ Z; @( \# Q" V[root@llf-uos-1 ~]# lsblk
( j) d/ i8 o) ?3 b0 e8 [NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT; G( }' U% ^ l
vda 252:0 0 50G 0 disk
1 I- _! F+ i1 P+ C├─vda1 252:1 0 512M 0 part /boot
* m2 y- ?9 _) |, j. {! C├─vda2 252:2 0 1.3G 0 part /backup6 b# @) D( w+ s* e
└─vda3 252:3 0 48.2G 0 part
) F/ A( l0 {6 d5 N ├─uniontechos-root 253:0 0 3G 0 lvm /+ y O6 x( e% q; Q- ~ W
└─uniontechos-swap 253:1 0 256M 0 lvm [SWAP]# ^5 r/ I3 d8 ]* n0 h" X8 Z
[root@llf-uos-1 ~]# xfs_
, {+ P7 O" r: }, e) [0 i. X# qxfs_admin xfs_db xfs_fsr xfs_io xfs_metadump xfs_quota xfs_spaceman* W6 @) y" o( W/ C" U) k! I0 ?
xfs_bmap xfs_estimate xfs_growfs xfs_logprint xfs_mkfile xfs_repair
8 ^ o; [0 J- U/ Bxfs_copy xfs_freeze xfs_info xfs_mdrestore xfs_ncheck xfs_rtcp
5 f2 ?0 d5 L# Q6 _- }% o) x9 L[root@llf-uos-1 ~]# xfs_growfs
& i9 X/ q+ k# [! m b$ I0 V4 |anaconda-ks.cfg .bash_logout .bashrc .ssh/ .viminfo
- P& s7 o4 V; l( X$ q$ I: h9 N4 j.bash_history .bash_profile .cshrc .tcshrc
+ _2 a J1 ^( b. M$ u5 T5 g% I# O[root@llf-uos-1 ~]# xfs_growfs /dev/vda. y1 {( q) A# B1 n
vda vda1 vda2 vda3 6 Q! X- O0 p, x- P$ q% _6 B
[root@llf-uos-1 ~]# xfs_growfs /dev/vda
" z* V9 [8 y1 ^, ]. F4 svda vda1 vda2 vda3
" e' _7 A4 P m- {# T; t& F, Z! A[root@llf-uos-1 ~]# xfs_growfs /dev/vda3 # n" t; G- S n ^3 m* K! c
xfs_growfs: /dev/vda3 is not a mounted XFS filesystem5 u: C& U4 }. P( w, b
[root@llf-uos-1 ~]# growpart /dev/vda
+ w M" R% v8 z Kvda vda1 vda2 vda3
% Q. ?/ Y1 O1 v& R! i' D[root@llf-uos-1 ~]# growpart /dev/vda- G7 _8 y* ]$ Y w; ^- c
vda vda1 vda2 vda3
! ?( O6 w' {5 ?[root@llf-uos-1 ~]# growpart /dev/vda
! N! G( k+ r, [' t& zvda vda1 vda2 vda3 8 j2 i( j$ O4 i' r; U+ p3 V
[root@llf-uos-1 ~]# growpart /dev/vda 37 Z& w) ~2 l1 f3 i) R7 Z6 Z# h" t
NOCHANGE: partition 3 is size 101081055. it cannot be grown- o( I5 Y y7 R1 b" _: m7 f
[root@llf-uos-1 ~]# growpart /dev/vda3: w# A, q& ~. X3 W
growpart disk partition
2 _! ^ U' l; Q' E8 k' B% I/ G rewrite partition table so that partition takes up all the space it can. h; W3 A) L2 |" C& B. i
options:5 `% s0 `6 `4 h* w+ I+ ?4 v5 P
-h | --help print Usage and exit2 \1 L F4 s- ^7 S
--fudge F if part could be resized, but change would be
2 F* D% Y' }0 B' s5 j( ~" } less than 'F' bytes, do not resize (default: 1048576)
" [; b& L6 h9 j2 I9 C3 ? -N | --dry-run only report what would be done, show new 'sfdisk -d'
6 w1 V, h# N" p' _- n4 ` -v | --verbose increase verbosity / debug
! P' n8 I5 Z8 f -u | --update R update the the kernel partition table info after growing
# D2 X- {, d2 f- D; S this requires kernel support and 'partx --update'1 g% W" S# G0 K; x
R is one of:9 n1 @& @2 A1 {, }+ z A
- 'auto' : [default] update partition if possible* @6 g0 g! G u* L! i
- 'force' : try despite sanity checks (fail on failure)
0 ]3 X# x$ z0 X5 r- d5 X - 'off' : do not attempt
7 y0 I4 E; }1 L/ X; M- _: m! N - 'on' : fail if sanity checks indicate no support& X. F1 N" [! B" q5 O
6 V, K6 Z9 V# f$ L _( {: L/ H" A Example:
' a7 M, U7 R% i/ \ - growpart /dev/sda 1
+ @; \0 z# u& m5 t Resize partition 1 on /dev/sda1 _; S. r: s/ ~; x8 B
must supply partition-number
/ `% e# \; y0 r' M% I$ |- \[root@llf-uos-1 ~]# lvextend -l +100%FREE /dev/uniontechos/root
3 C: n1 H+ s1 P4 C& O! z New size (754 extents) matches existing size (754 extents).1 h0 j( j- v* Y7 E9 n x: v
[root@llf-uos-1 ~]# lvresize -r -l +100%FREE /dev/uniontechos/root * [/ N% n) q! O8 b
Size of logical volume uniontechos/root unchanged from <2.95 GiB (754 extents).7 e' o) g; J& e
Logical volume uniontechos/root successfully resized.
4 M. a8 N, \7 d' J: v1 @[root@llf-uos-1 ~]# lvresize -r -l +100%FREE /dev/mapper/^C
U/ W1 d' y. a% Z3 e6 V[root@llf-uos-1 ~]# ls /dev/m
0 Q4 ^9 ~) d: x# B. xmapper/ mcelog mem memory_bandwidth mqueue/ ) G2 Z" R6 {! `2 v1 Y
[root@llf-uos-1 ~]# ls /dev/mapper/
7 G1 V7 Z; ]2 {- r* n! q% k7 \control uniontechos-root uniontechos-swap ) A( w8 e6 G4 u7 d+ Z( _
[root@llf-uos-1 ~]# ls /dev/mapper/
/ @) J- ^ D" X* V7 z4 ^control uniontechos-root uniontechos-swap 5 h' i; I9 \' V9 \+ t4 i- L' F
[root@llf-uos-1 ~]# ls /dev/mapper/uniontechos-root
v3 o. Y. q, z# {4 @$ g& V# `/dev/mapper/uniontechos-root1 Q a0 U3 h) ^% s' H/ k
[root@llf-uos-1 ~]# lvextend -l +100%FREE /dev/mapper/uniontechos-root3 [: o& Z( J; w- d: L! R
New size (754 extents) matches existing size (754 extents).; g% t# i" ]& g, W G h5 R
[root@llf-uos-1 ~]# lvresize -r -l +100%FREE /dev/mapper/uniontechos-root/ M4 m$ w: |4 n/ Q0 n
Size of logical volume uniontechos/root unchanged from <2.95 GiB (754 extents).
" A! W2 W. z9 L1 n" {7 `. ~9 o7 ? Logical volume uniontechos/root successfully resized.% P9 G: o. f/ S4 f) S _( R# [
[root@llf-uos-1 ~]# lsblk 4 H" K* ?- h8 z3 u* a5 Z( c
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
1 f: `" k$ I; H) }3 u7 u+ O+ Ovda 252:0 0 50G 0 disk 7 L7 P% L& M8 _5 g! c6 g* w+ t( I0 u
├─vda1 252:1 0 512M 0 part /boot" |3 T. V, w0 W7 }. S3 r
├─vda2 252:2 0 1.3G 0 part /backup
# R: L+ h# ~$ y6 S% a' Y. Y8 X└─vda3 252:3 0 48.2G 0 part % w: t& Y- x* W8 U9 p3 A9 u
├─uniontechos-root 253:0 0 3G 0 lvm /
7 P# |3 u K( n └─uniontechos-swap 253:1 0 256M 0 lvm [SWAP]
. |5 I8 ?; Q# O( ][root@llf-uos-1 ~]# df -Th2 L; T2 m; l4 U# Y: _6 Z
Filesystem Type Size Used Avail Use% Mounted on
4 `; M. `1 n6 h7 |3 M0 d5 s- i- Sdevtmpfs devtmpfs 3.8G 0 3.8G 0% /dev. X. H4 E; A2 j5 A# f% J/ v& c' `
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
' R# d9 w! h* _" k* Dtmpfs tmpfs 3.9G 17M 3.8G 1% /run- p$ m+ ]& v) v
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup2 V' L0 @% B* B6 R! \6 `- o
/dev/mapper/uniontechos-root xfs 3.0G 1.8G 1.2G 61% /; M9 }: T5 ?! O" ? y
/dev/vda2 xfs 1.3G 1.2G 148M 89% /backup
% t$ c( J) R: m( \8 W0 n9 X/dev/vda1 xfs 507M 266M 242M 53% /boot
9 Y% K8 R x5 X6 n0 w* P. S7 }tmpfs tmpfs 782M 0 782M 0% /run/user/0
. g- p$ X% U4 O9 D[root@llf-uos-1 ~]# xfs_growfs /) z# ]2 K s: M/ n7 z. Q2 V3 [
meta-data=/dev/mapper/uniontechos-root isize=512 agcount=4, agsize=193024 blks
# H" p R0 {2 } `- z1 T = sectsz=512 attr=2, projid32bit=1 i% c; a& E5 P6 D8 p$ ]
= crc=1 finobt=1, sparse=1, rmapbt=0
! W8 c" A7 _6 S8 Y5 E5 p5 F9 D5 P = reflink=1( \9 {; N: X6 v8 X" M
data = bsize=4096 blocks=772096, imaxpct=25% ~; `, c3 X+ g9 s" N6 h
= sunit=0 swidth=0 blks5 W8 G( R6 w1 b, }; x0 G
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
+ E3 z: s* a9 M; flog =internal log bsize=4096 blocks=2560, version=2
3 Z0 a% V! ] B5 x+ y$ l x( I = sectsz=512 sunit=0 blks, lazy-count=1+ U8 R+ O3 Y+ g! d0 _1 r
realtime =none extsz=4096 blocks=0, rtextents=00 V& x! Q% c! z( U5 {
[root@llf-uos-1 ~]# xfs_growfs /dev/mapper/uniontechos-root
7 [" F3 ^" [+ e% D# V7 c2 Kmeta-data=/dev/mapper/uniontechos-root isize=512 agcount=4, agsize=193024 blks% P6 b# a) e7 l. t& d
= sectsz=512 attr=2, projid32bit=1 ]) _* B, M' U3 X/ k2 U6 N- B8 v
= crc=1 finobt=1, sparse=1, rmapbt=06 N8 z- s+ X" |4 h4 w4 h
= reflink=19 }7 l5 O H& @, s2 G, }6 B }: U
data = bsize=4096 blocks=772096, imaxpct=25
; C( a8 O( M }, T1 M = sunit=0 swidth=0 blks: `2 g; P1 @/ {; L5 H0 B
naming =version 2 bsize=4096 ascii-ci=0, ftype=1+ v% `' n" s9 i$ @# R
log =internal log bsize=4096 blocks=2560, version=2. n$ c2 F5 Y6 y3 P$ B- F
= sectsz=512 sunit=0 blks, lazy-count=1
5 j. `( j( j+ f! p0 L4 L. f/ hrealtime =none extsz=4096 blocks=0, rtextents=0
) L/ I) m* u. s( E[root@llf-uos-1 ~]# df -Th( P! p( d( t4 M i3 f4 ?9 i( ~
Filesystem Type Size Used Avail Use% Mounted on+ q/ q @8 A- y3 u& [) F; p/ a
devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev P! F# D- }, ~9 `/ H
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm) b8 T, s+ p4 |, J' a) g
tmpfs tmpfs 3.9G 17M 3.8G 1% /run
% ]6 {# E0 f! d3 P8 T# R7 rtmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
7 z. o8 r% }3 z' L) s/dev/mapper/uniontechos-root xfs 3.0G 1.8G 1.2G 61% /
. o- @6 X# e+ K7 v, d! G; k; G/dev/vda2 xfs 1.3G 1.2G 148M 89% /backup
$ ~% F2 g, Q# L4 t3 O( N/dev/vda1 xfs 507M 266M 242M 53% /boot
5 _ c8 v; D. H4 H# J" X# Htmpfs tmpfs 782M 0 782M 0% /run/user/0
' \$ [; m# j: G# t7 c* E: g& ][root@llf-uos-1 ~]# ls
" k, m' Z3 }( Z0 _% `0 Eanaconda-ks.cfg: a+ T) x/ e. Y) X; c" ~9 q5 c
[root@llf-uos-1 ~]# cd /var/l3 \$ f6 D; M- b+ S
lib/ local/ lock/ log/
- Q. B7 D# E% x[root@llf-uos-1 ~]# cd /etc/cloud/
/ y4 h* h! K3 \% h* [[root@llf-uos-1 cloud]# ls9 [2 h6 a3 s, E" u* \8 M6 r
cloud.cfg cloud.cfg.d extend_root_fs templates1 t. C. |( Y- ]6 x) }" f- l5 w/ G
[root@llf-uos-1 cloud]# vim cloud.cfg. ^3 K0 M" p h3 ]+ {9 J/ a
[root@llf-uos-1 cloud]# ls/ {7 d1 z0 U* c) O$ Z. [0 E# B+ d
cloud.cfg cloud.cfg.d extend_root_fs templates4 r8 C0 m9 }* ]6 B) J
[root@llf-uos-1 cloud]# cat extend_root_fs
0 {% u, b9 r8 k8 y7 d, \8 h#!/bin/bash8 [2 S. p1 h( m1 j
###get / disk tag value
D3 X _) O' T) C8 o#tag=`(lsblk -nl |grep / |grep part|awk '{print $2}' |awk -F ":" '{print $2}')`
5 x) q) j3 `# \1 A ntag=`(lsblk -nl |grep part |awk "NR==3" |awk '{print $2}' |awk -F ":" '{print $2}')`0 u* S! `3 f+ w( V a" L+ G
##get block tag
9 u$ K1 A( }# C2 b* tblock=`(lsblk -nl |grep disk | awk '{print $1}')`- I6 m. x1 {; ]
##grow disk size# M2 w* w9 a, w
growpart /dev/$block $tag
* [7 B" p4 k+ y# y1 Q7 n2 g3 t$ T###xfs file system grow
% C) o) @3 [; ]+ g8 ~! F9 ^lvextend -l +100%FREE /dev/uniontechos/root
Q* d8 y+ \- V1 ?, {: ]( [
7 p0 `* @, W$ O( V# y4 }xfs_growfs /
3 _( f1 H9 y b$ w& r* h; D7 f
. I K$ k7 k* Q1 \( t8 H# c: E& lbreak;
- {2 N9 J6 Q* V4 I) W0 Xexit 0;
. S, [9 H# m. g& H! W7 f+ x. ~
- T( ^# m, \. {3 \[root@llf-uos-1 cloud]# xfs_growfs $ N+ ?( Q- N6 Z# D
Usage: xfs_growfs [options] mountpoint: x, B4 b0 E9 @) ], |2 U" ]
! F' z& y) v) i6 d, k
Options:: k" p3 M6 y2 P+ J* @, M& v; k* U* N6 ?
-d grow data/metadata section
: N* [& w' ~; W3 W -l grow log section
. m" X2 T; h7 p2 t. ] -r grow realtime section
; K5 E5 D& g" g# h! j. h -n don't change anything, just show geometry% v2 r9 z" n/ A4 p' Y# `
-i convert log from external to internal format
2 ]% k7 v- h: @- J; Y6 v5 W; D -t alternate location for mount table (/etc/mtab)& q) ~* @: }( n
-x convert log from internal to external format' P- l9 O+ d' n3 V* L u
-D size grow data/metadata section to size blks- o' j& _$ A, U6 s. G$ C# X
-L size grow/shrink log section to size blks( Y" u$ Z& x# `) d# G& ~; _
-R size grow realtime section to size blks
F$ f" d" k' o2 e- _# y, n% q -e size set realtime extent size to size blks5 R$ t5 Z8 N$ P: i W8 q/ M. w$ D
-m imaxpct set inode max percent to imaxpct
& U4 |& R% ]) ~+ s- } -V print version information4 A& H8 R/ `- @$ {9 }
[root@llf-uos-1 cloud]# xfs_growfs -i /dev/vda$ F7 _. m- ? L! Z9 i
vda vda1 vda2 vda3 8 M' S5 ?$ K! m) U6 ~
[root@llf-uos-1 cloud]# xfs_growfs -i /dev/vda, q/ i% ^3 _5 T: H7 [+ f: q$ H
vda vda1 vda2 vda3
& e- i' c4 x% ?1 C+ s. c[root@llf-uos-1 cloud]# xfs_growfs -i /dev/vda3
( V0 |9 G' i( B- Rxfs_growfs: /dev/vda3 is not a mounted XFS filesystem. G' q5 ^% [4 [) r
[root@llf-uos-1 cloud]# xfs_growfs -r /; v$ }6 @* [+ P# o: t# \2 X
xfs_growfs: failed to access realtime device for /
4 P. }9 n! o) f5 M# O7 W# A, t9 E[root@llf-uos-1 cloud]# xfs_growfs -d /
/ f& ?/ k' |1 C; s- p0 xmeta-data=/dev/mapper/uniontechos-root isize=512 agcount=4, agsize=193024 blks
7 ?* p& r' ?* k# ^5 D4 d4 S = sectsz=512 attr=2, projid32bit=10 r" K" a# `7 C- C
= crc=1 finobt=1, sparse=1, rmapbt=02 E" ]- R3 a8 D/ [
= reflink=10 J" J- U/ l: h+ u J; b2 c7 v
data = bsize=4096 blocks=772096, imaxpct=25
, o+ Q4 J) R7 D/ Y! G5 N4 E = sunit=0 swidth=0 blks
* ?1 N/ _+ Y$ N z& u, P6 @& \1 dnaming =version 2 bsize=4096 ascii-ci=0, ftype=15 `5 P7 _3 R) N+ i! Y
log =internal log bsize=4096 blocks=2560, version=2! h5 B& D; J! h
= sectsz=512 sunit=0 blks, lazy-count=1
( b' J. T6 \# c2 s1 Z' Frealtime =none extsz=4096 blocks=0, rtextents=0! [' k4 }/ U0 b$ C# _
data size unchanged, skipping! C0 H: R4 Z( L* |- A# @1 d
[root@llf-uos-1 cloud]# df -Th
0 R. t0 w# b4 y/ c4 `1 s. OFilesystem Type Size Used Avail Use% Mounted on% \& `0 J2 S- C2 f# ?
devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev0 z1 X5 X8 W: r2 x; ]4 z
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
! @7 C3 v: s. w8 V* K9 `+ A" |, vtmpfs tmpfs 3.9G 17M 3.8G 1% /run, w0 w7 W9 a2 S u9 S$ u+ q
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
# A4 Z- D- l8 C- J/ Q5 i9 M/dev/mapper/uniontechos-root xfs 3.0G 1.8G 1.2G 61% /7 O, k( ]* p5 m% f& |
/dev/vda2 xfs 1.3G 1.2G 148M 89% /backup
4 f, c& ~% O1 p; a1 D( B/dev/vda1 xfs 507M 266M 242M 53% /boot( s6 D4 @- U% B0 b, U/ C, ~) c' ]
tmpfs tmpfs 782M 0 782M 0% /run/user/0
4 L0 `' D; H. M" E# @4 m[root@llf-uos-1 cloud]# lsblk
* j+ u" _* @9 ~- L3 [NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT, w% f! I9 r8 ]8 a4 Q
vda 252:0 0 50G 0 disk
4 {( C; U& c+ z5 y. E( g- |* N+ z% W├─vda1 252:1 0 512M 0 part /boot5 t( A& D1 I! Z8 R0 V
├─vda2 252:2 0 1.3G 0 part /backup
0 }! ]: w- x& H└─vda3 252:3 0 48.2G 0 part $ z7 v. F2 J% P' i$ X" ]8 H
├─uniontechos-root 253:0 0 3G 0 lvm /
/ v, y4 I" g; q }! i └─uniontechos-swap 253:1 0 256M 0 lvm [SWAP] |
|