All Products
Search
Document Center

Elastic Compute Service:Initialize a data disk (Linux)

Last Updated:Jun 09, 2026

After you create and attach a cloud disk to an instance, you must initialize the disk and mount a file system before you can use it.

Procedure

Alibaba Cloud provides two methods to initialize a data disk:

  • Initialize from the console (invitational preview): Use Cloud Assistant in the console to initialize the disk and mount a file system. This method is convenient and does not require you to run commands manually.

  • Initialize from the command line: Log on to the instance and run commands to manually initialize the disk and mount a file system. This method provides more control and is widely applicable.

Method 1: Initialize from the console (invitational preview)

This feature is in invitational preview and is available only to select users.

  1. On the Block Storage tab of the instance details page, verify that Cloud Assistant is enabled.

    If Cloud Assistant is not available, you must initialize the cloud disk from the command line.

    image

  2. Open the Cloud Assistant initialization wizard.

    • If the cloud disk is not initialized, click 0/3 Passed under In-system Status Check for the target cloud disk, and then click Initialize to start the initialization process.

    • If a cloud disk is initialized but no file system is mounted, click 1/3 Passed under In-system Status Check for the target cloud disk, and then click Mount File System to re-enter.

    Not initialized

    If you need to expand the disk to 64 TiB, or if the page displays an error message such as Cloud Assistant Query or Task Failure or Cloud Assistant Not Installed, you must initialize the cloud disk from the command line.

    Cloud Assistant supports only GPT partitions and ext4 file systems.

    Important

    Creating a partition and a file system erases all data on the data disk. Make sure the cloud disk is empty before you proceed.

    1. On the disk status check page, configure the parameters, select the checkbox to acknowledge the risks, and then click OK.

      Parameter

      Description

      Size

      The total size of all partitions cannot exceed the capacity of the cloud disk.

      Mount point

      Must be an empty path that starts with /. Each mount point must be unique. If the directory is not empty, its existing content is hidden, which might affect your services.

      Add partition

      You can click Create Partition to create multiple partitions. You can add a maximum of 5 partitions per cloud disk.

    2. When the page displays the message The disk check is complete and the disk can be used as expected., the disk is initialized and the file system is mounted.

      Important

      This mount is temporary and does not persist after the instance reboots. To ensure that data remains accessible after a reboot, log on to the instance and configure the partition to automatically mount at startup.

    Initialized

    If the page displays an error message such as Cloud Assistant Query or Task Failure or Cloud Assistant Not Installed, you must initialize the cloud disk from the command line.
    1. On the disk status check page, configure the mount point, and then click Manually Mount.

      Parameter

      Description

      Mount point

      Must be an empty path that starts with /. Each mount point must be unique. If the directory is not empty, its existing content is hidden. This makes the original files inaccessible and might affect your services.

    2. When the page displays the message The disk check is complete and the disk can be used as expected., the file system is mounted.

      Important

      This mount is temporary and does not persist after the instance reboots. To ensure that data remains accessible after a reboot, log on to the instance and configure the partition to automatically mount at startup.

Method 2: Initialize from the command line

