原因

阿里云ECS云盘扩容后,在Linux服务器上没有生效
实际需要几条命令扩容才能正式生效。

处理方法

  • 先看扩容前磁盘空间,/dev/vda1可以看到只有40G。
# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  7.5G     0  7.5G   0% /dev
tmpfs          tmpfs     7.6G     0  7.6G   0% /dev/shm
tmpfs          tmpfs     7.6G  496K  7.6G   1% /run
tmpfs          tmpfs     7.6G     0  7.6G   0% /sys/fs/cgroup
/dev/vda1      ext4       40G   36G  2.0G  95% /
tmpfs          tmpfs     1.6G     0  1.6G   0% /run/user/0
  • 扩容后看到有200G/dev/vda: 214.7 GB,现在准备扩容分配给vda1
# 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: 0x000bf134

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886046    41941999+  83  Linux
  • 首先安装工具
yum install -y cloud-utils-growpart
  • 扩容需要的分区
    运行growpart 命令,为需要扩容的云盘和对应的第几个分区扩容。
    /dev/vda 1 ,表示为系统盘的第一个分区扩容。
# growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=83883999 end=83886047 new: size=419428319 end=419430367
  • 通过resize2fs重设分区大小
# resize2fs /dev/vda1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 13
The filesystem on /dev/vda1 is now 52428539 blocks long.
  • 最后再查看磁盘,发现/dev/vda1扩容成功
# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  7.5G     0  7.5G   0% /dev
tmpfs          tmpfs     7.6G     0  7.6G   0% /dev/shm
tmpfs          tmpfs     7.6G  496K  7.6G   1% /run
tmpfs          tmpfs     7.6G     0  7.6G   0% /sys/fs/cgroup
/dev/vda1      ext4      197G   36G  154G  19% /
tmpfs          tmpfs     1.6G     0  1.6G   0% /run/user/0

参考链接:
https://www.jianshu.com/p/0f4d20327153

10-24 23:54