All Products
Search
Document Center

ENS:Initialize a disk

Last Updated:Apr 08, 2026

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

Important

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.

Note

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

  1. Remotely connect to an ENS instance.

  2. Run the following command to view available disks and their device names.

    sudo fdisk -lu

    The following sample output indicates that three disks are attached to the ENS instance:

    • /dev/vda is the system disk. A system disk that is created with an instance is initialized by default and does not require further initialization.

    • /dev/vdb and /dev/vdc are new data disks.

    image

Create a GPT partition

  1. Run the following command to install the Parted tool.

    sudo yum install -y parted
  2. Use Parted to partition the data disk.

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

      sudo parted /dev/vdb

      In this example, /dev/vdb is the device name of the data disk to be partitioned. Replace it based on your actual environment.

    2. At the Parted prompt, enter the following command to set the partition table type to GPT.

      mklabel gpt
    3. Enter the following command to create a partition and specify its start and end positions.

      mkpart <partition_name> <start_position> <end_position>
      Important

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

      1. Single-partition example: To create one primary partition named primary that starts at 1 MiB and uses 100% of the disk capacity, run the following command:

        mkpart primary 1MiB 100%
      2. Multi-partition example: To create a 20 GiB partition named primary and a second partition named secondary that uses the remaining capacity, run the following commands:

        mkpart primary 1MiB 20GiB
        mkpart secondary 20GiB 100%
    4. Run the following command to check if the partition is aligned.

      Here, 1 is the corresponding partition number. We recommend that you perform partition alignment to obtain better disk performance.

      align-check optimal 1

      A successful alignment check returns the following output:

      1 aligned
    5. Run the print command to view the partition table.

      print
    6. (Optional) If you made a mistake, run rm <partition_number> to delete the incorrect partition, and then repeat the preceding steps.

      Important

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

    7. Enter quit to exit the Parted tool.

      quit

      image

  3. Run the partprobe command to make the operating system reread the partition table.

    partprobe
  4. Run the following command to view the information about the new partition. In this example, the data disk is /dev/vdb.

    sudo fdisk -lu /dev/vdb

    In this example, /dev/vdb is the device name of the data disk. Replace it based on your actual environment.

    The output is as follows. If Disk label type is gpt, the new partition is created successfully.

    image

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.

  1. Run the following command to install the e2fsprogs tool.

    sudo yum install -y e2fsprogs
    Note

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

  2. 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/vdb1

      In this example, /dev/vdb1 is 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/vdc

      Here, /dev/vdc is 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/vdb1

      In this case, /dev/vdb1 is 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/vdc

      In this example, /dev/vdc is the raw device name. Replace it with the actual raw device name.

  3. Run the following command to mount the file system.

    • For example, to mount the partition /dev/vdb1 to the /mnt directory, run the following command:

      sudo mount /dev/vdb1 /mnt

      /dev/vdb1 is the name of the data disk partition. Replace it with the actual partition name in your environment. /mnt is 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 the sudo mkdir -p <new directory> command. For example, sudo mkdir -p /data.

    • For example, to mount the raw device /dev/vdc to the /tmp directory, run the following command:

      sudo mount /dev/vdc /tmp

      /dev/vdc is the raw device name. Replace it based on your actual environment. /tmp is the mount point for the partition. The mount point can be an existing directory that contains no data, or you can run the sudo mkdir -p <new_directory> command to create a new directory to use as the mount point. For example, sudo mkdir -p /data.

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

  1. Run the following command to back up the /etc/fstab file.

    sudo cp /etc/fstab /etc/fstab.bak
  2. Add 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 the df -Th command 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 the df -Th command.)

    • ext4: The file system type of the partition. Replace this with the file system type of your partition (obtained by using the df -Th command).

    • defaults: The mount parameters for the file system. You can select the parameters based on your requirements. For more information, see the fstab documentation.

  3. Run the following command to view the new partition information in /etc/fstab.

    cat /etc/fstab

    If the command output contains the new partition information, the entry was successfully added.

    image.png

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

  1. Remotely connect to an ENS instance.

  2. On the Windows Server desktop, right-click the Start icon icon, and then click Disk Management.

    磁盘管理

  3. Find the data disk to be initialized (in this example, Disk 1), which is in the Offline state.

    脱机状态

  4. 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.Not Initialized

  5. Right-click the blank area of Disk 1, and from the shortcut menu, select Initialize Disk.

  6. In the Initialize Disk dialog box, select the target disk and the partition style, and then click OK.

    Important

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

    选择分区

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

    新建简单卷

  8. In the New Simple Volume Wizard dialog box, follow the wizard to complete the initialization.

    1. 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.指定卷大小

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

      分配驱动号

    3. In the Format Partition dialog box, select Format this volume with the following settings, configure the format settings, and then click Next.

      Important

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

      设置格式化信息

    4. 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.新建磁盘