Updated on 2025-07-30 GMT+08:00

Initializing a Linux Data Disk (Greater Than 2 TiB)

Scenarios

After a newly purchased data disk is attached to a server, you must log in to the server and initialize the disk before you can use the disk.

When your disk is greater than 2 TiB, you can only use the parted tool and create GPT partitions. The initialization operations vary depending on the server OS. To learn about the differences between MBR and GPT, see Partition Styles.

Operation

Partition Style

OS Requirements

Common File Systems

Partitioning Tool

Example Configuration

Initializing a Data Disk Using parted

GPT

None

ext* (such as ext2, ext3, and ext4), xfs, and btrfs

parted

  • OS: CentOS 7.4 64-bit
  • Device name: /dev/vdb
  • File system format: ext4
  • Mount point: /mnt/sdc
  • Partition name: /dev/vdb1
  • Partition style: GPT
  • Size: 3 TiB

Prerequisites

The disk has been attached to a server. For how to attach disks, see Attaching an EVS Disk.

Constraints

  • A disk created from a data source does not need to be initialized. Such a disk contains the source data in the beginning. Initializing the disk may clear the initial data on it. If you need to re-initialize the disk, you are advised to back up the disk data first. For how to back up data using CBR, see Backing Up EVS Disks. For how to back up data using snapshots, see Creating an EVS Snapshot.
  • Initializing a disk does not delete the snapshots created for the disk, so you can still use snapshots to roll back data to the source disk after the disk is initialized.

Initializing a Data Disk Using parted

Major initialization steps include creating partitions and file systems, mounting partitions, and configuring auto mount at system startup.

