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 that is larger than 2 TiB in size 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

The example in this topic uses an ECS instance and a data disk that have the configurations described in the following table. Operations may vary based on actual conditions.

Operating systemResourceDescription
LinuxImage used by the ECS instanceAlibaba Cloud Linux 3.2104 64-bit public image
Data disk
WindowsImage used by the ECS instanceWindows Server 2012 R2 64-bit
Data disk
  • Device name: Disk 2
  • Size: 3 TiB
Note 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 up to 2 TiB in size on a Windows instance.

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

This section describes how to initialize a new data disk that is larger than 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:
    fdisk -l
    A command output similar to the following one is returned, which indicates that the instance has two disks: the /dev/vda system disk and the /dev/vdb data disk. View the information of the data disk

Step 2: Create a GUID partition table (GPT) partition for the data disk

  1. Run the following command to install Parted:
    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 start partitioning the data disk. In this example, the /dev/vdb data disk is used.
      parted /dev/vdb
      /dev/vdb specifies the device name of the data disk. Replace it with the actual device name.
    2. Run the following command in the Parted interactive command-line prompt to set the partition format to GPT:
      mklabel gpt
    3. Run the following command to create a primary partition and specify the start sector and end sector for the partition.
      In this example, a primary partition named primary is created for 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. We recommend that you align partitions for better disk performance.
      align-check optimal 1
      If the partition is aligned, a command output similar to the following one 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 FAQ about initializing disks.
    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 partition process by using Parted. Partitioning result
  3. Run the following command to re-read the partition table:
    partprobe
  4. Run the following command to view the new partition. In this example, the /dev/vdb data disk is used.
    fdisk -lu /dev/vdb
    /dev/vdb specifies the device name of the data disk. Replace it with the actual device name.

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 suits your needs.

  1. Run the following command to install e2fsprogs:
    yum install -y e2fsprogs
    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. Run one of the following commands to create a file system. In this example, an ext4 file system and an xfs file system are created.
    • Create an ext4 file system
      mkfs -t ext4 /dev/vdb1
      /dev/vdb1 specifies the partition name of the data disk. Replace it 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 may be earlier than 1.42. Upgrade the version of e2fsprogs to 1.42 or later. For information about how to upgrade e2fsprogs, see the "How do I upgrade e2fsprogs on a Linux instance?" section in Initialize a data disk whose size does not exceed 2 TiB on a Linux instance.
      • 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 information about how to disable the lazy init feature, see the "How do I disable the lazy init feature on a Linux instance?" section in Initialize a data disk whose size does not exceed 2 TiB on a Linux instance.
    • Create an xfs file system
      mkfs -t xfs /dev/vdb1
      /dev/vdb1 specifies the partition name of the data disk. Replace it with the actual partition name.
    A command output similar to the following one is returned, which indicates that an ext4 file system is created for the /dev/vdb1 partition of the data disk. Create a file system

(Optional) 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 of 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 the 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 /etc/fstab:
    cp /etc/fstab /etc/fstab.bak
  2. Write the information of the new partition to /etc/fstab.
    • If you are a root user, you can run the following command to modify /etc/fstab:
      echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /mnt ext4 defaults 0 0 >> /etc/fstab
      Description of the parameters in this command:
      • /dev/vdb1: the partition name of the data disk. Replace it with the actual partition name.
      • /mnt: the mount point of the partition. Replace it with the actual mount point.
      • ext4: the file system type of the partition. Replace it with the file system type of the created file system.
      Note Ubuntu 12.04 operating systems do not support barriers. You must run the echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /mnt ext4 barrier=0 0 0 >> /etc/fstab command to write the information of the new partition to /etc/fstab. If your instance does not run an Ubuntu 12.04 operating system, ignore the note.
    • If you are a common user, you can modify /etc/fstab. For more information, see Configure UUIDs in the fstab file to automatically attach data disks.
  3. Run the following command to check the information of the new partition in /etc/fstab:
    cat /etc/fstab
    A command output similar to the following one is returned, which indicates that the information of the new partition is written to /etc/fstab. Information of the new partition
  4. Run the following command to mount the file system that is configured in /etc/fstab. If the file system is correctly configured in /etc/fstab, no error is reported.
    mount -a
  5. Run the following command to check whether the file system is mounted as expected:
    df -h
    A command output similar to the following one is returned. If the file system is mounted, the information of the new file system is displayed. Check the result

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 that is larger than 2 TiB on a Windows instance

  1. Connect to the instance.
  2. On the Windows Server desktop, right-click the Start icon icon and select Disk Management.
  3. Find the data disk that you want to initialize and is in the Offline state. In this example, Disk 2 is used.
  4. Right-click the blank area around Disk 2 and select Online.
    When Disk 2 goes 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 disk partition format, and then click OK.
    For more information about partition formats, see the "Partition formats" section in Partition formats.
  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, set Simple volume size in MB and click Next.
      If you want to create only a primary partition, use the default value. If you want to create multiple partitions for Disk 2, specify a simple volume size based on your needs.
    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 for 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 of the new simple volume. Then, click Finish to close the New Simple Volume Wizard window.

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