All Products
Search
Document Center

Elastic Compute Service:Initialize a data disk whose size exceeds 2 TiB

Last Updated:Dec 09, 2024

If you attach a new data disk (empty data disk) to an Elastic Compute Service (ECS) instance, you cannot directly use the disk to store data. To use the disk, you must initialize the disk for the operating system to recognize the disk. If the data disk is larger than 2 TiB in size and you want to store and manage data of various categories in different partitions, you can perform the initialization operations in this topic. The initialization operations include partitioning the disk and mounting file systems on the disk.

Note

You can perform the initialization operation only on new data disks that do not have data. For more information, see the Scenarios section of the "Overview" topic.

Prerequisites

A data disk is attached to a Linux ECS instance and is in the In Use state. For more information, see Attach a data disk.

Note

A data disk created together with a Linux ECS instance is already attached to the instance.

Background information

In the example, an ECS instance and a data disk that have the configurations described in the following table are used. Operations may vary based on actual conditions.

Operating system

Resource

Description

Linux

Image used by the ECS instance

Alibaba Cloud Linux 3.2104 64-bit public image

Data disk

Windows

Image used by the ECS instance

Windows Server 2016 64-bit

Data disk

  • Device name: Disk 2

  • Size: 3 TiB

Initialize a data disk whose size exceeds 2 TiB on a Linux instance

This section describes how to initialize a new data disk whose size exceeds 2 TiB on a Linux instance.

Step 1: Connect to the instance and view the data disk

  1. Connect to the instance.

  2. Run the following command to obtain the device name of the data disk that you want to initialize:

    sudo fdisk -l

    The following sample command output indicates that the instance has three disks. The device name of the system disk is /dev/vda and the device name of the new data disk is /dev/vdc.

    image

Step 2: Create a GPT partition on the data disk

  1. Run the following command to install Parted:

    sudo yum install -y parted
    Note

    The yum command used in this step is applicable to Linux distributions such as CentOS. For other Linux distributions, modify the command based on your package management software. For example, run the following commands to install Parted on Debian or Ubuntu:

    sudo apt-get update
    sudo apt-get install -y parted
  2. Use Parted to partition the data disk.

    1. Run the following command to partition the data disk. In this example, the /dev/vdc data disk is partitioned.

      sudo parted /dev/vdc

      /dev/vdc is the device name of the data disk. Replace /dev/vdc with the actual device name of your data disk.

    2. On the Parted command line, run the following command to set the partition format to GUID partition table (GPT):

      mklabel gpt
    3. Run the following command to create a partition and specify the start and end positions of the partition:

      mkpart <Partition name> <Start position> <End position>
      Important

      Use binary units, such as MiB and GiB, for the start and end positions of the partition to ensure that the partition is 4,096 byte-aligned. Otherwise, the partition may not be aligned, which significantly affects disk performance.

      Replace <Partition name>, <Start position>, and <End position> with actual values.

      • Example for creating only one partition on a disk: Run the following command to create a primary partition named primary that starts at 1 MiB and to which 100% of the disk capacity is allocated:

        mkpart primary 1MiB 100%
      • Example for creating multiple partitions on a disk. Run the following commands to create a partition named primary to which 20 GiB of the disk capacity is allocated and a partition named secondary to which the remaining disk capacity is allocated:

        mkpart primary 1MiB 20GiB
        mkpart secondary 20GiB 100%
    4. (Conditionally required) If you want to create multiple partitions on the data disk, repeat Step c.

    5. Run the following command to check whether the partition is aligned.

      The partition number of the partition is 1. To optimize disk performance, we recommend that you align partitions.

      align-check optimal 1

      If the partition is aligned, the following command output is returned:

      1 aligned
      Note

      If the partition is not aligned, 1 not aligned is returned. For information about how to resolve the preceding issue, see the FAQ about disk initialization section in the "Initialize a data disk whose size does not exceed 2 TiB on a Linux instance" topic.

    6. Run the following command to check the partition table:

      print
    7. Run the following command to exit Parted:

      quit

    The following figure shows the partitioning process by using Parted.分区结果

  3. Run the following command to reread the partition table:

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

    sudo fdisk -lu /dev/vdc

    /dev/vdc is the device name of the data disk. Replace /dev/vdc with the actual device name of your data disk.

    image

Step 3: Create a file system for the partition

Create a file system for the new partition. Partition sizes vary based on file system types. Create a file system that meets your business requirements.

  1. Run one of the following commands to create a file system. In the examples, an Ext4 file system and an XFS file system are created.

    • Create an Ext4 file system.

      sudo mkfs -t ext4 /dev/vdc1

      /dev/vdc1 is the partition name of the data disk. Replace /dev/vdc1 with the actual partition name.

      Important
      • If an error is reported when you create an Ext4 file system for a 16-TiB data disk, the version of the e2fsprogs package that you use may be earlier than 1.42. Upgrade the version of e2fsprogs to 1.42 or later. For more information, see the How do I upgrade e2fsprogs on a Linux instance? section in the "Initialize a data disk whose size does not exceed 2 TiB on a Linux instance" topic.

      • The lazy init feature of Ext4 file systems affects the I/O performance of data disks. You can disable the lazy init feature of Ext4 file systems. For more information, see the How do I disable the lazy init feature on a Linux instance? section in the "Initialize a data disk whose size does not exceed 2 TiB on a Linux instance" topic.

    • Create an XFS file system.

      sudo mkfs -t xfs /dev/vdc1

      /dev/vdc1 is the partition name of the data disk. Replace /dev/vdc1 with the actual partition name.

    The following sample command output indicates that an Ext4 file system is created for the /dev/vdc1 partition of the data disk.

    image

