Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Elastic Volume Service/ Getting Started/ Initializing Linux Data Disks Using a Script

Initializing Linux Data Disks Using a Script

Updated on 2024-10-10 GMT+08:00

Scenarios

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

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

NOTICE:

When using a disk for the first time, if you have not initialized it, including creating partitions and file systems, the additional space added to this disk in an expansion later may not be normally used.

Prerequisites

  • You have attached the data disk to a server, but has not initialized it yet.
  • You have logged in to the server.

Notes and 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

    NOTE:

    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.

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

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

    Figure 8 Disk formatting and partition mounting completed

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback