[Alibaba Cloud] Resize Alibaba Cloud ECS (Linux) Yun Disk size online

growpart and resize2fs to extend disk size

Alibaba CLoud Elastic Compute Service (ECS) is a high-performance, stable, reliable, and scalable IaaS-level service provided by Alibaba Cloud. ECS eliminates the need for upfront investments in IT hardware and allows you to scale computing resources on demand. This makes ECS instances more convenient and efficient than physical servers. ECS provides a variety of instance types that suit various business needs and helps boost business growth.

This article provides instructions on how to use tools such as growpart and resize2fs to extend the partition and file system of the Linux system disk.

Prerequites

Before extending the system disk partition and file system, please complete the following tasks in advance.

  • A snapshot backup data has been created.

    To prevent data loss due to operational errors, it is recommended that you use snapshots to back up data before operations.

  • The cloud disk has been expanded on the console.

  • Connect to the ECS instance remotely.

Installation

First, install growpart or xfsprogs according to your OS.

1
2
3
4
5
# CentOS7+
$ yum install cloud-utils-growpart xfsprogs -y

# # Debian, Ubuntu
# $ apt install cloud-guest-utils xfsprogs -y

Usages

Run growpart <DeviceName> <PartionNumber> command to resize disk.

1
2
# growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=83881984 end=83884032 new: size=125827039 end=125829087

Run resize2fs <PartitionName> command to resize file system.

1
2
3
4
5
# 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 = 4
The filesystem on /dev/vda1 is now 15728379 blocks long.

Run the following commands to show disk size.

1
$ df -m

References

[1] What is ECS? - https://www.alibabacloud.com/help/en/doc-detail/25367.htm

[2] Resize disks online for Linux instances - https://www.alibabacloud.com/help/en/doc-detail/113316.html