Step 1: Create a partition

  1. Connect to the ECS instance.

    1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

    2. Go to the details page of the target instance, click Connect, and select Workbench. Follow the on-screen instructions to connect to the instance and open the terminal.

  2. Create a partition.

    Partitions logically isolate data for different purposes. This prevents services from interfering with each other. If you do not need to create partitions, you can proceed directly to Step 2: Create a file system.

    1. Determine the device name of the cloud disk to be initialized. FSTYPE is the file system type. If this field is empty, no file system exists.

      sudo lsblk -f
      NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
      vda                                                      
      └─vda1 ext4   root  33b46ac5-7482-4aa5-8de0-60ab4c3a4c78 /
      vdb                                                      
      └─vdb1 ext4         f1645951-134f-4677-b5f4-c65c71f8f86d   
      vdc                                               
      • If a file system exists on the target cloud disk, the disk is already initialized. You only need to mount the file system. For example, the partition vdb1 on the data disk vdb has an ext4 file system, so you do not need to create a partition or a file system.

      • If a target cloud disk does not have a partition or a file system, this indicates that the disk is uninitialized. In the example, the data disk vdc has no partition or file system. You must create them before you can use the disk.

    2. Create a partition.

      The following steps show how to create a GPT partition. For MBR partitions, see How do I create an MBR partition?

      To understand the differences between partition types, see How do I choose a partition type and a file system type?
      Important

      Creating a partition erases all data on the data disk. Make sure the cloud disk is empty or that you have backed up its data by creating a snapshot.

      1. Install the parted tool.

        • For Alibaba Cloud Linux and CentOS:

          sudo yum install -y parted
        • For Debian and Ubuntu:

          sudo apt-get install -y parted
      2. Create the partition.

        Important

        Use binary units like MiB or GiB to set the start and end positions of the partition. parted automatically aligns partitions to 4 KiB boundaries. Using other units can result in misaligned partitions, which degrades cloud disk performance.

        Set <device name> to the device name that you obtained in Step 2.a.

        sudo parted /dev/<device_name> --script mklabel gpt mkpart <partition_name> <start_position> <end_position>
        Single-partition example: To allocate the entire capacity of the cloud disk with the device name vdc to a single partition, run sudo parted /dev/vdc --script mklabel gpt mkpart primary 1MiB 100%.
        Multi-partition example: This example shows how to divide a cloud disk with the device name vdc into two partitions. The first partition is named primary and is 20 GB. The remaining capacity is allocated to the second partition, which is named secondary. Run the following command: sudo parted /dev/vdc --script mklabel gpt mkpart primary 1MiB 20GiB mkpart secondary 20GiB 100%.
      3. Check if the partition is aligned.

        A misaligned partition can degrade cloud disk performance.

        1. View the partition number. Record the Number from the response because you will need it to check for alignment later.

          Set <device name> to the device name obtained in Step 2.a.

          sudo parted /dev/<device_name> print
        2. Check for alignment.

          Set <device name> to the device name obtained in Step 2.a, and <partition number> is the partition Number obtained in the previous step.

          sudo parted /dev/<device_name> align-check optimal <partition_number>

          A return value of aligned indicates that the partition is aligned. How do I resolve the 'not aligned' error when creating a GPT partition?

      4. Refresh the disk's partition table.

        Run sudo partprobe to instruct the operating system to re-read the partition information on the disk so that the new partition can be recognized.

      5. Verify that the partition was created.

        Run sudo lsblk to view the new partition information. If the correct partition information is found for the cloud disk that you want to initialize, the partition is successfully created. Next, you need to create a file system to make the data disk usable.

        sudo lsblk
        NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
        vda    253:0    0   50G  0 disk 
        └─vda1 253:3    0 49.8G  0 part /
        vdb    253:16   0   40G  0 disk 
        └─vdb1 253:17   0   40G  0 part 
        vdc    253:23   0   40G  0 disk 
        └─vdc1 253:24   0   40G  0 part 

        In this example, the entire cloud disk capacity of the target device vdc is allocated to the vdc1 partition.

Step 2: Create a file system

Important

Creating a file system deletes all data on the data disk. Make sure the cloud disk is empty or that you have backed up its data by creating a snapshot.

  1. Identify the target device name for the cloud disk. You will need this name when you create the file system.

    sudo lsblk -f
    NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
    vda                                                      
    └─vda1 ext4   root  33b46ac5-7482-4aa5-8de0-60ab4c3a4c78 /
    vdb                                                      
    └─vdb1 ext4         f1645951-134f-4677-b5f4-c65c71f8f86d   
    vdc  
    └─vdc1        
    vdd                                      
    • If the device has a partition, use the partition name. For example, for the disk vdc, the name to use is vdc1.

    • If the device does not have a partition, use the device name. For example, for the disk vdd, the name to use is vdd.

  2. Create a file system.

    ext4

    Replace the placeholder <target device name> with the target device name obtained in the previous step, and then run the command.

    If you need to expand the capacity to 64 TiB, add -i 65536 to the command to set bytes-per-inode to 65536.
    sudo mkfs -t ext4 /dev/<target_device_name>

    xfs

    1. Install the xfsprogs tool.

      For Debian or Ubuntu, use sudo apt-get install -y <package_name>.
      sudo yum install -y xfsprogs
    2. Create an XFS file system.

      Replace the <target device name> placeholder in the command with the target device name that you obtained in the previous step and run the command.

      sudo mkfs -t xfs /dev/<target_device_name>
  3. Verify that the file system was created.

    Run sudo lsblk -f. If the FSTYPE value for the target device in the command output is the file system type that you created, the configuration is successful. You must then mount the file system to store data.

Step 3: Mount the file system

  1. Create a mount point and mount the file system.

    sudo mkdir <mount_point> && sudo mount /dev/<target_device_name> <mount_point>

    Parameter

    Description

    <target device name>

    Replace this with the target device name you identified when creating the file system.

    <mount directory>

    The custom <mount directory> must be a unique, empty path that starts with /.

    Important

    If you mount the file system to a non-empty directory, the directory's existing content becomes temporarily inaccessible. This might affect your services, so assess the impact carefully.

    For example, to mount the target device vdc1 to the newly created /data directory, run sudo mkdir /data && sudo mount /dev/vdc1 /data.

  2. Verify that the file system was mounted.

    Run the sudo lsblk command. If the MOUNTPOINT column for the target device displays a mount point, the file system is mounted successfully.

    Important

    This mount is temporary and does not persist after the instance reboots. To ensure that data remains accessible after a reboot, we recommend configuring the partition to automatically mount at startup.

