All Products
Search
Document Center

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

Last Updated:Apr 01, 2024

Before you can store, read, and write data on a new data disk that is attached to an Elastic Compute Service (ECS) instance, you must initialize the data disk. The initialization operations include partitioning the disk, mounting file systems on the disk, and bringing the disk online. This topic describes how to initialize a data disk whose size exceeds 2 TiB on a Windows ECS instance or Linux ECS instance.

Prerequisites

A data disk is attached to an ECS instance. For more information, see Attach a data disk.

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

  • Device name: /dev/vdc

    For information about device names, see Overview.

  • Size: 3 TiB

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 in this step is suitable for Linux distributions such as CentOS. For other Linux distributions, modify the command based on your package management software. For example, run the apt-get install <Package name> command for Debian or Ubuntu.

  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 primary partition and specify the start and end positions of the partition.

      In this example, a primary partition named primary is created on the data disk and 100% of the disk capacity is allocated to the primary partition.

      mkpart primary 1 100%
    4. Run the following command to check whether the partition is aligned.

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

      align-check optimal 1

      If the partition is aligned, the following sample 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 issue, see the FAQ about initializing disks section in the "Initialize a data disk whose size does not exceed 2 TiB on a Linux instance" topic.

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

      print
    6. 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
    • 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 /etc/fstab file and mount the partition

If you want the system to mount the data disk on instance startup, write the information about the disk partition to /etc/fstab and configure the disk partition to automatically mount on instance startup.

Important

We recommend that you use a universally unique identifier (UUID) to reference the new partition in /etc/fstab. Operations that are performed on a disk, such as release operations, may cause the device names of other disks to change. If you use the device name of a data disk in /etc/fstab, your stored data may be affected if the device name is changed.

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

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

    Root users

    Run the following command to modify the /etc/fstab file:

    echo `blkid /dev/vdc1 | awk '{print $2}' | sed 's/\"//g'` /test01 ext4 defaults 0 0 >> /etc/fstab

    Take note of the following parameters in the command:

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

    • /test01: the mount point of the partition. Replace /test01 with the actual mount point.

      Important

      You need to specify or create a directory as the mount point based on the actual environment. You can mount the partition to an existing directory, or run the mkdir command to create a directory and then mount the partition to the new directory.

    • ext4: the file system type of the partition. Replace ext4 with the type of the created file system.

    • defaults: the mount parameters of the file system. Configure parameters based your business requirements to ensure data security and high performance of the file system. For more information, see Run the mount commands to mount Ext4 file systems.

    Note
    • The Ubuntu 12.04 operating system does not support barriers. You must run the echo `blkid /dev/vdc1 | awk '{print $2}' | sed 's/\"//g'` /test01 ext4 barrier=0 0 0 >> /etc/fstab command to write the information about the new partition to /etc/fstab. If your instance does not run an Ubuntu 12.04 operating system, ignore the note.

    • If a disk has multiple consecutive partitions, run a command specific to each partition to write partition information to /etc/fstab. For example, for the /dev/vdc data disk that has the /dev/vdc1 and /dev/vdc2 partitions, separately run the following commands:

      echo `blkid /dev/vdc1 | awk '{print $2}' | sed 's/\"//g'` <Mount point of /dev/vdc1> <File system type of /dev/vdc1> defaults 0 0 >> /etc/fstab
      echo `blkid /dev/vdc2 | awk '{print $2}' | sed 's/\"//g'` <Mount point of /dev/vdc2> <File system type of /dev/vdc2> defaults 0 0 >> /etc/fstab

    Regular users

    Modify the /etc/fstab file. For more information, see Configure UUIDs in the fstab file to automatically mount data disks.

  3. Run the following command to check the information about the new partition in /etc/fstab:

    cat /etc/fstab

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

    image

  4. 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
  5. Run the following command to check whether the file system is mounted as expected:

    df -h

    The following sample command output is returned. If the file system is mounted, the 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

For information about how to initialize a disk whose size does not exceed 2 TiB, see Initialize a data disk whose size does not exceed 2 TiB on a Linux instance and Initialize a data disk whose size does not exceed 2 TiB on a Windows instance.