tencent cloud

Feedback

Extending Data Disk Partitions and File Systems Online

Last updated: 2023-12-21 21:34:54

    Overview

    Expanding a data disk via the console only increases its storage space. You need to extend the partition or file system of the cloud disk to the larger size. This document describes how to extend partitions and file systems online.

    Prerequisite

    Before extending partition or file system, create a snapshot of the cloud disk to back up data. For more information, see Creating Snapshots. This practice helps you roll back snapshot to recover data in case of data loss due to maloperation.
    The cloud disk has been expanded and attached to a CVM via the console. For more information, see Expanding Cloud Disk Capacity.
    The Linux CVM kernel should be version 3.6.0 or later. You can use the uname -a command to check the kernel version. If the kernel version is earlier than 3.6.0, see Determining the Expansion Method.

    Operating Environment

    Resource
    Description
    Operating system
    CentOS 8.0 64-bit
    Cloud disk (data disk)
    /dev/vdb: Uses the MBR partition and the EXT4 file system, and expands from 50 GB to 60 GB via the console.
    /dev/vdc: Uses the GPT partition and the XFS file system, and expands from 50 GB to 60 GB via the console.

    Directions

    Viewing partitions of the cloud disk

    2. Run the following command to query partitions of the cloud disk.
    fdisk -l
    The following information appears:
    
    As shown in the figure,
    The 60 GB /dev/vdb data disk contains a 50 GB MBR partition /dev/vdb1.
    The 60 GB /dev/vdc data disk contains a 50 GB GPT partition /dev/vdc1.
    3. Run the following command to determine the file system type of existing partitions.
    df -TH
    The following information appears:
    
    As shown in the figure,
    The /dev/vdb1 partition is on an EXT4 file system that has been attached to /mnt/disk1.
    The /dev/vdc1 partition is on an XFS file system that has been attached to /mnt/disk2.

    Extending a partition

    1. Use the command as needed to install the gdisk tool.
    For a MBR partition, skip this step.
    For a GPT partition, run the following command according to the operating system of the CVM.
    CentOS
    Ubuntu or Debian
    yum install gdisk -y
    apt-get install gdisk -y
    2. Run the following command to install the growpart tool according to the operating system of the CVM.
    CentOS
    Ubuntu or Debian
    yum install -y cloud-utils-growpart
    apt-get install -y cloud-guest-utils
    3. Run the following command to extend partitions using growpart. Take extending the /dev/vdb1 partition as an example. Note that there is a space between /dev/vdb and 1 in the command. Replace with your actual values.
    growpart /dev/vdb 1
    If information similar to what is shown below is returned, the partition has been extended.
    
    

    Extending a file system

    1. Use the file system-specific command to resize a file system based on the type obtained in step 3.
    Extending an EXT file system
    Extending an XFS file system
    Run the following command to extend the EXT file system.
    resize2fs /dev/vdb1
    The following information will appear:
    
    
    
    Run the following command to extend the XFS file system.
    xfs_growfs <Mount point>
    Take mounting the /dev/vdc1 file system to`/mnt/disk2` as an example, then run the following command:
    xfs_growfs /mnt/disk2
    The following information will appear:
    
    
    
    2. Run the following command to view the result.
    df -TH
    If information similar to what is shown below is returned, the file system has been extended.
    
    
    3. Check data integrity and CVM running status after expansion. You can roll back the snapshot to recover data in case of exceptions. For more information, see Rolling Back Snapshots.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support