You can resize a system disk or data disk to extend its capacity. This topic describes how to resize a disk on a Linux instance while the instance is running.
Prerequisites
Resource | Requirement |
---|---|
Instance |
Note If your ECS instance does not meet the 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 greater in size. To resize an MBR disk to larger than 2 TiB, we recommend that
you create a new disk larger than 2 TiB, partition and format the new disk 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 use the GPT format to partition and
format disks, see Partition and format a data disk larger than 2 TiB.
|
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 ext4 file system, and is resized from 40 GiB to 60 GiB. |
Data disk |
|
Step 1: Create a snapshot
Create a snapshot for the disk to back up the disk data before you resize the disk.
Step 2: Resize the disk in the ECS console
Step 3: View the disk partitions
Log on to the ECS instance to view the partition types (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 types of the partitions and file systems.
Step 4: Resize partitions
When you view the disk partitions, you can find that the partitions and file systems within the ECS instance have not been resized. This step describes how to resize the partitions of the resized disk within the ECS instance.
Step 5: Resize file systems
This step describes how to resize the file system of a partition within an ECS instance.
Operating systems that support online resizing
- Alibaba Cloud Linux: Alibaba Cloud Linux 2.1903 LTS 64-bit
- CentOS: CentOS 6.8 and later, CentOS 7.2 and later, and CentOS 8 and later
- Red Hat Enterprise Linux (RHEL): RHEL 6.9 and later, RHEL 7.4 and later, and 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
- Problem description: When the
growpart /dev/vda 1
command is run, theunexpected output in sfdisk --version [sfdisk, from util-linux 2.23.2]
error is prompted.Solution:- Run the
locale
command to view the character encoding type of the ECS 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 persists, run the following command to switch the character encoding
type:
export LC_ALL=en_US.UTF-8
- If the problem persists, run the following command to switch the character encoding
type:
localectl set-locale LANG=en_US.UTF-8
- If you are using a CentOS 8 image and the preceding solution cannot solve 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 persists, run the
reboot
command to restart the ECS instance.
NoticeAfter you resize the partition by switching the character encoding type, we recommend that you switch back to the original character encoding type.
- Run the
- Problem description: When the
growpart /dev/vda 1
command is run, the-bash: growpart: command not found
error is prompted.Solution:- 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 can extend partitions of a disk on the instance. 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.
- Run the following command if the instance runs CentOS 7 or later:
yum install -y cloud-utils-growpart
- Run the following command if the instance runs Debian 9 or later or Ubuntu 14 or later:
apt install -y cloud-guest-utils
- Run the following command if the instance runs CentOS 7 or later:
- Run the
Other scenarios for disk resizing
- If you want to create partitions on the resized data disk, see Option 2: Add and format MBR partitions or Option 4: Add and format GPT partitions.
- If no partition is created on your data disk and a file system is created on the raw device, extend the file system. For more information, see Option 5: Resize the file system of a raw data disk.