Initializing Cloud Disks (≥2 TB)

Last updated: 2024-06-26 14:15:41

Scenario

This document provides guidance on initializing cloud disks with a capacity of 2TB or more. For more information on cloud disk initialization scenarios, refer to Introduction to Initialization Scenarios. The maximum disk capacity supported by MBR is 2TB, so when partitioning a disk with a capacity greater than 2TB, please use the GPT partition format. For the Linux operating system, when the GPT partition format is chosen, the fdisk partition tool cannot be used and the parted tool must be utilized instead.

Preparations

The cloud disk has been attached to the cloud server.

Supports and Limits

Before performing any operations on the cloud disk, it is advisable to familiarize yourself with the Precautions for Using Cloud Disks to prevent damage to important data.
Formatting a data disk will erase all data. Ensure that the disk is either empty or that important data has been backed up.
To avoid service exceptions, ensure before formatting that the CVM has stopped external services.

Instructions

Initializing Cloud Disk (Windows)
Initializing Cloud Disks (Linux)
Note
This document uses a CVM with Windows Server 2012 installed as an example. Note that the steps may vary according to the operating system version.
2. On the cloud server desktop, click
0a02193a82217974f650bbcaf4e1ed2d.png (39×39)

.
3. Navigate to the Server Manager page and click on Files and Storage Services in the left navigation tree.
4. In the left navigation tree, select Volumes > Disks.

Note
If the newly added disk is in an offline state, you need to first execute Step 5 to bring it online before executing Step 6 for initialization. Otherwise, proceed directly to Step 6 for initialization.
5. 
In the right pane, a list of disks will appear.
If the status of the disk is Offline, right-click on Disk 1 area and select Online from the menu list to bring it online. After going online, Disk changes from Offline status to Not Initialized.
6. Right-click on the
Disk area
and select New Volume... from the drop-down menu, as shown in the figure below:

7. In the New Volume... dialog box, select the disk that needs to be initialized, the confirm dialog appears and click Confirm. As shown below:
Note
If a disk initializes after the disk is put into use, the original data on the disk will be erased.

8. Specify the volume size according to your needs. By default, the maximum value is selected. Click Next.

9. Assign a drive letter and click Next. As shown in the figure below:

10. Select File System Setting, set the parameters as needed, take defalut for example and click Next.

11. Check all information and click Create. Please wait a moment for the system to complete the initialization. When the volume status is Healthy, it indicates that the disk initialization was successful.

After successful initialization, you can view the new disk in the Computer interface.

Select the initialization method according to your actual use cases:
If the entire disk is presented as a single independent partition (i.e., there are no multiple logical disks such as vdb1 and vdb2), we strongly recommend that you do not use partitions and directly build a file system on the raw device.
If the entire disk needs to be represented as multiple logical partitions (i.e., there are multiple logical drives), you must first perform partitioning operations, then create a file system on the partition.

Creating file systems on bare devices

2. Run the following command as the root user to view the disk name.
fdisk -l
If information similar to what is shown below is returned, the current CVM has two disks, where "/dev/vda" is the system disk and "/dev/vdb" is the newly added data disk.

