This document guides you on how to initialize an empty cloud disk that has been attached to a CVM instance, create a file system on the cloud disk, and write a file named qcloud.txt into it.
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, Creating a File System, and Writing a File (Windows)
Formatting, Creating a File System, and Writing a File (Linux)
Note
This document uses a CVM with Windows Server 2012 R2 DataCenter 64-bit English installed as an example. Note that the steps may vary according to the operating system version.
2. On the desktop of the CVM instance, right-click on the
at the lower left corner.
3. From the pop-up menu, select Server Management - All Servers - File and Storage Services - Disks to open the Disk Management window.
4. Right-click the online disk and select New Volume... button, in the pop-up window, follow the default settings and click Next all the time.
follow the default settings and click Next all the time
follow the default settings and click Next all the time
5. Click Create.
The target disk will display as formatting, and you will need to wait for a moment for the system to complete the initialization operation. When the volume status is Healthy, it indicates that the disk initialization was successful. After successful initialization, the new partition's data disk can be seen in the Computer interface.
6. Navigate to the new partition of the data disk, create a new file qcloud.txt, input the content you need, and select File > Save.
Note
This section uses a Linux CVM instance with CentOS 7.8 installed as an example. Note that the steps may vary by operating system version.
This section uses the EXT4 file system as an example.
After a Linux CVM restarts or starts up, it does not automatically mount the data disk. You can refer to Step 9 - Step 14 to set up automatic disk mounting at startup.
2. Run the following command to view the names of data disks attached to the instance.
fdisk -l
If the information returned is as shown below, it indicates that the current CVM has two disks. /dev/vda is the system disk, and /dev/vdb is the newly added data disk.
In this document, the disk connected to the instance is referred to as /dev/vdb for example. As shown in the figure below:
3. Run the following command to format the disk.
mkfs.ext4 /dev/vdb
4. Execute the following command to mount the disk to the /data mount point.
mount /dev/vdb /data
5. Execute the following commands in sequence to access the disk and create a new file named qcloud.txt.
cd /data
vi qcloud.txt
6. Press i to enter the editing mode, where you can input This is my first test..
7. Press Esc to exit the editing mode, enter :wq, and press Enter to save and close the file.
8. By executing the ls command, you can verify that the qcloud.txt file has been written to the disk.
Note
You can set up disk automount at startup through Step 9 to Step 14. If you do not need to configure disk automount at startup, skip the following steps.
9.
Run the following command
to back up the /etc/fstab file. The example below shows how to back it up to the /home directory:
cp -r /etc/fstab /home
10. Run the following command to open the /etc/fstab file using the VI editor.
vi /etc/fstab
11. Press i to enter the editing mode.
12. 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>
Take automatic mounting using the soft link of an elastic cloud disk as an example. Add the following content:
You can use the ls -l /dev/disk/by-id command to view the soft link of the elastic cloud disk.
13. Press ESC, enter :wq, and press Enter to save the configuration and exit the editor.
14.
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.