Initialize an EBS Disk (Linux)

When an EBS disk is mounted to the ECS as a data disk, it is offline by default. You need to initialize the data disk to format and partition the data disk, and create a file system so as to use it normally.

Before you begin

  • You have created and logged in to the ECS of Linux operating system.
  • You have mounted the EBS disk to the aforementioned ECS instance as a data disk, and not initialized the data disk.

About this task

In this example, the capacity of the newly mounted data disk is 20 GB and the disk name is /dev/vdb. Create a single partition data disk and format it into an ext3 file system. Optimized instance I/O is used, and the operating system is CentOS 7.6.

Procedure

  1. Connect to the ECS instance remotely.
  2. View the disk details under the current system.
    1s /dev/vd*

    In the information displayed, /dev/vda is the system disk, and /dev/vdb is the data disk mounted this time.

  3. View the information of the disk to be initialized.
    fdisk -1 /dev/vdb
  4. Partition the data disk.
    fdisk /dev/vdb
    1. Type in n and press Enter to create a new partition.

      In the information displayed, p represents a primary partition, and e represents an extended partition. In this example, a primary partition will be created.

    2. Type in p and press Enter to create a primary partition.

      In the information displayed, Partition number represents the serial number of the primary partition. The value range is from 1 to 4. The default value is 1.

    3. Type in the number and press Enter. Or press Enter directly and the system will use the default value 1.

      In the information displayed, First sector represents the serial number of the first sector. The value range is from 2048 to 20971519, and the default value is 2048.

    4. Type in the number and press Enter. Or press Enter directly and the system will use the default value 2048.

      In the information displayed, Last sector represents the serial number of the last sector. The value range is from 2048 to 41943039, and the default value is 41943039.

    5. Type in the number and press Enter. Or press Enter directly and the system will use the default value 41943039.

      A primary partition has been created for a data disk of 20 GB.

    6. Type in p and press Enter to view details of the partition.

      In the information displayed, /dev/vdb1 is the newly created partition.

    7. Type in w and press Enter to write the result to the partition table.

      The above information indicates that the partition is successfully created.

      Note: In case that you make a mistake in the process, you can exit by entering q, and the partition created before will be discarded.
    8. Run the command fdisk -l to view the new partition.

  5. Create a file system on the newly created partition.
    mkfs.ext3 /dev/vdb1
  6. Optional: Back up the file etc/fstab.
    cp /etc/fstab /etc/fstab.bak
  7. Write information of the new partition to /etc/fstab.
    Note:

    Information of the manually mounted disk must be written to the file /etc/fstab. Otherwise, if the server is restarted, you need to remount the disk.

    There are two ways for mounting:

    • Mount the disk using the partition number.

      echo /dev/vdb1 /mnt ext3 defaults 0 0 >> /etc/fstab
    • Mount the disk using UUID.

      Run the command blkid /dev/vdb1 to view the information of UUID.

      echo UUID=b7fc63da-be58-4aa5-bf6e-3651e3bb59bd /mnt ext3 defaults 0 0 >> /etc/fstab
  8. View the partition information written to the file etc/fstab.
    cat etc/fstab
  9. Mount the file system.
    mount /dev/vdb1 /mnt
  10. View the disk space usage.
    df -h
Did the above content solve your problem? Yes No
Please complete information!

Call us

400-151-8800

Email us

cloud@pingan.com

Online customer service

Instant reply

Technical Support

cloud products