After a new disk is mounted to an ENS instance, it cannot be used to store data immediately. You must perform initialization operations, such as creating partitions and mounting a file system, before the disk can be used.
Before you begin
Initializing a disk is a high-risk operation. Proceed with caution.
This procedure is for new data disks only. If your data disk already contains data, you must create a snapshot of the disk to prevent data loss.
Only initialize data disks. Do not initialize a system disk. Forcibly initializing a system disk by using third-party tools can cause system crashes or data loss. If you resize a system disk, you can extend the existing partition or create a new one. For more information, see resize a disk (Linux).
Scenarios
If the capacity of the system disk specified when you created an ENS instance is the same as the system disk image capacity, the system has already partitioned the disk and created a file system. No initialization is required.
If the capacity of the system disk that you specified when you created an ENS instance is larger than the system disk image capacity, you must initialize the extra space.
Data disks created with an instance: These disks are automatically attached to the ENS instance. You can proceed directly to initializing the disk.
Data disks purchased separately: You must first attach the disk to an ENS instance before you can initialize it.
If your entire disk is presented as a single partition (for example, /dev/vdb) and you do not need to create logical partitions (for example, /dev/vdb1, /dev/vdb2, etc.), you can create a file system directly on the disk during initialization.
Procedure
Initialize a Linux data disk
This example uses CentOS 7.9.
Connect and view the data disk
Remotely connect to an ENS instance.
Run the following command to view available disks and their device names.
sudo fdisk -luThe following sample output indicates that three disks are attached to the ENS instance:
/dev/vdais the system disk. A system disk that is created with an instance is initialized by default and does not require further initialization./dev/vdband/dev/vdcare new data disks.

Create a GPT partition
Run the following command to install the Parted tool.
sudo yum install -y partedUse Parted to partition the data disk.
Run the following command to start partitioning. This operation uses the data disk
/dev/vdbas an example.sudo parted /dev/vdbIn this example,
/dev/vdbis the device name of the data disk to be partitioned. Replace it based on your actual environment.At the Parted prompt, enter the following command to set the partition table type to GPT.
mklabel gptEnter the following command to create a partition and specify its start and end positions.
mkpart <partition_name> <start_position> <end_position>ImportantTo ensure the partition is 4 KiB-aligned for optimal disk performance, use binary units such as MiB or GiB for the start and end positions.
Replace <partition_name>, <start_position>, and <end_position> with the values you want.
Single-partition example: To create one primary partition named
primarythat starts at 1 MiB and uses 100% of the disk capacity, run the following command:mkpart primary 1MiB 100%Multi-partition example: To create a 20 GiB partition named
primaryand a second partition namedsecondarythat uses the remaining capacity, run the following commands:mkpart primary 1MiB 20GiB mkpart secondary 20GiB 100%
Run the following command to check if the partition is aligned.
Here,
1is the corresponding partition number. We recommend that you perform partition alignment to obtain better disk performance.align-check optimal 1A successful alignment check returns the following output:
1 alignedRun the
printcommand to view the partition table.print(Optional) If you made a mistake, run
rm <partition_number>to delete the incorrect partition, and then repeat the preceding steps.ImportantBefore you delete a partition, make sure that it contains no data or that you have backed up the data.
Enter
quitto exit the Parted tool.quit
Run the
partprobecommand to make the operating system reread the partition table.partprobeRun the following command to view the information about the new partition. In this example, the data disk is
/dev/vdb.sudo fdisk -lu /dev/vdbIn this example,
/dev/vdbis the device name of the data disk. Replace it based on your actual environment.The output is as follows. If
Disk label typeis gpt, the new partition is created successfully.
Create and mount a file system
Regardless of whether a disk is partitioned, you must create and mount a file system on it before use. This allows the operating system to recognize and use the disk. Different file systems support different partition sizes, so choose one based on your requirements.
Run the following command to install the e2fsprogs tool.
sudo yum install -y e2fsprogsNoteThe yum command in this step is for Linux distributions such as CentOS. For other Linux distributions, modify the installation command based on the package manager that you use. For example, on Debian or Ubuntu, use
apt-get install <package_name>.Run one of the following commands to create a file system. The following examples show how to create an ext4 and an xfs file system.
Ext4 file system
For example, to create an ext4 file system for the partition
/dev/vdb1, run the following command:sudo mkfs -t ext4 /dev/vdb1In this example,
/dev/vdb1is the partition name of the data disk. Replace it with your actual partition name.For example, to create an ext4 file system on the raw device
/dev/vdc, run the following command:sudo mkfs -t ext4 /dev/vdcHere,
/dev/vdcis the raw device name. Replace it with your actual raw device name.
Xfs file system
For example, to create an xfs file system on the partition
/dev/vdb1, run the following command:sudo mkfs -t xfs /dev/vdb1In this case,
/dev/vdb1is the partition name of the data disk. Replace it with your actual partition name.For example, to create an xfs file system on the raw device
/dev/vdc, run the following command:sudo mkfs -t xfs /dev/vdcIn this example,
/dev/vdcis the raw device name. Replace it with the actual raw device name.
Run the following command to mount the file system.
For example, to mount the partition
/dev/vdb1to the /mnt directory, run the following command:sudo mount /dev/vdb1 /mnt/dev/vdb1is the name of the data disk partition. Replace it with the actual partition name in your environment./mntis the mount point for the partition. The mount point can be an existing directory that contains no data, or a new directory that you create by running thesudo mkdir -p <new directory>command. For example,sudo mkdir -p /data.For example, to mount the raw device
/dev/vdcto the /tmp directory, run the following command:sudo mount /dev/vdc /tmp/dev/vdcis the raw device name. Replace it based on your actual environment./tmpis the mount point for the partition. The mount point can be an existing directory that contains no data, or you can run thesudo mkdir -p <new_directory>command to create a new directory to use as the mount point. For example,sudo mkdir -p /data.
Run the following command to verify that the mount result is as expected.
df -Th
Configure automatic mount on startup
You can add the new partition information to the /etc/fstab file to ensure that the disk partition is automatically mounted on startup.
Run the following command to back up the
/etc/fstabfile.sudo cp /etc/fstab /etc/fstab.bakAdd the new partition information to
/etc/fstab.sudo sh -c "echo `blkid /dev/vdb1 | awk '{print \$2}' | sed 's/\"//g'` /mnt ext4 defaults 0 0 >> /etc/fstab"Parameters:
/dev/vdb1: The name of the data disk partition. You must replace this value with the actual partition name for your environment. You can run thedf -Thcommand to obtain the partition name./mnt: The mount point of the partition. Replace this with the configured mount point. (You can obtain it by running thedf -Thcommand.)ext4: The file system type of the partition. Replace this with the file system type of your partition (obtained by using thedf -Thcommand).defaults: The mount parameters for the file system. You can select the parameters based on your requirements. For more information, see the fstab documentation.
Run the following command to view the new partition information in
/etc/fstab.cat /etc/fstabIf the command output contains the new partition information, the entry was successfully added.

