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 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 2012 R2 64-bit |
Data disk |
|
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
- Connect to the instance. For more information, see Connect to a Linux instance by using a password or key.
- 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.
Step 2: Create a GUID partition table (GPT) partition for the data disk
- 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 theapt-get install <Package name>
command for Debian or Ubuntu. - Use Parted to partition the data disk. The following figure shows the partition process by using Parted.
- Run the following command to re-read the partition table:
partprobe
- 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.
- 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 theapt-get install <Package name>
command for Debian or Ubuntu. - 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 an ext4 file system
(Optional) Step 4: Configure the /etc/fstab file and mount the partition
- Run the following command to back up /etc/fstab:
cp /etc/fstab /etc/fstab.bak
- 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:
Description of the parameters in this command:echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /mnt ext4 defaults 0 0 >> /etc/fstab
/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 theecho `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.
- If you are a root user, you can run the following command to modify /etc/fstab:
- Run the following command to check the information of the new partition in /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.cat /etc/fstab
- 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
- Run the following command to check whether the file system is mounted as expected:
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.df -h
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
- Connect to the instance. For more information, see Connect to a Windows instance by using a password or key.
- On the Windows Server desktop, right-click the
icon and select Disk Management.
- Find the data disk that you want to initialize and is in the Offline state. In this example, Disk 2 is used.
- Right-click the blank area around Disk 2 and select Online. When Disk 2 goes online, the disk enters the Not Initialized state.
- Right-click the blank area around Disk 2 and select Initialize Disk.
- 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.
- 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.
- In the New Simple Volume Wizard window, click Next and follow the wizard to perform initialization operations.
In the This PC window, a new drive named New Volume (E:) is displayed. The data disk is ready for use.