3. Run the following command to create a file system on the /dev/vdb bare device.
mkfs -t <file system format> /dev/vdb
Different file systems support different partition sizes. Please choose the file system according to your actual needs. For instance, when setting the file system to EXT4:
mkfs -t ext4 /dev/vdb
Note
The formatting takes a while. Pay attention to the system's running status and do not exit.
4. Run the following command to create a new mount point.
mkdir <mount point>
Taking the newly created mount point /data as an example:
mkdir /data
5. Run the following command to mount the new partition to the newly created mount point.
mount /dev/vdb <mount point>
Taking the newly created mount point /data as an example:
mount /dev/vdb /data
6. Run the following command to view the mount result.
df -TH
Note
If you do not need to configure disk automount at startup, skip the following steps.
7. Confirm the mounting method and obtain the corresponding information. Based on business needs, you can use an elastic cloud disk's soft link, file system's UUID (universally unique identifier), or device name to automatically mount a disk. The descriptions and information acquisition methods are as follows:
Mount method
Pros and cons
Obtaining information
Utilizing the soft link of an elastic cloud disk (recommended)
Advantages: Each elastic cloud disk has a fixed and unique soft link that does not change with operations such as unmounting, mounting, formatting partitions, etc.
Limitations: Only elastic cloud disks support soft links. It is unable to detect the formatting operations of partitions.
Run the following command to view the soft link of the elastic cloud disk.
ls -l /dev/disk/by-id
Use the UUID of the file system
Automatic mounting configuration may fail due to changes in a file system's UUID.
For example, reformatting a file system will change its UUID.
Run the following command to view the UUID of the file system.
blkid /dev/vdb
Use device name
Auto-attaching configuration may fail due to changes in device name.
For example, if an elastic cloud disk on the CVM is unmounted and then remounted, the device name may change when the operating system recognizes the file system again.
Run the following command to view the device name.
fdisk -l
8. Run the following command to back up the /etc/fstab file. The example below demonstrates how to back it up to the /home directory:
cp -r /etc/fstab /home
9. Run the following command to open the /etc/fstab file using the VI editor.
vi /etc/fstab
10. Press i to enter the editing mode.
11. Move the cursor to the end of the file, press Enter, and append the following content.
<Device information> <Mount point> <File system format> <File system installation option> <File system dump frequency> <File system check sequence at launch>
(Recommended) Using the automatic mounting of the soft link of an elastic cloud disk as an example, combine with the previous examples to add:
/dev/disk/by-id/virtio-disk-drkhklpe /data ext4 defaults,nofail 0 0
Take automatic mounting using the UUID of the disk partition as an example. Add the following content:
UUID=d489ca1c-5057-4536-81cb-ceb2847f9954 /data ext4 defaults,nofail 0 0
Take automatic mounting using the device name as an example. Add the following content:
/dev/vdb /data ext4 defaults,nofail 0 0
12. Press ESC, enter :wq, and press Enter to save the configuration and exit the editor.
13. Run the following command to verify if the /etc/fstab file has been written successfully.
mount -a
If the command runs successfully, the file has been written. The newly created file system will automatically mount when the operating system starts up.

Creating a file system on a partition

Note
This guide will demonstrate how to use the parted partition tool in CentOS 7.5 operating system to set the data disk /dev/vdc as the primary partition. The partition format is set to GPT by default, the file system is set to EXT4 format, it is mounted under /data/newpart2, and is set to automatically mount at startup. The formatting operations may vary across different operating systems, so this guide should be used for reference only.
2. Run the following command as the root user to view the disk name.
lsblk
If information similar to what is shown below is returned, the current CVM has two disks, where /dev/vda is the system disk and /dev/vdc is the newly added data disk.

3. Run the following command to use the parted tool to partition the newly added data disk.
parted <new data disk>
The newly mounted data disk /dev/vdc is used as an example:
parted /dev/vdc
The returned information is similar to what is shown below:

4. Enter p and press Enter to view the current disk partition format. The echo information should resemble the following image:


Partition Table: unknown indicates that the disk partition format is unknown.
5. Run the following command to configure the disk partition format.
mklabel <disk partition format>
If the disk capacity is larger than or equal to 2TB, only GPT partition format can be used:
mklabel gpt
6. Enter p and press Enter to check if the disk partition format has been successfully set. The echo information should resemble the following figure:


Partition Table: gpt indicates that the disk partition format is GPT.
7. Enter unit s and press Enter to set the disk's measurement unit to cylinders.
8. For instance, to create a partition for the entire disk, enter mkpart opt 2048s 100% and press Enter. Here, 2048s represents the starting capacity of the disk, and 100% represents the ending capacity. This is just a reference, and you can plan the number and capacity of disk partitions according to your business needs.
9. Enter p and press Enter to view the details of the newly created partition. The returned information should look similar to the following:

