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.
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.

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.
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 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.
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.
ImportantThis 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.
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.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 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
Connect to the ECS instance.
Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.
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.
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.
Determine the device name of the cloud disk to be initialized.
FSTYPEis the file system type. If this field 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 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
vdb1on the data diskvdbhas 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
vdchas no partition or file system. You must create them before you can use the disk.
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?
ImportantCreating 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.
Install the
partedtool.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.
partedautomatically 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
vdcto 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
vdcinto 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%.Check if the partition is aligned.
A misaligned partition can degrade cloud disk performance.
View the partition number. Record the
Numberfrom 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> printCheck for alignment.
Set
<device name>to the device name obtained in Step 2.a, and<partition number>is the partitionNumberobtained in the previous step.sudo parted /dev/<device_name> align-check optimal <partition_number>A return value of
alignedindicates that the partition is aligned. How do I resolve the 'not aligned' error when creating a GPT partition?
Refresh the disk's partition table.
Run
sudo partprobeto instruct the operating system to re-read the partition information on the disk so that the new partition can be recognized.Verify that the partition was created.
Run
sudo lsblkto 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 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 cloud disk capacity of the target device
vdcis 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 that you have backed up its data by creating a snapshot.
Identify the target device name for the cloud disk. 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, use the partition name. For example, for the disk
vdc, the name to use isvdc1.If the device does not have a partition, use the device name. For example, for the disk
vdd, the name to use isvdd.
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 65536to the command to setbytes-per-inodeto 65536.sudo mkfs -t ext4 /dev/<target_device_name>xfs
Install the
xfsprogstool.For Debian or Ubuntu, use
sudo apt-get install -y <package_name>.sudo yum install -y xfsprogsCreate 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>
Verify that the file system was created.
Run
sudo lsblk -f. If theFSTYPEvalue 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
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/.ImportantIf 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
vdc1to the newly created/datadirectory, runsudo mkdir /data && sudo mount /dev/vdc1 /data.Verify that the file system was mounted.
Run the
sudo lsblkcommand. If theMOUNTPOINTcolumn for the target device displays a mount point, the file system is mounted successfully.ImportantThis 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.
To prevent accidental operations, we recommend that you back up the
/etc/fstabfile.sudo cp /etc/fstab /etc/fstab.bakConfigure the mount information.
Get information about the target data disk.
Run the command
sudo lsblk -fand 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 -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. For example, for the data disk
vdb, the target device name isvdb1, the mount directory is/mnt, and the file system type isext4.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 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_point>, and <file_system_type> in the command with the information that you obtained in the previous step, and then run the command.
ImportantWhen 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 isext4:sudo sh -c "echo `sudo blkid /dev/vdb1 | awk '{print \$2}' | sed 's/\"//g'` /mnt ext4 defaults 0 0 >> /etc/fstab"
Verify the automatic mount configuration.
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>Reload the
/etc/fstabfile.Run the following command to mount any unmounted file systems according to the
/etc/fstabconfiguration file.sudo mount -aIf an error occurs, you can use the
sudo mv /etc/fstab.bak /etc/fstabcommand to quickly restore the /etc/fstab file.Verify the mount.
Run the
sudo lsblkcommand. If the output shows a mount directory for the target device in theMOUNTPOINTcolumn, the configuration is successful.
Related documents
To resize an existing cloud disk, see Resize a cloud disk (Linux).
To initialize a data disk for a Windows instance, see Initialize a data disk (Windows).
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?
ImportantMBR does not support capacities over 2 TiB. If your disk capacity is or will be larger than 2 TiB, use the GPT partition format.
Connect to the ECS instance.
Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.
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.
Create an MBR partition.
Start the
fdiskutility.Set
<device name>to the device name that you obtained in Step 2.a.sudo fdisk -u /dev/<device_name>Enter
nto create a new partition.This example describes how to create a primary partition. Enter
pto create a primary partition.prepresents the primary partition.erepresents an extended partition.
Enter the partition number and press the
Enterkey.The partition number for a primary partition can be from 1 to 4.
Enter the starting sector number, and press the
Enterkey.This is the partition's starting sector number. The system displays the valid range. Press
Enterto use the default value, or enter a custom value from this range.Enter the last sector number and press the
Enterkey.This is the partition's ending sector number. The system displays the valid range. Press
Enterto 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.Enter
pand check the Device field to identify the planned new partition.Enter
wto write the partition results to the partition table.If you make a mistake during the partitioning operation, enter
qto exit fdisk. Your changes will not be saved, and you can restart the partitioning process.
Run the
sudo lsblkcommand 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 alignederror 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
partedinterface, enter the following command to delete the misaligned partition.You can view the <Error partition number> using the
printcommand.ImportantBefore you delete a partition, make sure it contains no data or that you have backed up the data.
rm <incorrect_partition_number>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.
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. 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.