All Products
Search
Document Center

Elastic Compute Service:Initialize a data disk that is larger than 2 TiB in size

Last Updated:Feb 22, 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 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

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/vdb

    For information about device names, see Overview.

  • Size: 3 TiB

Windows

Image used by the ECS instance

Windows Server 2012 R2 64-bit

Data disk

  • Device name: Disk 2

  • Size: 3 TiB

Note

For information about how to initialize a disk that does not exceed 2 TiB in size, 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 in size on a Linux instance

This section describes how to initialize a new data disk that is larger than 2 TiB in size 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:

    fdisk -l

    A command output similar to the following one is returned, which indicates that the instance has two disks: the system disk whose device name is /dev/vda and a new data disk whose device name is /dev/vdb.View the information of the data disk

Step 2: Create a GUID partition table (GPT) partition on 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 partition the data disk. In this example, the /dev/vdb data disk is partitioned.

      parted /dev/vdb

      /dev/vdb is the device name of the data disk. Replace it 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 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. 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 the "FAQ about initializing disks" section of Initialize a data disk whose size does not exceed 2 TiB on a Linux instance.

    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 is the device name of the data disk. Replace it with the actual device name of your data disk.

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

      mkfs -t ext4 /dev/vdb1

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

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 the etc/fstab file:

    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

      Take note of the following parameters in the 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. 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 it with the type of the created file system.

      Note
      • The Ubuntu 12.04 operating system does 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 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/vdb data disk that has the /dev/vdb1 and /dev/vdb2 partitions, run the following commands separately:

        echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` <Mount point of /dev/vdb1> <File system type of /dev/vdb1> defaults 0 0 >> /etc/fstab
        echo `blkid /dev/vdb2 | awk '{print $2}' | sed 's/\"//g'` <Mount point of /dev/vdb2> <File system type of /dev/vdb2> defaults 0 0 >> /etc/fstab
    • If you are a common user, you can manually 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 the /etc/fstab file. If the file system is correctly configured in /etc/fstab, no errors are 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 file system is displayed. Check the results

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 in size on a Windows instance

  1. Connect to the instance.

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

    Disk Management

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

    Disk 2

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

    When Disk 2 goes online, it enters the Not Initialized state. Not Initialized

  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 Partition formats. GPT partition

  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.

    New Simple Volume

  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 on Disk 2, specify a simple volume size based on your needs. Specify Volume Size

    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.

      Assign drive letters

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

      Configure formatting settings

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

    After Disk 2 is partitioned and formatted, its status is displayed in the Disk Management window.New disk status

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