Step 4: Configure the disk partition to automatically mount on instance startup

If you want the disk partition to automatically mount on instance startup, write information about the disk partition to the /etc/fstab file and add the mount information of the disk partition to the /etc/fstab file based on your business requirements.

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

    sudo cp /etc/fstab /etc/fstab.bak
  2. Write information about the new partition to the /etc/fstab file.

    sudo sh -c "echo `blkid /dev/vdb1 | awk '{print \$2}' | sed 's/\"//g'` /mnt ext4 defaults 0 0 >> /etc/fstab"

    Take note of the following parameters in the preceding command:

    • /dev/vdb1: the partition name of the data disk. Replace /dev/vdb1 with an actual partition name. You can run the df -Th command to obtain the names of partitions.

    • /mnt: the mount point of the partition. Replace /mnt with an actual mount point. You can run the df -Th command to obtain the mount points of partitions.

    • ext4: the file system type of the partition. Replace ext4 with the type of the file system that you created. You can run the df -Th command to obtain the file system types of partitions.

    • defaults: the mount parameters of the file system. Configure mount parameters based on your business requirements. For more information, see fstab.

    Note

    Ubuntu 12.04 does not support barriers. You must run the sudo sh -c "echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /mnt ext4 barrier=0 0 0 >> /etc/fstab" command to write information about the disk partition to the /etc/fstab file.

  3. (Conditionally required) If a data disk has multiple consecutive partitions, run a command specific to each partition to write partition information to the /etc/fstab file.

    For example, for the /dev/vdb data disk that has the /dev/vdb1 and /dev/vdb2 partitions, separately run the following commands:

    sudo sh -c "echo `blkid /dev/vdb1 | awk '{print \$2}' | sed 's/\"//g'` <Mount point of the /dev/vdb1 partition> <File system type of the /dev/vdb1 partition> defaults 0 0 >> /etc/fstab"
    sudo sh -c "echo `blkid /dev/vdb2 | awk '{print \$2}' | sed 's/\"//g'` <Mount point of the /dev/vdb2 partition> <File system type of the /dev/vdb2 partition> defaults 0 0 >> /etc/fstab"
  4. Run the following command to check information about the new partition in the /etc/fstab file:

    cat /etc/fstab

    The following sample command output indicates that the information about the new partition is written to the /etc/fstab file.

    image

    Note

    If the information about the partition contained in the command output is incorrect, you can delete the incorrect information from the /etc/fstab file and add the correct information about the partition to the file. For more information, see Configure UUIDs in the fstab file to automatically mount data disks.

  5. Run the following command to mount the file system that is configured in the /etc/fstab file. If the file system is correctly configured in /etc/fstab, no errors are reported.

    sudo mount -a
  6. Run the following commands to check whether the partition is automatically mounted:

    sudo umount /dev/vdb1
    sudo mount -a
    mount | grep /mnt

    The following command output is returned. If a file system is mounted, information about the file system is displayed.

    image

The 3 TiB data disk is initialized.

Initialize a data disk that is larger than 2 TiB on a Windows instance

This section describes how to initialize a new data disk whose size exceeds 2 TiB on a Windows instance

  1. Connect to the instance.

  2. On the Windows desktop, right-click the 开始图标 icon and select Disk Management.

    磁盘管理

  3. Find the data disk in the Offline state that you want to initialize. In this example, Disk 2 is used.

    磁盘2

  4. Right-click the blank area around Disk 2 and select Online.

    When Disk 2 comes online, the disk enters the Not Initialized state. 未初始化

  5. Right-click the blank area around Disk 2 and select Initialize Disk.

  6. In the Initialize Disk dialog box, select Disk 2, select GPT (GUID Partition Table) as the partition format, and then click OK.

    For more information about partition formats, see the Partition formats section in the "Overview" topic. GPT分区

  7. In the Disk Management window, right-click the Unallocated section of Disk 2, and then select New Simple Volume to create a 3 TiB volume in the NTFS format.

    新建卷

  8. In the New Simple Volume Wizard window, click Next and follow the wizard to perform initialization operations.

    1. In the Specify Volume Size step, configure the Simple volume size in MB parameter and click Next.

      If you want to create only a primary partition, use the default value. If you want to create multiple partitions on Disk 2, specify a simple volume size based on your business requirements. 指定卷大小

    2. In the Assign Drive Letter or Path step, select Assign the following drive letter, select a drive letter, and then click Next. In this example, E is selected as the drive letter.

      分配驱动号

    3. In the Format Partition step, select Format this volume with the following settings, configure formatting settings, and then click Next.

      设置格式化信息

    4. View the information about the new simple volume. Then, click Finish to close the New Simple Volume Wizard window.

    After Disk 2 is partitioned and formatted, the status of the disk is displayed in the Disk Management window.新磁盘状态

    In the This PC window, a new drive named New Volume (E:) is displayed. The data disk is ready for use.新建驱动器

References

  • If you want to use a data disk as a raw disk without the need to partition the disk, you need to only create a file system for the raw disk when you initialize the disk. For more information, see Create a file system on a raw disk.

  • If a data disk does not have sufficient storage space, you can extend the capacity of the disk to increase the storage space. For information about how to extend a data disk, see Overview.