• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. User Guide
  4. FAQs
  5. How to Attach a Data Disk?

How to Attach a Data Disk?

Procedure

  1. Log in to the node to which a data disk will be attached.

    For more information about node login, see Help Center > Elastic Cloud Server > User Guide > Getting Started > Logging In to an ECS > Logging In to a Linux ECS Using a Key Pair (SSH) on the management console.

  2. Run the following command to switch to the root user:

    sudo -s

  3. Run the following command to display disk information:

    fdisk -l

    Example command output:

    ...
    Disk /dev/xvde: 107.4 GB, 107374182400 bytes, 209715200 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes

  4. Select an available data disk (for example, /dev/xvde) based on the disk information displayed in 3. Run the following command to start fdisk:

    fdisk /dev/xvde

    Example command output:

    Welcome to fdisk (util-linux 2.23.2).
    
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    Device does not contain a recognized partition table
    Building a new DOS disklabel with disk identifier 0x94116828.
    
    Command (m for help): 

  5. Type n and press Enter to start partitioning.

    Information similar to the following is displayed:

    Partition type:
       p   primary (0 primary, 0 extended, 4 free)
       e   extended
    Select (default p):

  6. Type p and press Enter.

    By way of example, this step creates a primary partition.

    Example command output:

    Partition number (1-4, default 1): 

  7. Type the primary partition number (for example, 3) and press Enter.

    Example command output:

    First sector (2048-209715199, default 2048): 

  8. Press Enter to set the start cylinder number.

    By way of example, the default start cylinder number is used.

    Example command output:

    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):

  9. Press Enter to set the end cylinder number.

    By way of example, the default end cylinder number is used.

    Example command output:

    Using default value 209715199
    Partition 3 of type Linux and of size 100 GiB is set
    
    Command (m for help):

  10. Type p and press Enter to display details of the newly created partition.

    Information similar to the following is displayed:

    Disk /dev/xvde: 107.4 GB, 107374182400 bytes, 209715200 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x94116828
        Device Boot      Start         End      Blocks   Id  System
    /dev/xvde3            2048   209715199   104856576   83  Linux
    Command (m for help):

  11. Type w and press Enter.

    The partition result is then written into the partition table.

    Example command output:

    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.

  12. Run the following command to build a file system (for example, ext4) for the new partition:

    mkfs -t ext4 /dev/xvde3

    Example command output:

    ...
    Allocating group tables: done                            
    Writing inode tables: done                            
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done 

  13. Mount the new partition to a directory (for example, /var/paas/xvdcuser).

    1. Run the following command to create the /var/paas/xvdcuser directory:

      mkdir /var/paas/xvdcuser

    2. Run the following command to mount the new partition to the /var/paas/xvdcuser directory:

      mount /dev/xvde3 /var/paas/xvdcuser

  14. Run the following command to verify whether the mount is successful:

    df -TH

    Example command output:

    Filesystem     Type      Size  Used Avail Use% Mounted on
    /dev/xvda1     xfs        40G  5.8G   35G  15% /
    devtmpfs       devtmpfs  2.0G     0  2.0G   0% /dev
    tmpfs          tmpfs     2.0G   13k  2.0G   1% /dev/shm
    tmpfs          tmpfs     2.0G   77M  1.9G   4% /run
    tmpfs          tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
    /dev/xvde3     ext4      106G   63M  101G   1% /var/paas/xvdcuser

  15. Enable onboot mount for the new disk dev/xvde.

    • Do not enable onboot mount for a disk that is not yet formatted. Otherwise, the VM using the disk will fail to boot.
    • Before uninstalling a disk capable of onboot mount, you must delete the onboot mount configuration. Otherwise, the VM using the disk will fail to boot.
    1. Run the following command to open the fstab file using the VI editor:

      vi /etc/fstab

    2. Press i to switch to the edit mode.
    3. Move the cursor to the end of the fstab file and press Enter to start a new line. Type the following at the new line:

      /dev/xvde3 /var/paas/xvdcuser ext4 defaults 1 1

  16. Press Esc. Type :wq! to save the new change. Press Enter to exit the VI editor.