原本ECS只有20G的硬盘,使用Docker之后完完全全不够用了,在阿里云上使用在线扩容服务,多花了5块钱一个月,扩容到40G。

付钱之后, 需要挂在到硬盘上,但是不想直接reboot,所以按照阿里云给的文档,一步步操作即可。

文档地址:
https://help.aliyun.com/document_detail/113316.html

先看一眼目前的硬盘,还是20G

[root@iZwz98ewn8pi7f4d2u12m1Z ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        482M     0  482M   0% /dev
tmpfs           492M     0  492M   0% /dev/shm
tmpfs           492M  5.4M  487M   2% /run
tmpfs           492M     0  492M   0% /sys/fs/cgroup
/dev/vda1        20G   16G  3.2G  84% /
tmpfs            99M     0   99M   0% /run/user/0
overlay          20G   16G  3.2G  84% /var/lib/docker/overlay2/37622ad6dcbaed4079d377d65c8fea7ba47b3565152c10948725a206e5b97254/merged
overlay          20G   16G  3.2G  84% /var/lib/docker/overlay2/ee36f74c8d6efdd7300e285751e378c349105d684f279f663984ad129df9276f/merged
/dev/loop5      100M  100M     0 100% /var/lib/snapd/snap/core/11798
/dev/loop1      100M  100M     0 100% /var/lib/snapd/snap/core/11993
overlay          20G   16G  3.2G  84% /var/lib/docker/overlay2/ca56b14d7c24c03d476647c12433b3ac4db2ea82dd92bdecc1cd27a7461bb94a/merged
/dev/loop3       43M   43M     0 100% /var/lib/snapd/snap/certbot/1582
/dev/loop4       62M   62M     0 100% /var/lib/snapd/snap/core20/1242
overlay          20G   16G  3.2G  84% /var/lib/docker/overlay2/184075d81b46c7d3733b01233ab782d1d5a37cb14b66a777147327f88c731d27/merged
/dev/loop6       62M   62M     0 100% /var/lib/snapd/snap/core20/1270
/dev/loop0       44M   44M     0 100% /var/lib/snapd/snap/certbot/1670

再看一眼云盘的情况,确认已经付款成功,扩到40G

[root@iZwz98ewn8pi7f4d2u12m1Z ~]# fdisk -lu

磁盘 /dev/loop0:45 MB, 45195264 字节,88272 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/loop1:104 MB, 104267776 字节,203648 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/loop3:44 MB, 44183552 字节,86296 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/loop4:64 MB, 64835584 字节,126632 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/loop5:104 MB, 104271872 字节,203656 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/loop6:64 MB, 64913408 字节,126784 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/vda:42.9 GB, 42949672960 字节,83886080 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000b83c7

   设备 Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886046    41941999+  83  Linux

安装gdisk工具,进行分区扩容

yum install gdisk -y

使用工具,扩容系统盘

[root@iZwz98ewn8pi7f4d2u12m1Z ~] growpart /dev/vda 1
unexpected output in sfdisk --version [sfdisk,来自 util-linux 2.23.2]

遇到错误, 根据文档的提示,更改字符编码类型

export LANGUAGE=en_US.UTF-8

再次执行,扩容系统盘分区

 growpart /dev/vda 1

最后,扩容文件系统

[root@iZwz98ewn8pi7f4d2u12m1Z ~]# resize2fs /dev/vda1
resize2fs 1.43.5 (04-Aug-2017)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 3
The filesystem on /dev/vda1 is now 10485499 (4k) blocks long.

操作完成,检查扩容后情况

[root@iZwz98ewn8pi7f4d2u12m1Z ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        482M     0  482M   0% /dev
tmpfs           492M     0  492M   0% /dev/shm
tmpfs           492M  5.4M  487M   2% /run
tmpfs           492M     0  492M   0% /sys/fs/cgroup
/dev/vda1        40G   16G   23G  42% /
tmpfs            99M     0   99M   0% /run/user/0
overlay          40G   16G   23G  42% /var/lib/docker/overlay2/37622ad6dcbaed4079d377d65c8fea7ba47b3565152c10948725a206e5b97254/merged
overlay          40G   16G   23G  42% /var/lib/docker/overlay2/ee36f74c8d6efdd7300e285751e378c349105d684f279f663984ad129df9276f/merged
/dev/loop5      100M  100M     0 100% /var/lib/snapd/snap/core/11798
/dev/loop1      100M  100M     0 100% /var/lib/snapd/snap/core/11993
overlay          40G   16G   23G  42% /var/lib/docker/overlay2/ca56b14d7c24c03d476647c12433b3ac4db2ea82dd92bdecc1cd27a7461bb94a/merged
/dev/loop3       43M   43M     0 100% /var/lib/snapd/snap/certbot/1582
/dev/loop4       62M   62M     0 100% /var/lib/snapd/snap/core20/1242
overlay          40G   16G   23G  42% /var/lib/docker/overlay2/184075d81b46c7d3733b01233ab782d1d5a37cb14b66a777147327f88c731d27/merged
/dev/loop6       62M   62M     0 100% /var/lib/snapd/snap/core20/1270
/dev/loop0       44M   44M     0 100% /var/lib/snapd/snap/certbot/1670

Done.