Content is empty
If you don't find the content you expect, please try another search term
Last updated:2021-07-16 10:54:19
This topic describes how to format a data disk whose capacity is less than 2 TB. If you want to partition a data disk whose capacity is greater than 2 TB, you must use the GUID Partition Table (GPT) partition format. For more information, see Format a data disk (≥ 2 TB).
Operating environment
A data disk with a capacity of 200 GB is attached to a KEC instance that runs 64-bit Windows Server 2012 R2. The following procedure shows you how to initialize the data disk in the Master Boot Record (MBR) partition format, format the data disk, and then create a New Technology File System (NTFS) file system for the data disk.
Procedure
Note: If the data disk that you want to initialize is in the Offline state, as shown in the preceding figure, you must perform Step 4 to bring it online before you perform Step 5 to initialize it. If the data disk is in the Online state, you can directly perform Step 5 to initialize it.
Operating environment
A data disk with a capacity of 200 GB is attached to a KEC instance that runs 64-bit CentOS 7.6. The following procedure shows you how to create a primary partition for the /dev/vdb data disk by using the fdisk partition utility, initialize the partition in the MBR format, and then create an ext4 or XFS file system for the partition. After you configure the file system, you can mount the file system to the /mnt/data_disk01 directory and configure the file system to be automatically mounted upon operating system startup.
Note: By default, the device names of data disks are assigned by the system, which ascend from /dev/vdb to /dev/vdz. If you do not need to create logical partitions such as /dev/vdb1 or /dev/vdb2 on your data disk, you can directly create a file system on the raw data disk. For more information, see Create a file system on a raw data disk.
Procedure
Run the following command to view the information about the EBS volumes on the KEC instance:
fdisk -l
The following figure shows the output. The following table describes the information extracted from the figure. | EBS volume | Partition | Partition description |
---|---|---|---|
/dev/vda is the system disk with a capacity of 50 GB. | /dev/vda1 | MBR partition, with a capacity of 50 GB | |
/dev/vdb is a data disk with a capacity of 200 GB. | /dev/vdb | No partition |
Note: If the /dev/vd* data disk that you purchase is not displayed in the command output, check whether the data disk is attached to the instance. In this example, the data disk is /dev/vdb. For more information about how to attach a data disk to a KEC instance in the EBS console, see Attach an EBS volume.
Run the fdisk <Data disk name>
command to partition the data disk by using the fdisk partition utility. In this example, the /dev/vdb
data disk is partitioned.
fdisk /dev/vdb
Perform the following steps as prompted: a. Enter p and press the Enter key to view the partition information about the data disk. By default, a new data disk does not have a partition. b. Enter n and press the Enter key to create a partition. c. Enter p and press the Enter key to set the partition type to primary partition.
Note If you want to create four or less partitions on a data disk, you can set the partition type to primary partition for all the partitions. If you want to create more than four partitions, enter e at least once to create an extended partition.
d. Enter the partition number 1 and press the Enter key to create a primary partition.
Note: Partition number specifies the number of a primary partition, which ranges from 1 to 4.
e. Press the Enter key twice to use the default partition size. By default, the number of the start sector is 2048 and the number of the end sector is 419430399.
Note [First sector] specifies the number of the start sector. The default value is 2048. You can select a value within the range from 2048 to 419430399. [Last sector] specifies the number of the end sector. The default value is 419430399. You can select a value within the range from 2048 to 419430399.
f. Enter p and press the Enter key to view the details of the new partition. g. Enter w to save the partition table and start partitioning. The following figure shows the output.
Run the following command to view the information about the new partition:
lsblk
The following figure shows the output.
Run the mkfs.<fstype> <Partition name>
command to format the new partition and create a file system. In this example, create an ext4 file system.
To create an ext* file system, for example, ext4, run the following command:
Create a file system for the /dev/vdb1 partition
mkfs.ext4 /dev/vdb1
The following figure shows the output.
Note: In the preceding command,
/dev/vdb1
is the partition name. You must change it based on your business requirements.
To create an XFS file system, run the following command:
Create a file system for the /dev/vdb1 partition
mkfs.xfs -f /dev/vdb1
The following figure shows the output.
Note: In the preceding command,
/dev/vdb1
is the partition name. You must change it based on your business requirements. If the message-bash: mkfs.xfs: command not found
appears, run theyum -y install xfsprogs
command to install the RPM package of xfsprogs.
mkdir <Mount point>
command to create a mount point for the new partition. In this example, create a mount point named /mnt/data_disk01
.
mkdir /mnt/data_disk01
mount <Partition name> <Mount point>
command to mount the new partition. In this example, mount the /dev/vdb1
partition to the /mnt/data_disk01
mount point.
mount /dev/vdb1 /mnt/data_disk01
df -Th
The following figure shows the output.
Description of optional actions If you want the new partition of the data disk to be automatically mounted to the KEC instance when the KEC instance starts or restarts, perform the following steps to add the information about the new partition to the /etc/fstab file.
Confirm the mount method and obtain the required information. A partition can be automatically mounted by using the universally unique identifier (UUID) or name of the partition. Perform the corresponding operation to obtain the UUID or name.
To obtain the UUID of the /dev/vdb1 partition, run the following command:
blkid /dev/vdb1
To obtain the partition information about the data disk, run the following command:
lsblk
The following figure shows the output. Note: If you detach or delete an EBS volume from a running KEC instance, the names of other EBS volumes attached to the KEC instance may change. We recommend that you reference a partition by adding the UUID of the partition to the /etc/fstab file.
Run the following command to back up the etc/fstab file:
cp /etc/fstab /etc/fstab.bak
/dev/vdb1
partition to the /mnt/data_disk01
mount point.
echo 'UUID=34dbba74-5123-4b0f-a589-ae5e7e9e497c /mnt/data_disk01 ext4 defaults 0 0' >> /etc/fstab
echo '/dev/vdb1 /mnt/data_disk03 ext4 defaults 0 0' >> /etc/fstab
cat /etc/fstab
command to view the auto-mount configuration.
cat /etc/fstab
The following figure shows the output.
mount -a
If the command is successfully run, the /etc/fstab file is successfully configured, and the file system created for the partition will be automatically mounted when the operating system starts.
Pure Mode