After creating and attaching a cloud disk to an instance, you must initialize the disk and mount a file system before using 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 convenient method does not require running commands manually.
Initialize from the command line: Log on to the instance and run commands to initialize the disk and mount a file system manually. This method offers greater control and is widely applicable.
Method 1: Initialize a data disk from the console (invitational preview)
This invitational preview feature is available only to specific users and in certain scenarios.
On the Block Storage tab of the instance details page, enable Cloud Assistant detection.
If Cloud Assistant detection is not available, you must initialize the cloud disk from the command line.

Open the Cloud Assistant initialization wizard.
If the cloud disk is not initialized: Hover over 0/3 Check Passed under In-system Status Check for the target cloud disk and click Initialize Data Disk.
If the cloud disk is initialized but not mounted: Hover over 1/3 Check Passed under In-system Status Check for the target cloud disk and click Mount File Systems.
If the disk is not initialized
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', initialize the cloud disk from the command line.
Cloud Assistant only supports creating GPT partitions and ext4 file systems.
ImportantCreating a partition and a file system erases all data on the data disk. Make sure the cloud disk is empty before you proceed.
On the cloud disk status check page, configure the parameters, select the checkbox to acknowledge the risks, and then click OK.
Parameter
Description
Partition size
The total size of all partitions cannot exceed the capacity of the cloud disk.
Mount Target
This must be an empty path that starts with
/. Each mount target must be unique. If the directory is not empty, its existing content will be hidden, which might affect your services.Add Partition
You can click Add Partition to create multiple partitions as needed. You can add a maximum of 5 partitions per cloud disk.
When the page displays the message 'The disk check is complete and the disk can be used as expected.', the disk is initialized and mounted.
ImportantThis mount is temporary and does not persist after a reboot. To ensure data remains accessible after a reboot, log in to the instance and configure the partition to mount automatically on boot.
If the disk is 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.
On the cloud disk status check page, configure the mount target and then click Manually Mount.
Parameter
Description
Mount Target
This must be an empty path that starts with
/. Each mount target must be unique. If the directory is not empty, its existing content will be hidden, which might affect your services.When the page displays the message 'The disk check is complete and the disk can be used as expected.', the file system is mounted.
ImportantThis mount is temporary and does not persist after a reboot. To ensure data remains accessible after a reboot, log in to the instance and configure the partition to mount automatically on boot.
Method 2: Initialize a data disk from the command line
Step 1: Create a partition
Log on to the Elastic Compute Server (ECS) instance.
Go to ECS console - Instance. In the top navigation bar, select the target region and resource group.
Go to the details page of the target instance, click Connect, and select Workbench. Follow the on-screen instructions to log in and open the terminal.
Create a partition.
Partitions provide logical isolation, letting you separate data for different purposes. This can prevent services from interfering with each other. If you do not need to create partitions, proceed directly to Step 2: Create a file system.
Identify the device name of the cloud disk you want to initialize.
FSTYPEindicates the file system type. If this column is empty, no file system exists.sudo lsblk -fNAME FSTYPE LABEL UUID MOUNTPOINT vda └─vda1 ext4 root 33b46ac5-7482-4aa5-8de0-60ab4c3a4c78 / vdb └─vdb1 ext4 f1645951-134f-4677-b5f4-c65c71f8f86d vdcIf the target cloud disk already has a file system, you only need to mount it. For example, the data disk
vdbhas a partitionvdb1with an ext4 file system. You can skip to Step 3: Mount the file system.If the target cloud disk does not have a partition or a file system, you must initialize it. For example, the data disk
vdcrequires initialization.
Create a partition.
The following steps show how to create a GPT partition. For MBR partitions, see How do I create an MBR partition?
For more information about the differences between partition types, see How do I choose a partition type and a file system type?
ImportantCreating a partition erases all data on the data disk. Make sure the cloud disk is empty or back up your data by creating a snapshot.
Install the Parted tool.
For Alibaba Cloud Linux and CentOS:
sudo yum install -y partedFor Debian and Ubuntu:
sudo apt-get install -y parted
Create the partition.
ImportantUse binary units like MiB or GiB to set the start and end positions of the partition. Parted automatically aligns partitions to 4 KiB boundaries. If you do not use binary units, partitions may be misaligned, which degrades cloud disk performance.
Replace
<device_name>with the device name you identified 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
vdcto a single partition, runsudo parted /dev/vdc --script mklabel gpt mkpart primary 1MiB 100%.Multiple partitions example: To divide the capacity of the cloud disk with the device name
vdcinto two partitions, with the first partition namedprimarybeing 20 GiB and the second partition namedsecondaryusing the remaining capacity, runsudo parted /dev/vdc --script mklabel gpt mkpart primary 1MiB 20GiB mkpart secondary 20GiB 100%.Check if the partition is aligned.
Misaligned partitions can degrade cloud disk performance.
View the partition number. Note the
Numberfrom the output, as you will need it to check for alignment.Replace
<device_name>with the device name you previously identified in Step 2.a.sudo parted /dev/<device_name> printCheck for alignment.
Replace
<device_name>with the device name you identified and<partition_number>with the partitionNumberyou noted in Step 2.a.sudo parted /dev/<device_name> align-check optimal <partition_number>The output
alignedindicates that the partition is correctly aligned. When I create a GPT partition, the system reports anot alignederror. How do I fix this?
Refresh the disk partition table.
Run
sudo partprobeto inform the operating system of the partition table changes.Verify that the partition was created.
Run
sudo lsblkto view the new partition information. If the output shows the correct partition information for the disk you are initializing, proceed to Step 2: Create a file system.sudo lsblkNAME 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 partIn this example, the entire capacity of the target device
vdchas been allocated to thevdc1partition.
Step 2: Create a file system
Creating a file system deletes all data on the data disk. Make sure the cloud disk is empty or back up your data by creating a snapshot.
Identify the target device name for the cloud disk you want to initialize. You will need this name when you create the file system.
sudo lsblk -fNAME FSTYPE LABEL UUID MOUNTPOINT vda └─vda1 ext4 root 33b46ac5-7482-4aa5-8de0-60ab4c3a4c78 / vdb └─vdb1 ext4 f1645951-134f-4677-b5f4-c65c71f8f86d vdc └─vdc1 vddIf the device has a partition, the target device name is the partition name. In this example, for the data disk
vdc, the target device name isvdc1.If the device does not have a partition, the target device name is the device name. In this example, for the data disk
vdd, the target device name isvdd.
Create a file system.
ext4
Replace
<target_device_name>in the command with the target device name you identified in the previous step and then run the command.If you need to expand the disk to 64 TiB in the future, add
-i 65536to the command to specify abytes-per-inodevalue of 65536.sudo mkfs -t ext4 /dev/<target_device_name>xfs
Install the xfsprogs tool.
For Debian or Ubuntu, use
sudo apt-get install -y <package_name>.sudo yum install -y xfsprogsCreate an XFS file system.
Replace
<target_device_name>in the command with the target device name you identified in the previous step and then run the command.sudo mkfs -t xfs /dev/<target_device_name>
Verify that the file system was created.
Run
sudo lsblk -f. If theFSTYPEcolumn for the target device shows the file system you created, proceed to Step 3: Mount the file system.
Step 3: Mount the file system
Create a directory and mount the file system.
sudo mkdir <mount_directory> && sudo mount /dev/<target_device_name> <mount_directory>Parameter
Description
<target_device_name>Replace this with the target device name you identified when creating the file system.
<mount_directory>Specify a custom
<mount_directory>. This must be an empty path that starts with/. Each mount directory must be unique.ImportantIf the directory is not empty, its existing content will be hidden, which may affect your services. Evaluate this carefully.
For example, to mount the target device
vdc1to a new directory named/data, runsudo mkdir /data && sudo mount /dev/vdc1 /data.Verify that the file system was mounted.
Run the
sudo lsblkcommand. If the output shows a mount directory (MOUNTPOINT) for the target device, the file system is mounted successfully.ImportantThis mount is temporary and does not persist after a reboot. To ensure data remains accessible after a reboot, configure the partition to mount automatically on boot.
Configure the partition to mount automatically on boot
If you do not configure the partition to mount automatically on boot, the mount is lost on reboot. You must mount the disk manually to access its data.
Back up the
/etc/fstabfile to prevent data loss from misconfiguration.sudo cp /etc/fstab /etc/fstab.bakConfigure the mount information
Get information about the target data disk.
Run the
sudo lsblk -fcommand and note the target device name, mount directory, and file system type of the cloud disk to be configured. You will need this information to edit the mount entry.sudo lsblk -fNAME 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 /testIf the device has a partition, the target device name is the partition name. In this example, for the data disk
vdb, the target device name isvdb1, the mount directory is/mnt, and the file system type isext4.If the device does not have a partition, the target device name is the device name itself. In this example, for the data disk
vdc, the target device name isvdc, the mount directory is/test, and the file system type isxfs.
Append the mount information to
/etc/fstab.Replace the variables
<target_device_name>,<mount_directory>, and<file_system_type>in the command with the information you obtained in the previous step and then run the command.ImportantWhen the mount options are 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 verify that the automatic mount was 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_directory> <file_system_type> defaults 0 0 >> /etc/fstab"For example, to configure a device with target device name
vdb1, mount directory/mnt, and file system typeext4:sudo sh -c "echosudo blkid /dev/vdb1 | awk '{print $2}' | sed 's/"//g'/mnt ext4 defaults 0 0 >> /etc/fstab"
Verify that the automatic mount configuration is effective.
Unmount the current mount point.
Replace
<target_device_name>with the target device name you identified in the Step 3.a.sudo umount /dev/<target_device_name>Reload the
/etc/fstabfile.Mount all unmounted file systems defined in
/etc/fstab.sudo mount -aIf an error occurs, you can quickly restore the
/etc/fstabfile by runningsudo mv /etc/fstab.bak /etc/fstab.Check if the mount is effective.
Run the
sudo lsblkcommand. If the output shows a mount directory (MOUNTPOINT) for the target device, the configuration was successful.
References
To resize an existing cloud disk, see Resize a Linux cloud disk.
To initialize a data disk for a Windows instance, see Initialize a data disk (Windows).
FAQ
How do I choose a partition type and a 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
Partition description
GPT (Recommended)
18 EiB (1 EiB = 1,048,576 TiB)
The maximum capacity supported by Alibaba cloud disks 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. There is no limit on the number of logical partitions.
Choose a file system type: ext4 is better suited for handling small files than xfs.
File system type
Max file size
Use cases
ext4
16 TiB
Performs well with small files, making it suitable for scenarios with many small files, such as 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 by Alibaba cloud disks is 64 TiB.
Offers better performance for large-scale directories and large files. Suitable for 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?
ImportantMBR does not support capacities over 2 TiB. If your disk capacity exceeds 2 TiB, use the GPT partition format.
Log on to the ECS instance.
Go to ECS console - Instance. In the top navigation bar, select the target region and resource group.
Go to the details page of the target instance, click Connect, and then select Workbench. Follow the on-screen instructions to log in and open the terminal.
Create an MBR partition.
Start the fdisk utility.
Replace
<device_name>with the device name you identified previously in Step 2.a.sudo fdisk -u /dev/<device_name>Enter
nto create a new partition.As an example, to create a primary partition, enter
p.pstands for primary partition.estands for extended partition.
Enter the partition number and press
Enter.The partition number for a primary partition can be from 1 to 4.
Enter the starting sector number and press
Enter.The first sector is the starting sector number of the partition. The system displays the available sector range. You can enter a custom value within this range or press Enter to use the default value.
Enter the last sector number and press
Enter.The last sector is the ending sector number of the partition. The system displays the available sector range. You can enter a custom value within this range or press Enter to use the default value. The last sector number must be greater than the first sector number.
Enter
pto review the planned new partition, checking theDevicefield.Enter
wto write the partition table and exit.If you make a mistake, enter
qto exit fdisk without saving the changes. You can then restart the process.
Run
sudo lsblkto view the new partition information. If the output shows the correct partition information for the disk, the partition was created successfully. In this example, devicevdbhas one partition,vdb1. Next, 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 should I do if the instance fails to start after an incorrect /etc/fstab configuration?
You can follow the steps in Troubleshoot boot failures caused by incorrect /etc/fstab configuration in Linux instances to connect to the instance remotely using VNC and manually correct the incorrect mount information in emergency mode.
How do I fix a
"not aligned"error when creating a GPT partition?Run the following command to start partitioning again. This example uses the data disk
/dev/vdb.sudo parted /dev/vdbIn the Parted interface, enter the following to delete the incorrect partition.
You can find the
<incorrect_partition_number>by using theprintcommand.ImportantBefore you delete a partition, make sure it contains no data or that the data has been backed up.
rm <incorrect_partition_number>Run the following command to re-create the partition, ensuring 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 "device too big" error?
Cause: If the data disk capacity is 16 TiB, you must use e2fsprogs version 1.42 or later to create an ext4 file system. Otherwise, the following error will occur:
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.
Check the current version of e2fsprogs.
sudo rpm -qa | grep e2fsprogsDownload 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-certificateCompile the later version of the tool.
Decompress the package.
sudo tar xvzf e2fsprogs-1.42.8.tar.gzNavigate to the package directory.
cd e2fsprogs-1.42.8Generate the Makefile.
sudo ./configureCompile e2fsprogs.
sudo makeInstall e2fsprogs.
sudo make install
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, and then call the DescribeInvocations operation to query the command output to initialize the disk and mount a file system.
How do I fix a "404 Not Found" error when installing an initialization tool?
CentOS 6 and Debian 9/10/11 have reached their end-of-life (EOL). You must first switch the repository source addresses for CentOS or the Debian 9/10/11 before installing the tools.