You can resize a system disk or data disk to extend its capacity. If your Elastic Compute Service (ECS) Linux instance does not support online resizing of disks, you can resize the disks on the instance offline. After you resize a disk on an instance offline, you must restart the instance for the change to take effect. The restart operation interrupts services that run on the instance for a short period of time. We recommend that you resize disks offline during off-peak hours.
Prerequisites
Resource | Requirement |
---|---|
Instance |
|
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 in the disk.
Step 2: Resize the disk and start or restart the instance in the ECS console
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 resizing 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.
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 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 problem still persists, run the following command to switch the character encoding
type:
export LC_ALL=en_US.UTF-8
- If the problem 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 problem, 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 problem still 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 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
- 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 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 end of life (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 a CentOS 6 operating system 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.