This topic describes how to partition and format a data disk larger than 2 TiB in different operating systems.

Prerequisites

  • A data disk is attached to an ECS instance. For more information, see Attach a data disk.
  • A remote connection to the ECS instance is established. For more information about how to connect to an ECS instance, see Overview.

Background information

  • The amount of time required to create a snapshot of a data disk is directly proportional to the volume of data on the data disk. The more data stored on the disk, the longer it takes to create the snapshot.
  • Alibaba Cloud Block Storage supports Master Boot Record (MBR) and GUID Partition Table (GPT) partition formats. MBR is applicable to data disks up to 2 TiB in size and can be used to create up to four primary partitions. If you want to partition a data disk larger than 2 TiB, you must use the GPT format.
    Notice Conversion between MBR and GPT may cause data loss. If you expect the resulting disk size to exceed 2 TiB when you create a disk from a snapshot or resize a disk, we recommend that you check whether the disk uses the MBR partition format. If the disk uses the MBR partition format and you want to retain disk data on your instance, we recommend that you create another data disk and attach the disk to the instance. Then, use the GPT partition format to format a new data disk, copy data from the original MBR data disk to the new data disk.
  • The following table describes the partition tools, partition formats, and file systems when you partition and format a data disk larger than 2 TiB.
    Operating system Partition tool Partition format File system
    Windows Disk Management GPT NTFS
    Linux parted GPT Ext4 or XFS

Partition and format a data disk on a Windows instance

The Windows Server 2008 R2 64-bit operating system is used as an example in the following section to describe how to partition and format a data disk larger than 2 TiB on a Windows instance:

  1. On the taskbar of Windows Server, click Server Manager.
  2. In the left-side navigation pane of the Server Manager window, choose Storage > Disk Management.
  3. Find the disk to be partitioned and formatted. Disk 4 is used in this example. The disk is in the Offline state.
  4. Right-click the space next to Disk 4, and select Online.
    After the disk comes online, Disk 4 enters the Not Initialized state.
  5. Right-click the space next to Disk 4, and select Initialize Disk.
  6. In the Initialize Disk dialog box, select Disk 4 and select GPT as the disk partition format.
  7. In the Disk Management window, right-click the Unallocated section of Disk 4, and then select New Simple Volume to create a 4 TiB volume in the NTFS format.
  8. In the New Simple Volume Wizard window, click Next, and follow these steps:
    1. Specify Volume Size: Specify the size of the simple volume. If you want to create a single primary partition, use the default value. Click Next. You can also divide Disk 4 into multiple partitions.
      Note Theoretically, the maximum volume of NTFS contains 2 64 -1 clusters. However, in Windows XP Pro, the maximum volume of NTFS is 2 32 -1 clusters. For example, if the cluster size is 64 KiB, then the maximum volume of NTFS is 256 TiB in size. If the cluster size is 4 KiB, the maximum volume of NTFS is 16 TiB in size. NTFS automatically selects the size of a cluster based on the disk capacity.
    2. Assign Drive Letter or Path: Select a drive letter. G is used in this example. Click Next.
    3. Format Partition: Select the formatting specifications such as the file system, allocation unit size, and volume label. Select Perform a quick format and Enable file and folder compression. In this example, Perform a quick format is selected. Click Next.
    4. After a new simple volume is created, click Finish to close the New Simple Volume Wizard window.

Convert the partition format of a data disk on a Windows instance

Notice Conversion between partition formats may cause data loss. Ensure that you have backed up the data on the disk before you convert to a different partition format.

The Windows Server 2012 R2 64-bit operating system is used as an example in the following section to describe how to convert the partition format of a 3 TiB data disk on a Window instance:

  1. On the Windows Server desktop, right-click the Start icon, and select Disk Management.
  2. Find the disk to be partitioned and formatted. Disk 2 is used in this example.
  3. Right-click a simple volume, and then select Delete Volume.
  4. Right-click the space next to Disk 2, and then select Convert to GPT Disk.
  5. 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.
  6. In the New Simple Volume Wizard window, click Next, and follow these steps:
    1. Specify Volume Size: Specify the size of the simple volume. If you want to create a single primary partition, use the default value. Click Next. You can also divide Disk 2 into multiple partitions.
      Note Theoretically, the maximum volume of NTFS contains 2 64 -1 clusters. However, in Windows XP Pro, the maximum volume of NTFS is 2 32 -1 clusters. For example, if the cluster size is 64 KiB, then the maximum volume of NTFS is 256 TiB in size. If the cluster size is 4 KiB, the maximum volume of NTFS is 16 TiB in size. NTFS automatically selects the size of a cluster based on the disk capacity.
    2. Assign Drive Letter or Path: Select a drive letter. E is used in this example. Click Next.
    3. Format Partition: Select the formatting settings including file system, allocation unit size, and volume label, and then select Perform a quick format and Enable file and folder compression. In this example, Perform a quick format is selected. Click Next.
    4. After a new simple volume is created, click Finish to close the New Simple Volume Wizard window.

Partition and format a data disk on a Linux instance

The CentOS 7.4 64-bit operating system is used as an example in the following section to describe how to use the parted and e2fsprogs tools to partition and format a data disk larger than 2 TiB on a Linux instance: In the example, the data disk to be processed is a newly created 3 TiB empty disk and its device name is /dev/vdb.

Prerequisites: The parted and e2fsprogs tools are installed on your Linux instance.
[root@ecshost~ ]# yum install -y parted
[root@ecshost~ ]# yum install -y e2fsprogs

