You can resize system and data disks to extend their capacities. This topic describes how to resize a disk for an Elastic Compute Service (ECS) Linux instance when the instance is running.
Prerequisites
Resource | Requirement |
---|---|
Instance |
Note If your instance does not meet the preceding requirements on resizing disks online,
you can resize its disks offline. For more information, see Resize disks offline for Linux instances.
|
Disk |
Notice A disk in the master boot record (MBR) partition format cannot be resized to 2 TiB
or larger. To resize an MBR disk to larger than 2 TiB, we recommend that you create
a disk with the desired capacity, partition and format the new disk to the GUID Partition
Table (GPT) format, and then copy data from the original MBR disk to the new GPT disk.
For more information about how to partition and format disks to GPT, see Partition and format a data disk larger than 2 TiB in size.
|
Background information
Resource | Description |
---|---|
Image used by the instance | Alibaba Cloud Linux 2.1903 LTS 64-bit public image |
System disk | /dev/vda: uses the MBR partition format and the ext4 file system, and is resized from 40 GiB to 60 GiB. |
Data disks |
|
Step 1: Create a snapshot
Before you resize a disk online, you must create a snapshot for the disk to back up the data stored on the disk.
Step 2: Resize the disk in the ECS console
- After you resize the disk in the ECS console, you must resize the partitions and file systems of the disk within the instance before you can use the new capacity of the disk.
- If you use Logical Volume Manager (LVM) to manage your disk partitions, you must use LVM to resize the partitions and file systems after you resize your disk in the ECS console. For more information, see Resize an LV by using LVM.
Step 3: View the disk partitions
You can log on to the instance to view the partition types (such as MBR and GPT) and file system types (such as ext4 and XFS) of the system disk and data disks. Subsequent resize operations vary based on the partition and file system types of the disks.
Step 4: Resize partitions
When you view the partitions of a resized disk, you may find that the partitions and file systems within the instance were not resized. This step describes how to resize the partitions of the resized disk within the instance.
Step 5: Resize file systems
This step describes how to resize the file systems of partitions within the instance.
Operating systems (images) that support online resizing of disks
- Alibaba Cloud Linux: Alibaba Cloud Linux 2 and Alibaba Cloud Linux 3
- CentOS:
- CentOS 6: CentOS 6.8 and later
- CentOS 7: CentOS 7.2 and later
- CentOS 8 and later
- Red Hat Enterprise Linux (RHEL):
- RHEL 6: RHEL 6.9 and later
- RHEL 7: RHEL 7.4 and later
- RHEL 8 and later
- Ubuntu: Ubuntu 16 and later
- Debian: Debian 8 and later
- SUSE: SUSE 12 SP2 and later
- openSUSE: openSUSE 42.3 and later
FAQ
- Question: When the
growpart /dev/vda 1
command is run on the Linux instance, theunexpected output in sfdisk --version [sfdisk, from util-linux 2.23.2]
error message appears. What do I do?Answer:- Run the
locale
command to check the character encoding type of the instance. If the character encoding type is not en_US.UTF-8, switch it to en_US.UTF-8.- Run the following command to switch the character encoding type:
LANG=en_US.UTF-8
- If the error persists, run the following command to switch the character encoding
type:
export LC_ALL=en_US.UTF-8
- If the error still persists, run the following command to switch the character encoding
type:
localectl set-locale LANG=en_US.UTF-8
- If the preceding solutions do not resolve the error, run the following command to
switch the character encoding type:
export LANGUAGE=en_US.UTF-8
- Run the following command to switch the character encoding type:
- If the error persists, run the
reboot
command to restart the instance.
NoticeIf the partition is resized after you switch the character encoding type, we recommend that you switch it back to the original character encoding type.
- Run the
- Question: When the
growpart /dev/vda 1
command is run on the Linux instance, the-bash: growpart: command not found
error message appears. What do I do?Answer:- Run the
uname -a
command to check the version of the Linux kernel. The procedure described in this topic applies to Linux kernel 3.6.0 and later.If the version of the Linux kernel is earlier than 3.6.0, you must resize the partitions of disks after you resize the disks. For more information, see Procedure for instances with kernels earlier than 3.6.0 and Resize partitions and file systems of Linux data disks.
- Install the growpart tool.
- If the instance runs a CentOS 7 or later operating system, run the following command:
yum install -y cloud-utils-growpart
Note CentOS 8 has reached its end of life (EOL). If your instance runs a CentOS 8 operating system, change the CentOS 8 repository address. For more information, see Change CentOS 8 repository addresses. - If the instance runs a Debian 8 or later operating system or an Ubuntu 14 or later
operating system, run the following command:
apt install -y cloud-guest-utils
- If the instance runs a CentOS 7 or later operating system, run the following command:
- Run the
- Question: The growpart tool used to resize partitions cannot be installed on an instance that
runs CentOS 6.5. Why?
Answer: The Linux kernel version of CentOS 6 is earlier than 3.6.0. To install the growpart tool on CentOS 6, perform the following steps:
- Change the YUM repository address for CentOS 6. For more information, see Change the CentOS 6 source address.
Note CentOS 6 has reached its EOL. To use YUM to install CentOS software packages, you must change the YUM repository address for CentOS 6.
- Install the dracut-modules-growroot tool on the instance that runs CentOS 6 to resize the partitions of disks. For more information, see Procedure for instances with kernels earlier than 3.6.0.
- Change the YUM repository address for CentOS 6. For more information, see Change the CentOS 6 source address.
Other scenarios for disk resizing
- If you want to create partitions on a resized data disk, see Option 2: Create and format MBR partitions or Option 4: Create and format GPT partitions.
- If a raw data disk contains a file system but no partitions, see Option 5: Resize the file system of a raw data disk.