Scenario
This topic uses CentOS 7.6 64-bit as an example to describe how to use the parted partitioning tool to set partitions for a data disk with a capacity greater than 2 TB on the Linux system. The information returned is for reference only.
Before You Begin
The data disk mounted to the physical server or local data disk of the physical server has not been initialized.
Operation Steps
If the capacity of the new data disk is greater than 2 TB, use the parted tool to initialize the Linux-based data disk in the following five steps:
l Log in to the physical server.
l View the newly added data disk: Check whether the newly added data disk has been successfully mounted to the physical server and check its capacity.
l Create a GPT partition: Create an independent logical partition for the newly added data disk to better organize and manage data. When the disk capacity is greater than 2 TB, you must create a GPT partition.
l Create and mount a file system: Create a file system for the new partition and use an independent file system to store data.
l Set automatic disk mounting upon startup: The disk can be automatically mounted when the physical server system starts.
Logging in to a Physical Server
1. Log in to the console.
2. Click in the upper left corner of the console and select a region. In this topic, Hong Kong 2 is selected.
3. Go to Computing > Physical Server Service to go to the physical server list page.
4. Locate the row that contains the physical server for which the data disk is to be initialized, and in the Operation column, click Remote Login to log in to the physical server. For more information, see Logging in to Linux-based Physical Server.
Viewing the Newly Added Data Disk
Run the lsblk command to view the newly added data disk. The following information is returned:
The current physical server has two disks, of which /dev/vda is the default system disk having a partition /dev/vda1 and /dev/vdb is the newly added data disk with a capacity of 3 TB to be initialized.
Creating a GPT Partition
1. Run the parted /dev/vdb command to start the parted partitioning tool. The following information is returned:
2. Type "p" and press Enter to view the partition form of the current disk. The following information is returned:
3. If Partition Table is unknown, the partition form is unknown.
4. Type the mklabel gpt command. The disk capacity is 3221 GB, greater than 2 TB, and you must set the partition form to GPT.
5. Type "p" and press Enter to view again the partition form of the disk after setting the partition form. The following information is returned:
It can be seen that Partition Table is gpt, indicating that the partition form is set to GPT.
6. Type "unit s" and press Enter to set the metering unit of the disk to cylinder.
7. Type "mkpart opt 2048s 100%" and press Enter. 2048s indicates the start disk capacity and 100% indicates the end disk capacity. The parameters are for reference only. In this example, a partition is created for the entire disk. You can plan the number and capacity of disk partitions based on your business needs. The following information is returned:
Note:
If such a performance optimization reminder is displayed, type "Ignore" to ignore this warning.
Warning: The resulting partition is not properly aligned for best performance.Ignore/Cancel? Ignore
8. Type "p" and press Enter. You can view the detailed information of the newly created partition. The following information is returned:
9. Type "q" and press Enter to exit the parted partitioning tool. The partition is created. The operations and returned are shown in the following figure:
10. Run the lsblk command to check that the partition /dev/vdb1 is created. The following information is returned:
Creating and Mounting a File System
1. Run the mkfs -t ext4 /dev/vdb1 command to create a file system for the newly created partition. In this example, an ext4 file system is created. Select an appropriate file system based on your business needs. The returned information is shown in the figure:
The formatting process takes a while. Do not quit the process before formatting is complete. The larger the capacity, the longer the formatting process.
2. Run the mkdir /mnt/sdc command to create a mount point. In this example, /mnt/sdc is used as the mount point.
3. Run the mount /dev/vdb1 /mnt/sdc command to mount the newly created partition to the newly created mount point. The returned information is shown in the figure:
4. Run the df -TH command to check the mount result. The following information is returned:
This indicates that the newly created partition /dev/vdb1 is mounted to /mnt/sdc.
Setting Automatic Disk Mounting upon Startup
If you want to automatically mount disks when the physical server system starts, do not specify /dev/vdb1 in /etc/fstab because the sequential encoding of devices in the cloud may change when the physical server stops or starts. For example, /dev/vdb1 may change to /dev/vdb2. We recommend that you use UUID to configure automatic disk mounting. The Universally Unique Identifier (UUID) of a disk is the universally unique string that the Linux system provides for disk partitions.
1. Run the blkid /dev/vdb1 command to query the UUID of the disk partition. The following information is returned:
2. Run the vi /etc/fstab command to open the fstab file using the VI editor. Type "i" to go to the editing mode, move the cursor to the end of the file, and press Enter to add the following content. In the UUID= field, please enter the UUID you queried in the previous step, as shown in the figure:
3. Press ESC, type ":wq", and press Enter. Save settings and exit the editor.
4. To verify the automatic mounting function, unmount the mounted partition and run the umount /dev/vdb1 command, as shown in the figure:
5. Run mount- a to reload all the contents of the /etc/fstab file, as shown in the figure:
6. Run the mount |grep /mnt/sdc command to query the mount of the file system. The operations and returned information are shown in the following figure:
If the information shown in the figure is returned, the automatic disk mounting is successfully set.