Ali cloud server ECS cloud disk expansion

foreword

For cloud servers, I believe that most of the developers have played with them, but when the cloud disk is full, for novices or those who do not operate their own business, the initial capacity provided by the platform is not too small, so this situation is very difficult. The chances of getting there are relatively small. Since the complexity of my server application has gradually increased with the development of the business, the disk is full today, causing several services to hang directly.

failure scenario

My buddy told me that the front-end resources could not be uploaded today. Xiaobian went up to take a look. Good guy, the folder could not be created, and the container restart failed frequently. Using the mkdir command actually shows that my disk space is insufficient. Good guy, the capacity of 300G is lonely. Here, give me two slaps from a year ago.

Check disk usage

Oh, the root directory occupies 100%, and my heart is half cold. What about the 300G I expanded last time, so I took a look at the official expansion tutorial, MMP, the tutorial is very hidden, and I didn’t find it if I didn’t look carefully.

Expand capacity according to Alibaba Cloud official documents

  • Step 1
    Expand the capacity of the cloud disk in the ECS console
    Reminder: Before expanding the capacity, it is best to create a snapshot of the cloud disk. Alibaba Cloud charges for this. If the data is not very important, you don’t need to create a snapshot, which can save a little.

1. Find the place where the snapshot is created


After clicking OK, it will take a while. When it shows 100%, it means that the snapshot is created

Warm reminder: After the expansion is successful, delete the snapshot in time to avoid continuous charges.

2. Purchase the expansion package first for the console

Log in to expand the partition and file system inside the ECS instance

  • Enter the fdisk -lu command to view the cloud disk information with expansion

  • Install the expansion tool growpart
type growpart || yum install -y cloud-utils-growpart

  • If the cloud disk type is GPT type, you also need to install the gdisk tool, it is best to install it
输入命令:type sgdisk || yum install -y gdisk

  • Schematic diagram of successful installation

  • Carry out partition expansion
 输入命令:LC_ALL=en_US.UTF-8 growpart /dev/vdb 1

Notice:

1. A space needs to be added between vdb and the following number 1. 1 means the number of the partition.
2. /dev/vdb is obtained through the command fdisk -lu. You need to modify it according to your actual value. If there are many partitions A partition needs to be partitioned with the last number, such as
LC_ALL=en_US.UTF-8 growpart /dev/vdb 8, etc.

  • When the word CHANGED is output , it means that the partition is successful

  • Expand the file system

1. Use the df -Th command to view

2、

输入命令:resize2fs /dev/vdb1(这里需要根据你自己的实际值填写)

The following prompt is displayed, indicating that the expansion is successful

The expansion is successful, check the latest disk capacity

Enter the command to view, the expansion is successful

dh -h

write at the end

That's all for today's sharing. If you think it's good, you can bookmark it. You can always refer to it later when you do things yourself. If it's convenient, give me a triple. Welcome to "Anqianmahou", an account that continues to share practical dry goods. See you next time.

Guess you like

Origin blog.csdn.net/weixin_42329623/article/details/130908226