Help Center> Elastic Volume Service> Best Practices> EVS Disk Management Using LVM> Adding an EVS Disk to Expand the Capacity of a Volume Group

Adding an EVS Disk to Expand the Capacity of a Volume Group

Scenarios

When the space of the LVM volume group cannot meet your requirements, you can expand the volume group capacity by creating EVS disks, creating physical volumes, and adding physical volumes to the volume group.

Figure 1 Sample of expanding a volume group

Procedure

  1. Create an EVS disk and attach it.

    1. Log in to the management console.
    2. Under Storage, click Elastic Volume Service. The disk list page is displayed.
    3. Click Buy Disk and create a disk.

      For details about how to create EVS disks, see Elastic Volume Service User Guide.

    4. In the disk list, locate the row that contains the new disk and click Attach in the Operation column.
    5. Select the target ECS and select the device name from the drop-down list. Ensure that the EVS disk and ECS are in the same AZ.

      Return to the disk list page. The status of the disk is Attaching, indicating that the disk is being attached to the ECS. When the disk status changes to In-use, the disk is successfully attached.

  2. Log in to the ECS as user root.
  3. Run the following command to query the capacity of the volume group:

    vgdisplay

    Information similar to the following is displayed:

    [root@ecs-lvmtest ~]# vgdisplay
      --- Volume group ---
      VG Name               vgdata
      System ID
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  3
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                1
      Open LV               1
      Max PV                0
      Cur PV                2
      Act PV                2
      VG Size               19.99 GiB
      PE Size               4.00 MiB
      Total PE              5118
      Alloc PE / Size       4864 / 19.00 GiB
      Free  PE / Size       254 / 1016.00 MiB
      VG UUID               NLkZV7-hYYE-0w66-tnlt-Y6jL-Ik7S-76w4P6

    In the command output, the VG Size value indicates the volume group capacity, which is 19.99 GiB in this example.

  4. Run the following command to view and take note of the disk device names:

    fdisk -l | grep /dev/vd | grep -v vda

    Information similar to the following is displayed:

    [root@ecs-lvmtest ~]# fdisk -l | grep /dev/vd | grep -v vda
    Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
    Disk /dev/vdc: 10.7 GB, 10737418240 bytes, 20971520 sectors
    Disk /dev/vdd: 10.7 GB, 10737418240 bytes, 20971520 sectors

    In the command output, the new EVS disk is attached to the ECS, and the device name is /dev/vdd.

  5. Run the following command to create a physical volume based on the new EVS disk:

    pvcreate Disk device name

    For example, run the following command:

    pvcreate /dev/vdd

    Information similar to the following is displayed:

    [root@ecs-lvmtest ~]# pvcreate /dev/vdd
      Physical volume "/dev/vdd" successfully created.

  6. Run the following command to add the physical volume to the volume group to expand the volume group capacity:

    vgextend Volume group name physical volume name

    For example, run the following command:

    vgextend vgdata /dev/vdd

    Information similar to the following is displayed:

    [root@ecs-lvmtest ~]# vgextend vgdata /dev/vdd
      Volume group "vgdata" successfully extended

  7. Run the following command to query details of the volume group:

    vgdisplay

    Information similar to the following is displayed:

    [root@ecs-lvmtest ~]# vgdisplay
      --- Volume group ---
      VG Name               vgdata
      System ID
      Format                lvm2
      Metadata Areas        3
      Metadata Sequence No  4
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                1
      Open LV               1
      Max PV                0
      Cur PV                3
      Act PV                3
      VG Size               <29.99 GiB
      PE Size               4.00 MiB
      Total PE              7677
      Alloc PE / Size       4864 / 19.00 GiB
      Free  PE / Size       2813 / <10.99 GiB
      VG UUID               NLkZV7-hYYE-0w66-tnlt-Y6jL-Ik7S-76w4P6

    In the command output, 10 GB has been added to the VG Size volume group.