このページは、お客様の言語ではご利用いただけません。Huawei Cloudは、より多くの言語バージョンを追加するために懸命に取り組んでいます。ご協力ありがとうございました。

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 Cloud Server/ User Guide (Paris Regions)/ Getting Started/ Initializing EVS Data Disks/ Initializing a Linux Data Disk Larger Than 2 TiB (parted)

Initializing a Linux Data Disk Larger Than 2 TiB (parted)

Updated on 2025-01-27 GMT+08:00

Scenarios

This section uses CentOS 7.4 64bit to describe how to use parted to initialize a data disk whose capacity is larger than 2 TiB. In the following operations, the capacity of the example disk is 3 TiB.

The maximum partition size that MBR supports is 2 TiB and that GPT supports is 18 EiB. If the disk size you need to partition is greater than 2 TiB, partition the disk using GPT.

The fdisk partitioning tool is suitable only for MBR partitions, and the parted partitioning tool is suitable for both MBR and GPT partitions. For more information, see Scenarios and Disk Partitions.

The method for initializing a disk varies slightly depending on the OS running on the server. This document is used for reference only. For the detailed operations and differences, see the product documents of the corresponding OS.

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

  • A data disk has been attached to a server and has not been initialized.
  • You have logged in to the server.
    • For how to log in to an ECS, see the Elastic Cloud Server User Guide.
    • For how to log in to a BMS, see the Bare Metal Server User Guide.

Creating and Mounting a Partition

The following example shows you how a new partition can be created on a new data disk that has been attached to a server. The partition will be created using parted, and GPT will be used. Furthermore, the partition will be formatted using the ext4 file system, mounted on /mnt/sdc, and configured to mount automatically at startup.

  1. Query information about the new data disk.

    lsblk

    Information similar to the following is displayed:

    [root@ecs-centos74 ~]# lsblk
    NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    vda    253:0    0  40G  0 disk
    ├─vda1 253:1    0   1G  0 part /boot
    └─vda2 253:2    0  39G  0 part /
    vdb    253:16   0   3T  0 disk

    In the command output, this server contains two disks. /dev/vda and /dev/vdb. /dev/vda is the system disk, and /dev/vdb is the new data disk.

  2. Launch parted to partition the new data disk.

    parted New data disk

    In this example, run the following command:

    parted /dev/vdb

    Information similar to the following is displayed:

    [root@ecs-centos74 ~]# parted /dev/vdb
    GNU Parted 3.1
    Using /dev/vdb
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted)

  3. Enter p and press Enter to view the current disk partition style.

    Information similar to the following is displayed:

    (parted) p
    Error: /dev/vdb: unrecognised disk label
    Model: Virtio Block Device (virtblk)
    Disk /dev/vdb: 3299GiB
    Sector size (logical/physical): 512B/512B
    Partition Table: unknown
    Disk Flags:
    (parted)

    In the command output, the Partition Table value is unknown, indicating that no partition style is set for the new disk.

  4. Set the disk partition style.

    mklabel Disk partition style

    The disk partition style can be MBR or GPT. If the disk capacity is greater than 2 TiB, use GPT.

    mklabel gpt

    NOTICE:

    The maximum disk size supported by MBR is 2 TiB, and that supported by GPT is 18 EiB. Because an EVS data disk currently supports up to 32 TiB, use GPT if your disk size is greater than 2 TiB.

    If the partition style is changed after the disk has been used, all data on the disk will be lost, so take care to select an appropriate partition style when initializing the disk. If you must change the partition style to GPT after a disk has been used, it is recommended that you back up the disk data before the change.

  5. Enter p and press Enter to view the disk partition style.

    Information similar to the following is displayed:

    (parted) mklabel gpt
    (parted) p
    Model: Virtio Block Device (virtblk)
    Disk /dev/vdb: 3299GiB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    Disk Flags:
     
    Number  Start  End  Size  File system  Name  Flags
     
    (parted)

  6. Enter unit s and press Enter to set the measurement unit of the disk to sector.
  7. Create a new partition.

    mkpart Partition name Start sector End sector

    In this example, run the following command:

    mkpart opt 2048s 100%

    In this example, one partition is created for the new data disk, starting on 2048 and using 100% of the rest of the disk. The two values are used for reference only. You can determine the number of partitions and the partition size based on your service requirements.

    Information similar to the following is displayed:
    (parted) mkpart opt 2048s 100%
    Warning: The resulting partition is not properly aligned for best performance.
    Ignore/Cancel? Ignore 

    If the preceding warning message is displayed, enter Ignore to ignore the performance warning.

  8. Enter p and press Enter to print the partition details.

    Information similar to the following is displayed:

    (parted) p
    Model: Virtio Block Device (virtblk)
    Disk /dev/vdb: 6442450944s
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    Disk Flags:
     
    Number  Start  End          Size         File system  Name  Flags
     1      2048s  6442448895s  6442446848s               opt

    Details about the dev/vdb1 partition are displayed.

  9. Enter q and press Enter to exit parted.
  10. View the disk partition information.

    lsblk

    Information similar to the following is displayed:

    [root@ecs-centos74 ~]# lsblk
    NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    vda    253:0    0  40G  0 disk
    ├─vda1 253:1    0   1G  0 part /boot
    └─vda2 253:2    0  39G  0 part /
    vdb    253:16   0   3T  0 disk
    └─vdb1 253:17   0   3T  0 part

    In the command output, /dev/vdb1 is the partition you created.

  11. Format the new partition with a desired file system format.

    mkfs -t File system format /dev/vdb1

    In this example, the ext4 format is used for the new partition.

    mkfs -t ext4 /dev/vdb1

    Information similar to the following is displayed:

    [root@ecs-centos74 ~]# 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
    201326592 inodes, 805305856 blocks
    40265292 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=2952790016
    24576 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, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
            102400000, 214990848, 512000000, 550731776, 644972544
     
    Allocating group tables: done
    Writing inode tables: done
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done

    The formatting takes a period of time. Observe the system running status and do not exit.

    NOTICE:

    The partition sizes supported by file systems vary. Choose an appropriate file system format based on your service requirements.

  12. Create a mount point.

    mkdir Mount point

    In this example, the /mnt/sdc mount point is created.

    mkdir /mnt/sdc

    NOTE:

    The /mnt directory exists on all Linux systems. If the mount point cannot be created, it may be that the /mnt directory has been accidentally deleted. You can run mkdir -p /mnt/sdc to create the mount point.

  13. Mount the new partition on the created mount point.

    mount Disk partition Mount point

    In this example, the /dev/vdb1 partition is mounted on /mnt/sdc.

    mount /dev/vdb1 /mnt/sdc

  14. Check the mount result.

    df -TH

    Information similar to the following is displayed:

    [root@ecs-centos74 ~]# df -TH
    Filesystem     Type      Size  Used Avail Use% Mounted on
    /dev/vda2      ext4       42G  1.5G   38G   4% /
    devtmpfs       devtmpfs  2.0G     0  2.0G   0% /dev
    tmpfs          tmpfs     2.0G     0  2.0G   0% /dev/shm
    tmpfs          tmpfs     2.0G  8.9M  2.0G   1% /run
    tmpfs          tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
    /dev/vda1      ext4      1.1G  153M  801M  17% /boot
    tmpfs          tmpfs     398M     0  398M   0% /run/user/0
    /dev/vdb1      ext4      3.3T   93M  3.1T   1% /mnt/sdc

    You should now see that partition /dev/vdb1 is mounted on /mnt/sdc.