The following example shows you how to use parted to create a GPT partition on the /dev/vdb data disk.

  1. Log in to the server.

    For how to log in to an ECS, see Logging In to an ECS.

    For how to log in to a BMS, see Logging In to a BMS.

  2. Create partitions. In this example, create the /dev/vdb1 partition on data disk /dev/vdb.

    1. Check that the capacity of the /dev/vdb data disk is 3 TiB.
      lsblk
      [root@ecs-centos76 ~]# lsblk
      NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
      vda    253:0    0  40G  0 disk
      ├vda1 253:1    0  40G  0 part /
      vdb    253:16   0   3T  0 disk

      The command output shows that there are two EVS disks. /dev/vda is the system disk, and /dev/vdb is the new data disk, whose 3 TiB is not partitioned.

    1. Create a partition. Replace /dev/vdb in the command with your desired disk name.

      parted /dev/vdb

      p
      [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) p
      Error: /dev/vdb: unrecognised disk label
      Model: Virtio Block Device (virtblk)
      Disk /dev/vdb: 3299GB
      Sector size (logical/physical): 512B/512B
      Partition Table: unknown
      Disk Flags:
      (parted)

      Partition Table: unknown means that no partition style is set for the new disk.

      If error message -bash: parted: command not found is returned, the system cannot identify the command. In this case, run yum install -y parted to install the command. Then, run the command again.

    1. Set the partition style to GPT.

      mklabel gpt

      unit s

      p

      (parted) mklabel gpt
      (parted) unit s
      (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
       
      (parted)
      • mklabel <disk-partition-style>: If your disk capacity is less than or equal to 2 TiB and you want to use parted to create an MBR partition, run the mklabel msdos command.
      • unit s: This command sets the measurement unit of the disk to sector.
      • If you change the partition style of a disk, data on the disk will be erased. Select an appropriate partition style when initializing disks.
      • The partition style (MBR or GPT) set here will apply to all subsequent partitions created on this EVS disk. When you create partitions on this disk later, you do not need to perform this step again.
    1. Set the partition name to /dev/vdb1 and allocate all the storage space to this partition.

      mkpart /dev/vdb1 2048s 100%

      p

      • mkpart <partition-name> <first-sector-value> <last-sector-value>: In the example command, 2048s is the start sector value, and 100% indicates to allocate 100% of the disk space to the /dev/vdb1 partition.
      • If you want to allocate the data disk capacity to two or more partitions, calculate the first and last sectors of the partitions based on the method provided in 2.
      (parted) mkpart /dev/vdb1 2048s 100%
      (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               /dev/vdb1
    2. Enter q and press Enter. Then run lsblk to view the new partition /dev/vdb1.
      [root@ecs-centos74 ~]# lsblk
      NAME     MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
      vda      253:0    0    40G  0 disk
      ├─vda1 253:1    0    40G  0 part /
      vdb      253:16   0     3T  0 disk
      └─vdb1 253:17   0     3T  0 part

  3. Create file systems.

    1. In this example, create an ext4 file system on the /dev/vdb1 partition.

      mkfs -t ext4 /dev/vdb1

      • mkfs -t <file-system-format> <disk-partition-name>: To create an xfs file system, the command is mkfs -t xfs <disk-partition-name>. To create a btrfs file system, the command is mkfs -t btrfs <disk-partition-name>.
      • It takes some time to create file systems. Do not exit before the system returns the following information:
      [root@ecs-test-0001 ~]# 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
      [root@ecs-test-0001 ~]#
    2. After the file system is created, run the following commands to check the file system format:

      parted /dev/vdb

      p
      [root@ecs-test-0001 ~]# parted /dev/vdb
      GNU Parted 3.1
      Using /dev/vdb
      Welcome to GNU Parted! Type 'help' to view a list of commands.
      (parted) p
      Model: Virtio Block Device (virtblk)
      Disk /dev/vdb: 3299GB
      Sector size (logical/physical): 512B/512B
      Partition Table: gpt
      Disk Flags:
      
      Number  Start   End      Size     File system  Name        Flags
       1      1049kB  3299GB   3299GB   ext4         /dev/vdb1           
      
      (parted) q
      [root@ecs-test-0001 ~]#

      If ext4 is displayed under File system, the creation is successful.

      Enter q and press Enter to exit parted.

  4. Create a directory (mount point) and mount the new partition on the created mount point.

    mkdir -p /mnt/sdc

    mount /dev/vdb1 /mnt/sdc

    lsblk

    [root@ecs-test-0001 ~]# lsblk
    NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    vda    253:0    0  40G  0 disk
    ├vda1 253:1    0  40G  0 part /
    vdb    253:16   0   3T 0 disk
    ├vdb1 253:17   0   3T 0 part /mnt/sdc

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

  5. (Optional) Use the partition UUID to configure auto mount at startup.

    UUIDs are the unique character strings for identifying partitions in Linux. Mounts become invalid after a system reboot. You can configure auto mount at startup by adding information of the new partitions into the /etc/fstab file.
    • You are advised not to use device names to identify disks in the /etc/fstab file because device names are assigned dynamically and may change (for example, from /dev/vdb1 to /dev/vdb2) after a server stop or start. This can even prevent your server from booting up.
    • This operation will not affect the existing data on the ECS.
    1. Query the partition UUID.

      blkid /dev/vdb1

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

      Take note of the partition UUID, which will be used in the next step. In this example, the UUID of the /dev/vdb1 partition is 0b3040e2-1367-4abb-841d-ddb0b92693df.

    1. Configure auto mount at startup.

      vi /etc/fstab

      Press i to enter the editing mode, move the cursor to the end of the file, press Enter, and add the following content:

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

      Press Esc, enter :wq, and press Enter to save the settings and exit the vi editor.

      Table 1 Content description

      Example Value

      Description

      UUID=0b3040e2-1367-4abb-841d-ddb0b92693df

      The UUID of the partition.

      /mnt/sdc

      The mount point of the partition.

      ext4

      The file system format of the partition.

      defaults

      The partition mount option. Normally, this parameter is set to defaults.

      0

      • The Linux dump backup option.
        • 0: Linux dump backup is not used. Usually, dump backup is not used, and you can set this parameter to 0.
        • 1: Linux dump backup is used.

      2

      • The fsck option, which means whether to use fsck to check the disk during startup.
        • 2: The check starts from the partitions whose mount points are non-root directories. / is the root directory.
        • 1: The check starts from the partitions whose mount points are root directories.
        • 0: The fsck option is not used.

  6. (Optional) Verify that auto mount takes effect.

    You can restart the server to check whether auto mount takes effect. Alternatively, you can perform the following steps to simulate auto mount.

    1. To verify auto mount, unmount the partition first.

    umount /dev/vdb1

    1. Reload all the content in the /etc/fstab file. /etc/fstab is a static file system table that contains the list of file systems that need to be automatically mounted during system startup.

    mount -a

    1. Query the file system mount information.

    mount | grep /mnt/sdc

    If information similar to the following is displayed, auto mount has taken effect:

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