Perform the following operations to partition and format a data disk larger than 2 TiB and mount the file system:

  1. Run the fdisk -l command to check whether the data disk exists.
    The expected command output contains the following similar information. If the command output does not contain the following information, the data disk is not attached to the instance.
    [root@ecshost~ ]# fdisk -l
    Disk /dev/vdb: 3221.2 GB, 3221225472000 bytes, 6291456000 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
  2. Run the parted /dev/vdb command to start to partition the disk.
    1. Run the mklabel gpt command to convert the partition format from MBR to GPT.
    2. Run the mkpart primary 1 100% command to create a primary partition, and specify the starting and ending sectors for the partition.
    3. Run the align-check optimal 1 command to check the partition alignment.
      Note If 1 not aligned is returned, the partition is not aligned. We recommend that you run the following commands and use the formula (<optimal_io_size>+<alignment_offset>)/<physical_block_size> to obtain the starting sector number to align partitions for optimal performance. For example, if the starting sector number is 1024, you can then run the mkpart primary 1024s 100% command to create a new primary partition.
      [root@ecshost~ ]# cat /sys/block/vdb/queue/optimal_io_size
      [root@ecshost~ ]# cat /sys/block/vdb/queue/minimum_io_size
      [root@ecshost~ ]# cat /sys/block/vdb/alignment_offset
      [root@ecshost~ ]# cat /sys/block/vdb/queue/physical_block_size
    4. Run the print command to view the partition table:
      (parted) mklabel gpt
      (parted) mkpart primary 1 100%
      (parted) align-check optimal 1
      1 aligned
      (parted) print
      Model: Virtio Block Device (virtblk)
      Disk /dev/vdb: 3221GB
      Sector size (logical/physical): 512B/512B
      Partition Table: gpt
      Disk Flags:
      Number Start End Size File system Name Flags
      1 17.4kB 3221GB 3221GB primary
    5. Run the quit command to exit the parted tool.
  3. Run the partprobe command to enable the system to re-read the partition table.
  4. Run one of the following commands to create a file system for the /dev/vdb1 partition:
    • Create an Ext4 file system.
      [root@ecshost~ ]# mkfs -t ext4 /dev/vdb1
    • Create an XFS file system.
      [root@ecshost~ ]# mkfs -t xfs /dev/vdb1
    Note
  5. Run the mkdir /test command to create a mount point named /test.
  6. Run the mount /dev/vdd1 /test command to mount the /dev/vdb1 partition to the /test mount point.
  7. Run the df -h command to view the current disk space and usage.
    If the command output shows information about the newly created file system, the mount operation is successful, and the new file system can be used.
    [root@ecshost~ ]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/vda1 40G 6.4G 31G 18% /
    devtmpfs 487M 0 487M 0% /dev
    tmpfs 497M 0 497M 0% /dev/shm
    tmpfs 497M 364K 496M 1% /run
    tmpfs 497M 0 497M 0% /sys/fs/cgroup
    tmpfs 100M 0 100M 0% /run/user/0
    /dev/vdb1 2.9T 89M 2.8T 1% /test
  8. (Optional) Write new partition information to /etc/fstab to enable automatic partition mounting when the instance is started.
    1. Run the cp /etc/fstab /etc/fstab.bak command to back up etc/fstab.
    2. Run the echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /test ext4 defaults 0 0 >> /etc/fstab command to write new partition information to /etc/fstab.
      Note We recommend that you use a universally unique identifier (UUID) in /etc/fstab to reference the new partition. You can run the blkid command to obtain the UUID of the new partition.
    3. Run the cat /etc/fstab command to check the information of /etc/fstab.
      If the new partition information is displayed in the command output, the write operation is successful.

The procedure to partition and format a 3 TiB data disk is completed.

Appendix 1: Update e2fsprogs on a Linux instance

If the disk capacity is 16 TiB, you must use e2fsprogs 1.42 or later to format its partitions to an Ext4 file system. If e2fsprogs of a version earlier than 1.42 is used, the following error occurs:

mkfs.ext4: Size of device /dev/vdb too big to be expressed in 32 bits using a blocksize of 4096.            

Perform the following operations to install a later version of e2fsprogs. In this example, e2fsprogs 1.42.8 is used.

  1. Run the rpm -qa | grep e2fsprogs command to check the current e2fsprogs version.

    If the version is earlier than 1.42, perform the following operations to update the software.

  2. Run the following command to download e2fsprogs 1.42.8. You can visit the e2fsprogs page to obtain the latest software package.
    wget https://www.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v1.42.8/e2fsprogs-1.42.8.tar.gz
  3. Run the following commands to compile the tool of a later version:
    tar xvzf e2fsprogs-1.42.8.tar.gz
    cd e2fsprogs-1.42.8
    ./configure
    make
    make install
  4. Run the following command to check whether e2fsprogs is updated:
    rpm -qa | grep e2fsprogs

Appendix 2: Disable the lazy init feature on a Linux instance

By default, the lazy init feature of an Ext4 file system is enabled. When this feature is enabled, the instance initiates a thread to continuously initialize the metadata of the Ext4 file system. After you partition and format a data disk while this feature is enabled, the IOPS of the disk may be reduced.

If you want to test the performance of a data disk immediately after the disk is partitioned and formatted, run the following command to disable the lazy init feature when you initialize the file system:

mke2fs -O 64bit,has_journal,extents,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize -E lazy_itable_init=0,lazy_journal_init=0   /dev/vdb1
Note If the lazy init feature is disabled, it may take a longer time to initialize the file system. For example, a file system of a 32 TiB data disk may take 10 to 30 minutes to initialize. Enable or disable the lazy init feature to suit your business.