Run the following commands to test the automatic mount configuration.
sudo umount /dev/vdb1 sudo mount -a mount | grep /mnt
Initialize a Windows data disk
Procedure
Remotely connect to an ENS instance.
On the Windows Server desktop, right-click the
icon, and then click Disk Management.
Find the data disk to be initialized (in this example, Disk 1), which is in the Offline state.

Right-click a blank area of Disk 1 and select Online.
After the disk is brought online, the status of Disk 1 is Not Initialized.

Right-click the blank area of Disk 1, and from the shortcut menu, select Initialize Disk.
In the Initialize Disk dialog box, select the target disk and the partition style, and then click OK.
ImportantMBR partition tables do not support disks larger than 2 TiB. If your disk is larger than 2 TiB, or if you plan to resize it to be larger than 2 TiB in the future, you must use the GPT partition style.

Right-click the Unallocated area of Disk 1, and select New Simple Volume.

In the New Simple Volume Wizard dialog box, follow the wizard to complete the initialization.
In the Specify Volume Size dialog box, set Simple Volume Size, and then click Next.
If you want to create a single partition that uses the entire disk, use the default value. Otherwise, specify a smaller size to create multiple partitions on Disk 1.

In the Assign Drive Letter or Path dialog box, select Assign the following drive letter, select a drive letter (for example, D), and click Next.

In the Format Partition dialog box, select Format this volume with the following settings, configure the format settings, and then click Next.
ImportantChoose the allocation unit size carefully. You cannot change this setting after you format the volume. For more information about disk capacity limits, see NTFS overview.
If you plan to resize the disk to a capacity between 16 TiB and 32 TiB (inclusive), select 8192.
If you plan to resize the disk to a capacity between 32 TiB and 64 TiB (inclusive), select 16K.
Otherwise, keep the default value.

Review the new simple volume information and click Finish to close the New Simple Volume Wizard.
Verify the result
After initialization, Disk 1 in Disk Management appears as shown in the following figure.
You can now see the new drive, New Volume (D:), in This PC. The data disk is ready to use.