Configure automatic mount at startup

If you do not configure the partition to automatically mount at startup, you must manually run the mount command after each reboot to access the data on the disk.

  1. To prevent accidental operations, we recommend that you back up the /etc/fstab file.

    sudo cp /etc/fstab /etc/fstab.bak
  2. Configure the mount information.

    1. Get information about the target data disk.

      Run the command sudo lsblk -f and record the target device name, mount directory, and file system type for the target cloud disk. You will need this information to edit the mount information later.

      sudo lsblk -f
      NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
      vda                                                      
      └─vda1 ext4   root  33b46ac5-7482-4aa5-8de0-60ab4c3a4c78 /
      vdb    ext4         3d7a3861-da22-484e-bbf4-b09375894b4f                                                         
      └─vdb1 ext4         f1645951-134f-4677-b5f4-c65c71f8f86d /mnt
      vdc    xfs          3d7a3861-da22-484e-bbf4-b09375894b4f /test
      • If the device has a partition, the target device name is the partition name. For example, for the data disk vdb, the target device name is vdb1, the mount directory is /mnt, and the file system type is ext4.

      • If a device does not have a partition, the Target device name is the same as the device name. For example, for the data disk vdc, the Target device name is vdc, the Mount directory is /test, and the File system type is xfs.

    2. Append the mount information to /etc/fstab.

      Replace the variables <target_device_name>, <mount_point>, and <file_system_type> in the command with the information that you obtained in the previous step, and then run the command.

      Important

      When the parameter is set to defaults,nofail, the instance can start normally even if the mount configuration is incorrect. However, because the system does not report an error, you must carefully check whether the automatic mount is successful to prevent data from being written to the wrong device.

      sudo sh -c "echo `sudo blkid /dev/<target_device_name> | awk '{print \$2}' | sed 's/\"//g'` <mount_point> <file_system_type> defaults 0 0 >> /etc/fstab"
      In this example, the target device name is vdb1, the mount directory is /mnt, and the file system type is ext4:
      sudo sh -c "echo `sudo blkid /dev/vdb1 | awk '{print \$2}' | sed 's/\"//g'` /mnt ext4 defaults 0 0 >> /etc/fstab"
  3. Verify the automatic mount configuration. 

    1. Unmount the current mount point.

      Replace <target device name> with the target device name that you obtained in Step 3.a.

      sudo umount /dev/<target_device_name>
    2. Reload the /etc/fstab file.

      Run the following command to mount any unmounted file systems according to the /etc/fstab configuration file.

      sudo mount -a

      If an error occurs, you can use the sudo mv /etc/fstab.bak /etc/fstab command to quickly restore the /etc/fstab file.

    3. Verify the mount.

      Run the sudo lsblk command. If the output shows a mount directory for the target device in the MOUNTPOINT column, the configuration is successful.

Related documents

