第一章 阿里云ECS服务器云盘在线扩容不生效(详细解决步骤)

最近将阿里云服务器的系统盘扩容了2T,但是过了很长时间,我的系统依旧是原来的1T,磁盘确实已经扩大到2T,于是搜索了一下看看什么原因导致,其实是我们的系统盘原本已经做了分区,虽然系统盘扩容,但是我们的分区没有做改动,所以我们应该对系统盘的分区.

一、安装growpart

[root@iZuf681ncvagioevqx84nuZ all-sql]# yum install -y cloud-utils-growpart gdisk

二、查看磁盘实际大小

[root@iZuf681ncvagioevqx84nuZ ~]# fdisk  -l

Disk /dev/vda: 214.7 GB, 214748364800 bytes, 419430400 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
Disk label type: dos
Disk identifier: 0x0008d207

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   419430366   209714159+  83  Linux

Disk /dev/vdb: 2147.5 GB, 2147483648000 bytes, 4194304000 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
Disk label type: dos
Disk identifier: 0x00d2a2f3

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048  2097151999  1048574976   83  Linux

Disk /dev/mapper/docker-253:1-263986-pool: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 65536 bytes

三、查看磁盘分配大小

[root@iZuf681ncvagioevqx84nuZ ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1       197G  185G  3.1G  99% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G     0   16G   0% /dev/shm
tmpfs            16G  792K   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/vdb1       985G  870G   65G  94% /data
tmpfs           3.2G     0  3.2G   0% /run/user/0

四、自适应分区扩容

#表示为系统盘的第一个分区(/dev/vdb1)扩容。
[root@iZuf681ncvagioevqx84nuZ ~]# growpart /dev/vdb 1
CHANGED: partition=1 start=2048 old: size=2097149952 end=2097152000 new: size=4194301919 end=4194303967

五、重设分区大小

[root@iZuf681ncvagioevqx84nuZ ~]# resize2fs /dev/vdb1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vdb1 is mounted on /data; on-line resizing required
old_desc_blocks = 125, new_desc_blocks = 250
The filesystem on /dev/vdb1 is now 524287739 blocks long.

六、再次查看磁盘分区大小

[root@iZuf681ncvagioevqx84nuZ ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1       197G  187G  983M 100% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G     0   16G   0% /dev/shm
tmpfs            16G  784K   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/vdb1       2.0T  870G 1009G  47% /data
tmpfs           3.2G     0  3.2G   0% /run/user/0
可以看到分区(/dev/vdb1)容量已经是2T,表示已经成功扩容。

在整个过程中,无需重启服务器,所以不会影响到服务器上正在运行的服务。
posted @ 2021-10-14 21:31  年少纵马且长歌  阅读(539)  评论(0编辑  收藏  举报