Este conteúdo foi traduzido por máquina para sua conveniência e a Huawei Cloud não pode garantir que o conteúdo foi traduzido com precisão. Para exibir o conteúdo original, use o link no canto superior direito para mudar para a página em inglês.
Atualizado em 2025-01-23 GMT+08:00

Initializing Linux Data Disks Using Script

Scenarios

This section uses CentOS 7.4 64bit to describe how to initialize data disks attached to a ECS running Linux using the initialization script.

The formatting procedure varies depending on the ECS OS. This section is for reference only.

Ao usar um disco pela primeira vez, se você não o inicializou, incluindo a criação de partições e sistemas de arquivos, a capacidade adicional adicionada ao disco em uma operação de expansão posterior pode não ser usada normalmente.

Pré-requisitos

  • Um disco de dados foi anexado ao ECS e não foi inicializado.
  • Você fez logon no ECS.

Constraints

  • This script uses the EXT4 file system by default. It cannot be used for the disks using LVM or VG.
  • This script can only be used to format CentOS.

Initializing New Disks

  1. Log in to the server and run the following command to obtain the automatic disk initialization script:

    wget https://ecs-instance-driver.obs.cn-north-1.myhuaweicloud.com/datadisk/LinuxVMDataDiskAutoInitialize.sh

    If an abnormal output is returned, check whether the server has an EIP bound. When you are in a region other than CN North-Beijing1, the script can be obtained only after an EIP is bound to the server.

  2. Run the following command to change the permission of the script:

    chmod +x LinuxVMDataDiskAutoInitialize.sh

  3. Execute the following script to automatically detect the data disks to be initialized:

    ./LinuxVMDataDiskAutoInitialize.sh

    The script automatically detects and displays the drive letters (for example, /dev/vdb) except the system disk on the server. Then, you need to enter the drive letter to be initialized, for example, /dev/vdb.

    Figura 1 Automatic detecting disks
  4. Enter the drive letter and press Enter. The script automatically creates the partition for the disk and formats it.
    Figura 2 Entering the drive letter
  5. Enter the directory on which you want to mount the partition, for example, /data-test.
    Figura 3 Entering the mounting directory
    The initialization is complete until the script has mounted the partition and configured automatic mounting upon server start.
    Figura 4 Disk initialization completed

Initializing Existing Disks

  1. Log in to the server and run the following command to obtain the automatic disk initialization script:

    wget https://ecs-instance-driver.obs.cn-north-1.myhuaweicloud.com/datadisk/LinuxVMDataDiskAutoInitialize.sh

  2. Run the following command to change the permission of the script:

    chmod -x LinuxVMDataDiskAutoInitialize.sh

  3. Execute the following script to automatically detect the data disks to be initialized:

    sh LinuxVMDataDiskAutoInitialize.sh

  4. The script automatically detects that the disk partition has been mounted and displays the mounting directory. Determine whether to unmount the partition. Enter y to unmount the partition, or enter n to exit the script. In this example, enter y to continue the initialization.
    Figura 5 Unmounting the disk partition
  5. After the disk partition is unmounted, determine whether to format the disk. Enter y to format the disk, or enter n to exit the script.
    Figura 6 Formatting the disk
  6. After the disk is formatted, the system automatically creates a partition and completes the formatting. Enter the directory on which you want to mount the partition, for example, /data-test.
    Figura 7 Entering the mounting directory

    The initialization is complete until the script has mounted the partition and configured automatic mounting upon server start.

    Figura 8 Disk formatting and partition mounting completed