FAQ

  • How do I choose a partition and file system type?

    • Choose a partition format: The MBR format does not support disks larger than 2 TiB. If your cloud disk is, or might become, larger than 2 TiB, use the GPT format.

      Creating partitions helps with data management and logical isolation. If you do not need to create partitions, you can proceed directly to choosing a file system type.

      Partition format

      Max partition capacity

      Number of partitions

      Description

      GPT (Recommended)

      18 EiB (1 EiB = 1,048,576 TiB)

      The maximum capacity supported for an Alibaba Cloud cloud disk is 64 TiB.

      128

      All partitions are primary partitions. There is no distinction between extended and logical partitions.

      MBR

      2 TiB

      MBR supports the following partition schemes:

      • 4 primary partitions

      • 3 primary partitions and 1 extended partition

      • Partitions are categorized as primary, extended, and logical.

      • An extended partition cannot be used directly. It must be divided into one or more logical partitions before use. There is no limit on the number of logical partitions.

    • Choose a file system type: Compared to xfs, ext4 is generally better suited for handling small files.

      File system type

      Max file size

      Use cases

      ext4

      16 TiB

      Well-suited for workloads with many small files. Examples include general-purpose servers and desktop systems, development and testing environments, small log servers, internal management systems, and small database servers.

      xfs

      8 EiB

      The maximum capacity supported for an Alibaba Cloud cloud disk is 64 TiB.

      Offers better performance for large directories and large files. Examples include large database servers (MySQL/PostgreSQL), high-performance computing (HPC), storage-intensive applications (such as video and image storage), high-concurrency write operations, and big data analytics platforms.

  • How do I create an MBR partition?

    Important

    MBR does not support capacities over 2 TiB. If your disk capacity is or will be larger than 2 TiB, use the GPT partition format.

    1. Connect to the ECS instance.

      1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

      2. Go to the details page of the target instance, click Connect, and select Workbench. Follow the on-screen instructions to connect to the instance and open the terminal.

    2. Create an MBR partition.

      1. Start the fdisk utility.

        Set <device name> to the device name that you obtained in Step 2.a.

        sudo fdisk -u /dev/<device_name>
      2. Enter n to create a new partition.

      3. This example describes how to create a primary partition. Enter p to create a primary partition.

        • p represents the primary partition.

        • e represents an extended partition.

      4. Enter the partition number and press the Enter key.

        The partition number for a primary partition can be from 1 to 4.
      5. Enter the starting sector number, and press the Enter key.

        This is the partition's starting sector number. The system displays the valid range. Press Enter to use the default value, or enter a custom value from this range.
      6. Enter the last sector number and press the Enter key.

        This is the partition's ending sector number. The system displays the valid range. Press Enter to use the default value (which uses the remaining disk space), or enter a custom value from this range. The last sector number must be greater than the first sector number.
      7. Enter p and check the Device field to identify the planned new partition.

      8. Enter w to write the partition results to the partition table.

        If you make a mistake during the partitioning operation, enter q to exit fdisk. Your changes will not be saved, and you can restart the partitioning process.
    3. Run the sudo lsblk command to view information about the new partition. If the correct partition information is displayed for the cloud disk, the partition is created. In this example, the device vdb has one partition named vdb1. You must then create a file system to make the data disk usable.

      $ sudo lsblk
      NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
      vda    253:0    0   50G  0 disk 
      ├─vda1 253:1    0    2M  0 part 
      ├─vda2 253:2    0  200M  0 part /boot/efi
      └─vda3 253:3    0 49.8G  0 part /
      vdb    253:16   0   40G  0 disk 
      └─vdb1 253:17   0  40G  0 part
  • What do I do if an instance fails to start after an incorrect /etc/fstab configuration?

    Follow the steps in Troubleshoot boot failures caused by an incorrect /etc/fstab configuration in a Linux instance to connect to the instance remotely by using VNC and manually correct the mount information in emergency mode.

  • How do I resolve the not aligned error when creating a GPT partition?

    1. Run the following command to start partitioning again. This example uses the data disk /dev/vdb.

      sudo parted /dev/vdb
    2. In the parted interface, enter the following command to delete the misaligned partition.

      You can view the <Error partition number> using the print command.

      Important

      Before you delete a partition, make sure it contains no data or that you have backed up the data.

      rm <incorrect_partition_number>
    3. Run the following command to re-create the partition. Ensure that the units for the start and end positions are MiB or GiB. This example uses MiB:

      mkpart data <start_capacity>MiB <end_capacity>MiB 
  • How do I fix a "Size of device ... too big to be expressed" error when creating a file system?

    Cause: If a data disk is 16 TiB or larger, you must use e2fsprogs version 1.42 or later to create an ext4 file system. Otherwise, the following error occurs:

    mkfs.ext4: Size of device /dev/vdb too big to be expressed in 32 bits using a blocksize of 4096.            

    Solution: Upgrade e2fsprogs to version 1.42.8 or later.

    1. Check the current version of e2fsprogs.

      sudo rpm -qa | grep e2fsprogs
    2. Download e2fsprogs version 1.42.8.

      You can also find the latest package at e2fsprogs.
      sudo wget https://www.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v1.42.8/e2fsprogs-1.42.8.tar.gz --no-check-certificate
    3. Compile the later version of the tool. 

      1. Decompress the package.

        sudo tar xvzf e2fsprogs-1.42.8.tar.gz
      2. Navigate to the package directory.

        cd e2fsprogs-1.42.8
      3. Generate the Makefile.

        sudo ./configure
      4. Compile e2fsprogs.

        sudo make
      5. Install e2fsprogs.

        sudo make install
    4. Check if the version was successfully updated.

      sudo rpm -qa | grep e2fsprogs
  • How do I initialize a data disk by using an API?

    Call the RunCommand operation to send initialization commands to the target instance. Then, call the DescribeInvocations operation to query the output and confirm that the disk was initialized and mounted.

  • What do I do if I get a "404 not found" error when installing an initialization tool?

    CentOS 6 and Debian 9, 10, and 11 have reached their end of life (EOL). You must first switch the repository source for CentOS or Debian 9/10/11 before you install the tools.