This indicates the details of the newly created partition /dev/vdc1.
10. Enter q and press Enter to exit the parted partition tool.
11. Run the following command to view the disk name.
lsblk
If information similar to what is shown below is returned, you can now see the new partition /dev/vdc1.

12. Execute the following command to set the file system of the newly created partition to the format required by the system.
mkfs -t <file system format> /dev/vdc1
Different file systems support different partition sizes. Please choose the file system according to your actual needs. The following example uses the EXT4 file system:
mkfs -t ext4 /dev/vdc1
The returned information is similar to what is shown below:

The formatting takes a while. Pay attention to the system's running status and do not exit.
13. Run the following command to create a new mount point.
mkdir <mount point>
Taking the newly created mount point /data/newpart2 as an example:
mkdir /data/newpart2
14. Run the following command to mount the new partition to the newly created mount point.
mount /dev/vdc1 <mount point>
Taking the newly created mount point /data/newpart2 as an example:
mount /dev/vdc1 /data/newpart2
15. Run the following command to view the mount result.
df -TH
If information similar to what is shown below is returned:

It indicates that the newly created partition /dev/vdc1 has been mounted to /data/newpart2.
Note
If you do not need to configure disk automount at startup, skip the following steps.
16. Confirm the mounting method and obtain the corresponding information. Based on business needs, you can use an elastic cloud disk's soft link, file system's UUID (universally unique identifier), or device name to automatically mount a disk. The descriptions and information acquisition methods are as follows:
Mount method
Pros and cons
Obtaining information
Utilizing the soft link of an elastic cloud disk (recommended)
Advantages: Each elastic cloud disk has a fixed and unique soft link, which will not change with operations such as unmounting, mounting, formatting partitions, etc.
Limitations: Only elastic cloud disks support soft links. It is unable to detect the formatting operations of partitions.
Run the following command to view the soft link of the elastic cloud disk.
ls -l /dev/disk/by-id

Use the UUID of the file system
Automatic mounting configuration may fail due to changes in a file system's UUID.
For example, reformatting a file system will change its UUID.
Run the following command to view the UUID of the file system.
blkid /dev/vdc1
Use device name
Auto-attaching configuration may fail due to changes in device name.
For instance, if an elastic cloud disk on the cloud server is unmounted and then remounted, the device name may change when the operating system recognizes the device again.
Run the following command to view the device name.
fdisk -l

17. Run the following command to backup the /etc/fstab file. The example below demonstrates how to backup to the /home directory:
cp -r /etc/fstab /home
18. Run the following command to open the /etc/fstab file using the VI editor.
vi /etc/fstab
19. Press i to enter the editing mode.
20. Move the cursor to the end of the file, press Enter, and append the following content.
<Device information> <Mount point> <File system format> <File system installation option> <File system dump frequency> <File system check sequence at launch>
(Recommended) Take automatic mounting using the soft link of an elastic cloud disk as an example. Enter the device information /dev/disk/by-id/virtio-disk-xxxxxxxx, where disk-xxxxxxxx is the ID of the cloud disk you need to set for automatic mounting, which can be viewed on the cloud disk console.
/dev/disk/by-id/virtio-disk-bm42ztpm /data/newpart2 ext4 defaults,nofail 0 2
Take automatic mounting using the UUID of the disk partition as an example. Add the following content:
UUID=fc3f42cc-2093-49c7-b4fd-c616ba6165f4 /data/newpart2 ext4 defaults,nofail 0 2
Take automatic mounting using the device name as an example. Add the following content:
/dev/vdc1 /data/newpart2 ext4 defaults,nofail 0 2
21. Press ESC, enter :wq, and press Enter to save the configuration and exit the editor.
22. Run the following command to verify if the /etc/fstab file has been written successfully.
mount -a
If the command runs successfully, the file has been written. The newly created file system will automatically mount when the operating system starts up.

Related Actions