如何在线扩容阿里云服务器云盘?

 

第一、查看磁盘使用情况。

如下我的系统盘已经快满了,79%使用了。

[root@iZbpfrxxxxxxxxxxtgZ csp]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.8G 0 3.8G 0% /dev/shm
tmpfs 3.8G 500K 3.8G 1% /run
tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
/dev/vda1 40G 32G 8.8G 79% /
tmpfs 777M 0 777M 0% /run/user/0

备份好快照。

第二、去控制台购买扩容的量。

原来40G,多买了10G。

第三、查看磁盘情况。

[root@iZbpfrxxxxxxxxxxtgZ csp]# fdisk -lu
Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x69698bcb

Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 83886046 83883999 40G 83 Linux

 


第四、查看要扩容的盘的情况。


[root@iZbpfrxxxxxxxxxxtgZ csp]# file -s /dev/vda
/dev/vda: DOS/MBR boot sector

第五、执行扩容命令。

[root@iZbpfrxxxxxxxxxxtgZ csp]# type growpart || sudo yum install -y cloud-utils-growpart
growpart is /usr/bin/growpart

[root@iZbpfrxxxxxxxxxxtgZ csp]# yum update cloud-utils-growpart
Repository epel is listed more than once in the configuration
Last metadata expiration check: 2:05:18 ago on Tue 31 Dec 2024 05:50:59 PM CST.
Dependencies resolved.
Nothing to do.
Complete!

[root@iZbpfrxxxxxxxxxxtgZ csp]# LC_ALL=en_US.UTF-8 growpart /dev/vda 1                /dev/vda是我的系统盘
CHANGED: partition=1 start=2048 old: size=83883999 end=83886047 new: size=104855519 end=104857567

第六、扩容文件系统。

[root@iZbpfrxxxxxxxxxxtgZ csp]# xfs_growfs || yum install -y xfsprogs
Usage: xfs_growfs [options] mountpoint

Options:
-d grow data/metadata section
-l grow log section
-r grow realtime section
-n don't change anything, just show geometry
-i convert log from external to internal format
-t alternate location for mount table (/etc/mtab)
-x convert log from internal to external format
-D size grow data/metadata section to size blks
-L size grow/shrink log section to size blks
-R size grow realtime section to size blks
-e size set realtime extent size to size blks
-m imaxpct set inode max percent to imaxpct
-V print version information
Repository epel is listed more than once in the configuration
Last metadata expiration check: 2:08:58 ago on Tue 31 Dec 2024 05:50:59 PM CST.
Package xfsprogs-5.0.0-9.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

[root@iZbpfrxxxxxxxxxxtgZ csp]# xfs_growfs /    这个/是根据mounted on来的
meta-data=/dev/vda1 isize=512 agcount=9, agsize=1310656 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=10485499, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 10485499 to 13106939

第七、查看扩容情况。

[root@iZbpfrxxxxxxxxxxtgZ csp]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs tmpfs 3.8G 0 3.8G 0% /dev/shm
tmpfs tmpfs 3.8G 500K 3.8G 1% /run
tmpfs tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
/dev/vda1 xfs 50G 32G 19G 63% /
tmpfs tmpfs 777M 0 777M 0% /run/user/0

posted @   夏威夷8080  阅读(33)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2018-12-31 2018年结束感悟
点击右上角即可分享
微信分享提示