Alibaba cloud disk online capacity expansion

1. Check whether the disk supports online capacity expansion

https://help.aliyun.com/document_detail/113316.html

2. Create snapshot from cloud disk


3. Online capacity expansion

  • purchase

4. Log in to the server to view the disk status

# View cloud disk partition
[root@middleware ~]# fdisk -l
Disk /dev/vda: 200 GiB, 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
Disklabel type: dos
Disk identifier: 0x1863aa79

Device     Boot Start       End   Sectors Size Id Type
/dev/vda1  *     2048 104857566 104855519  50G 83 Linux

# Confirm that the file system type of the existing partition is xfs
[root@middleware ~]# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  7.7G     0  7.7G   0% /dev
tmpfs          tmpfs     7.7G     0  7.7G   0% /dev/shm
tmpfs          tmpfs     7.7G  540K  7.7G   1% /run
tmpfs          tmpfs     7.7G     0  7.7G   0% /sys/fs/cgroup
/dev/vda1      xfs        50G   39G   12G  77% /
tmpfs          tmpfs     1.6G     0  1.6G   0% /run/user/0

Serial number partition explain
/dev/vda1 System disk, which is represented as MBR partition.
/dev/vdb1 Data disk, which is represented as MBR partition.
/dev/vdc1 Data disk, the value of System GPT is expressed as GPT partition.

5. Expansion partition

By checking the partition of the cloud disk, the partition and file system in the ECS instance are not expanded. This step describes how to expand cloud disk partitions within ECS instances.

5.1 install the gdisk tool inside the ECS instance.

If your partition is in GPT format, you must perform this step; If your partition is in MBR format, skip this step.

yum install gdisk -y
5.2 install the growpart tool.
-Run the following command for Alibaba cloud Linux version 2 / 3, CentOS 7 and above.
yum install -y cloud-utils-growpart
-Debian 8 and above, Ubuntu 14 and above run the following command.

Update software source.

apt-get update

Install cloud guest utils.

apt-get install -y cloud-guest-utils
5.3 run the following commands to expand the partition.
[root@middleware ~]# growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=104855519 end=104857567 new: size=419428319 end=419430367

This example takes the expansion of the system disk as an example. Space separation is required between / dev/vda and 1. If you need to expand other partitions, please modify the command according to the actual situation. The execution results are as follows. Represents the first partition of the expanded / dev/vda.

Note: when you execute this step, the error message unexpected output in sfdisk --version [sfdisk, from util Linux 2.23.2] may appear. For how to troubleshoot this problem, see the frequently asked questions section of this article.

6. Capacity expansion file system

6.1 within the ECS instance, expand the file system according to the file system type queried.
[root@middleware ~]# blkid
/dev/vda1: UUID="e32cfa7a-df48-4031-8fdf-5eec92ee3039" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="1863aa79-01"
[root@middleware ~]# 
[root@middleware ~]# 
[root@middleware ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda    253:0    0  200G  0 disk 
└─vda1 253:1    0  200G  0 part /
Expand ext * (for example, ext4) file system: run the following command to expand the file system.

--# expand the file system of system disk / dev/vda1

[root@middleware ~]# resize2fs /dev/vda1

--# expand the file system of data disk / dev/vdb1

[root@middleware ~]# resize2fs /dev/vdb1
Expand xfs file system: run the following command to expand the file system of data disk / dev/vda1.

[root@middleware ~]# xfs_growfs /dev/vda1
meta-data=/dev/vda1 isize=512 agcount=11, agsize=1310656 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=13106939, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13106939 to 52428539

Expand btrfs file system: if your data disk file system is btrfs, you need to run the following command to expand the file system.

[root@middleware ~]# btrfs filesystem resize max /mountpoint

Note: / mountpoint is the mount point corresponding to the data disk. You need to modify it according to the actual situation.

6.2 run the following commands to check the results after capacity expansion.

[root@middleware ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 540K 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/vda1 200G 40G 161G 20% /
tmpfs 1.6G 0 1.6G 0% /run/user/0

After the expansion, you need to check whether the data is normal according to the actual situation.
 - If the expansion is successful, ECS If the business program in the instance can run normally, the operation is completed.
 - If the expansion fails, the data will be rolled back through the backup snapshot.

Keywords: Linux

Added by whizard on Mon, 31 Jan 2022 22:30:29 +0200