Elastic Volume Service

Capacity Greater than 2 TB, Initialising Linux-based Data Disks (parted)

2024-11-01 09:41:05

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

A data disk is attached to a cloud server or dedicated physical server and this data disk is not initialised.

Operation Steps

If the capacity of the new EVS is greater than 2 TB, use the parted tool to initialise the Linux-based data disk in the following five steps:

Ÿ   Log in to the ECS

Ÿ   View the newly added data disk: Check whether the newly added data disk has been successfully attached to the cloud server and check its capacity.

Ÿ   Create an 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.

Ÿ   Create and mount a file system: Create a file system for the new partition and use an independent file system to store data.

Ÿ   Set automatic disk mounting upon startup: The disk can be automatically mounted when the cloud server system starts.

Log in to the ECS

1.       Log in to the console.

2.       Click   in the upper left corner of the console and select a Region. In this topic, China (Hong Kong 2) is selected.

3.       Select Compute and click ECS to go to the ECS list page.

4.       Locate the row that contains the cloud server for which the data disk is to be initialised, and in the Operation column, click Remote Login to log in to the cloud server. For more information, see Overview of Linux ECS Login.

Viewing the Newly Added Data Disk

1.       Run the lsblk command to view the newly added data disk. The following information is returned:

The current cloud 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 initialised.

Creating an GPT Partition

1.       Run the parted /dev/vdb command to enter 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:

Caution: A warning message may display:

Warning:   The resulting partition is not properly aligned for best performance.

Ignore/Cancel?   Ignore

If such a performance optimization reminder is displayed, type "Ignore"   to ignore this reminder.

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 an attach point. In this example, /mnt/sdc is used as the attach point.

3.       Run the mount /dev/vdb1 /mnt/sdc command to mount the newly created partition to the newly created attach 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 cloud server system starts, do not specify /dev/vdb1 in /etc/fstab because the sequential encoding of devices in the cloud may change when the cloud 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.


m2dmQcX79ibh