Configuring Automatic Mounting at System Start

The fstab file controls what disks are automatically mounted at ECS startup. You can configure the fstab file of an ECS that has data. This operation will not affect the existing data.

The following example uses UUIDs to identify disks in the fstab file. You are advised not to use device names (like /dev/vdb1) to identify disks in the file because device names are assigned dynamically and may change (for example, from /dev/vdb1 to /dev/vdb2) after an ECS stop or start. This can even prevent your ECS from booting up.

NOTE:

UUIDs are the unique character strings for identifying partitions in Linux.

  1. Query the partition UUID.

    blkid Disk partition

    In this example, the UUID of the /dev/vdb1 partition is queried.

    blkid /dev/vdb1

    Information similar to the following is displayed:

    [root@ecs-test-0001 ~]# blkid /dev/vdb1
    /dev/vdb1: UUID="0b3040e2-1367-4abb-841d-ddb0b92693df" TYPE="ext4"

    Carefully record the UUID, as you will need it for the following step.

  2. Open the fstab file using the vi editor.

    vi /etc/fstab

  3. Press i to enter editing mode.
  4. Move the cursor to the end of the file and press Enter. Then, add the following information:

    UUID=0b3040e2-1367-4abb-841d-ddb0b92693df /mnt/sdc                ext4    defaults        0 2

  5. Press Esc, enter :wq, and press Enter.

    The system saves the configurations and exits the vi editor.

  6. Verify that the disk is auto-mounted at startup.

    1. Unmount the partition.

      umount Disk partition

      In this example, run the following command:

      umount /dev/vdb1

    2. Reload all the content in the /etc/fstab file.

      mount -a

    3. Query the file system mounting information.

      mount | grep Mount point

      In this example, run the following command:

      mount | grep /mnt/sdc

      If information similar to the following is displayed, automatic mounting has been configured:

      root@ecs-test-0001 ~]# mount | grep /mnt/sdc
      /dev/vdb1 on /mnt/sdc type ext4 (rw,relatime,data=ordered)

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