HUAWEI CLOUD cloud practice (2): Create, mount and initialize cloud hard disk EVS in Linux environment

insert image description here

This article mainly explains the basic operations of HUAWEI CLOUD cloud hard disk EVS on the Linux operating system EC2 server, such as creation, mounting, and cloud hard disk initialization, so as to quickly master the operation method of HUAWEI CLOUD cloud hard disk EVS.

How to attach new Huawei EVS Volume

I. Introduction

In our previous article: HUAWEI CLOUD Cloud Practice (1): The creation, mounting and initialization of cloud hard disk EVS in the Windows environment has a preliminary explanation of HUAWEI CLOUD EVS. For the detailed introduction of HUAWEI CLOUD EVS, please refer to: Click Here; EVS official website: Click here , the focus of this article is practical operation, to expand an EVS hard disk on the EC2 of Huawei Cloud's Linux operating system.

This article digs Huawei cloud storage service EVS follow-up theory explanation article

2. Environmental preparation and manufacturing steps

2.1 The environment for the practice of this article

  • An EC2 instance machine
  • Operating system for EC2: CentOS
  • A single piece of EVS (Elastic Volume Service)

2.2 The architecture diagram on the cloud for the practical operation of this article

(ALL)

3. Practical operation

3.1 Purchasing HUAWEI CLOUD EVS

  1. Add cloud hard disks to the Linux elastic cloud server ECS and initialize and log in to the management console. Move the mouse to the left menu bar of the experimental operation desktop browser page, and select "Service List > Storage > Cloud Hard Disk EVS". Go to the cloud hard disk EVS page.

On the home page of the HUAWEI CLOUD console, select: Service List > Storage > EVS. Enter the cloud hard disk EVS page.
image.png

Click the "Buy Disk" button in the new window, as shown in the figure below:

image.png
According to the interface prompts, configure the basic information of the cloud disk. The operation is as follows:

  1. [Billing Mode]: There are two payment methods here, yearly and monthly or on-demand billing. In the example, we choose pay-as-you-go
  2. [Region]: North China - Beijing 4
  3. [Availability Zone]: Availability Zone 1
  4. [Disk Specifications]: The general-purpose SSD is selected in the example, choose according to your own situation
  5. [Disk size]: 20G
  6. [Cloud backup]: Note here, if you need cloud backup, you can check the service, if you don’t need it, choose not to buy it
  7. [More]: Example operation, not configured yet
  8. [Disk name]: volume-linux
  9. 【Purchase Quantity】: 1

insert image description here

Click Buy Now. On the "Details" page, you can check the EVS information of the cloud disk again. After confirming that there are no errors, click "Submit" to start creating the EVS. If modification is still required, click Back to modify the parameters.

insert image description here

After the purchase is successful, the prompt page is as shown in the figure:

insert image description here

Return to Disk List. On the main page of "EVS Disk", check the EVS status of the cloud disk. When the EVS status of the cloud disk changes 可用, it means the creation is successful.

insert image description here

3.2 Mount HUAWEI CLOUD EVS

In the EVS list of the cloud disk, find the cloud disk volume-linux created in the previous steps, click [Mount] in the operation on the right, and the mount disk configuration window will pop up.

insert image description here

Select the elastic cloud server ECS to be mounted on the cloud hard disk EVS, here we choose ecs-linux, the elastic cloud server ECS must be located in the same available zone as the cloud hard disk EVS, select "mount point" from the drop-down list, and the mount point For the data disk, click OK.

insert image description here

Return to the EVS list page of the cloud disk. At this time, the EVS status of the cloud disk is "mounting", indicating that the EVS of the cloud disk is in the process of being mounted to the ECS. When the EVS status of the cloud disk is "in use", it means that it is successfully mounted to the ECS, and it can be used normally only after initialization in the next step.

insert image description here

3.3 Initialize and mount the Linux cloud disk EVS

3.3.1 Connect to the ECS server where the EVS is to be mounted

Remotely log in to the Linux ECS and choose Service List > ECS. Go to the ECS page.

insert image description here

Copy the EIP of the ECS named "ecs-linux".

insert image description here

Use SSH tools to connect to this ECS instance. The tool I use here is MobaXterm. According to your own habits, you can also choose tools such as XShell or putty.

3.3.2 View the newly added data disk

Execute the following command to check the status of the hard disk.

Note: Only when a new EVS is mounted in step 3.3.2 will the following disk information be displayed, otherwise no new disk will appear.

fdisk -l

Indicates that the current ECS has two disks, "/dev/vda" is the system disk, and "/dev/vdb" is the new data disk.

insert image description here

3.3.3 Create a new partition

Execute the following command to enter the fdisk partition tool and start partitioning the newly added data disk. fdisk adds a new data disk, taking the newly mounted data disk "/dev/vdb" as an example:

[root@ecs-linux ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x71eb7798.

Enter "n" and press "Enter" to start creating a new partition.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
  • Take creating a primary partition as an example, enter "p" and press "Enter" to start creating a primary partition. Take the partition number selection "1" as an example, enter the primary partition number "1", and press the "Enter" key.

  • "First sector" indicates the initial magnetic column area, you can choose 2048-20971519, and the default is 2048. Take the selection of the default initial magnetic column number 2048 as an example, without entering a command, just press the "Enter" key.

  • "Last sector" means the cut-off magnetic column area, you can choose 2048-20971519, and the default is 20971519. Take the selection of the default cut-off magnetic column number 20971519 as an example, without entering a command, just press the "Enter" key.

Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{
    
    K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set

Enter "p" and press "Enter" to view the details of the newly created partition.

Command (m for help): p

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x4069c171

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048    41943039    20970496   83  Linux

Next, enter "w" and press the "Enter" key to write the partition result into the partition table.

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Screenshots of the above steps:

insert image description here

Note: If there is a mistake in the previous partition operation, please enter "q", and the fdisk partition tool will exit, and the previous partition results will not be retained. Execute the following command to synchronize the new partition table changes to the operating system.

3.3.4 Format new partition

Execute the following command to synchronize the new partition table changes to the operating system.

partprobe

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/vdb1 Take setting the file system as "ext4" as an example:

[root@ecs-linux ~]# mkfs -t ext4 /dev/vdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242624 blocks
262131 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2153775104
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

insert image description here

Formatting needs to wait for a while, do not exit, wait for the task status to be done.

3.3.5 Mount new disk EVS

Execute the following command to create a new mount point. Take the new mount point "/mnt/sdc" as an example:

mkdir /mnt/sdc

Execute the following command to mount the new partition to the mount point created in the previous step.

Take mounting a new partition to "/mnt/sdc" as an example:

mount /dev/vdb1 /mnt/sdc

Execute the following command to view the mounting results.

df -TH

You can see that "/dev/xvdb1" has been mounted to "/mnt/sdc".
insert image description here

5. Summary at the end of the paper

Through the introduction of this article, we have learned the detailed steps of mounting HUAWEI CLOUD EVS to the Linux system. First, we need to create a cloud hard drive on EVS and install the corresponding driver on the Linux system. Next, we use the command line tool to mount the cloud disk to the Linux system, and format and partition it. Finally, we add the mount point to the fstab file so it will mount automatically after a system reboot. Through these steps, we can easily use HUAWEI CLOUD EVS as a persistent storage solution for Linux systems.

For more articles about HUAWEI CLOUD's cloud practice, please pay attention to the column: Introduction and Practice of Cloud Computing - HUAWEI CLOUD

Guess you like

Origin blog.csdn.net/dietime1943/article/details/130246462