All Products
Search
Document Center

Elastic Compute Service:Create a logical volume

Last Updated:May 15, 2026

Use LVM to combine multiple data disks or partitions into a dynamically expandable storage pool and carve out logical volumes for use.

How it works

Creating a logical volume (LV) involves four steps:

  1. Create a physical volume (pvcreate): Mark a data disk for LVM use.

  2. Create a volume group (vgcreate): Combine PVs into a storage pool.

  3. Create a LV (lvcreate): Carve out a logical partition from the volume group (VG).

  4. Create and mount a file system (mkfs & mount): Format the LV and mount it to an access path.

image

In this example, two 40 GiB data disks (/dev/vdb and /dev/vdc) are initialized as PVs and added to a VG named vg_01, forming an 80 GiB storage pool. A 55 GiB LV named lv01 is carved from the pool.

Procedure

Step 1: Create a PV

Important

Creating a PV erases all data on the disk. Back up data before proceeding.

  1. Log on to the ECS instance.

    1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

    2. On the instance details page, click Connect > Workbench and log on to the terminal.

  2. Install the LVM tool.

    Alibaba Cloud Linux and CentOS

    sudo yum install -y lvm2

    Debian and Ubuntu

    sudo apt-get install -y lvm2
  3. Run sudo lsblk -f to find the target device names.

    sudo lsblk -f
    NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
    vda                                                      
    ├─vda1                                                   
    ├─vda2 vfat         7938-FA03                            /boot/efi
    └─vda3 ext4   root  33b46ac5-7482-4aa5-8de0-60ab4c3a4c78 /
    vdb                                                      
    vdc                                                      
    vdd                                                      
    └─vdd1                                   
    • If the FSTYPE column is not empty, the device is already initialized and cannot be used as a PV.

    • If the FSTYPE column is empty:

      • If the device has no partitions, use the device name directly. Example: vdbvdb, vdcvdc.

      • If the device has partitions, use the partition name. Example: vddvdd1.

  4. Create the PVs.

    Replace <target_device_name> with the device names from the previous step. Separate names with spaces.

    sudo pvcreate /dev/<target device name>.../dev/<target device name>
    Example: to use vdb and vdc, run sudo pvcreate /dev/vdb /dev/vdc. This creates two 40 GiB PVs.

    Output containing successfully created confirms success.

Step 2: Create a VG

  1. Create the VG.

    Replace <vg_name> with a custom name and <target_device_name> with the device names from Step 1.

    sudo vgcreate <vg_name> /dev/<target device name>.../dev/<target device name>
    Example: to create VG vg_01 with vdb and vdc, run: sudo vgcreate vg_01 /dev/vdb /dev/vdc.

    Output containing successfully created confirms success.

  2. Check the VG's free space.

    Run sudo vgs. Note the VFree column, which shows the remaining capacity.

    sudo vgs

Step 3: Create a LV

  1. Create the LV.

    sudo lvcreate -L <lv_size> -n <lv_name> <vg_name>
    Example: to create LV lv01 (55 GiB) from VG vg_01, run: sudo lvcreate -L 55g -n lv01 vg_01.

    Parameter

    Description

    <lv_size>

    Must not exceed the VG free space.

    <lv_name>

    A custom name for the new LV.

    <vg_name>

    The name of the VG you created.

    Output Logical volume "<lv_name>" created confirms success.

  2. View the LV information.

    Run sudo lvdisplay. Note the LV Path for use in the next step.

    sudo lvdisplay
      --- Logical volume ---
      LV Path                /dev/vg_01/lv01
      LV Name                lv01
      VG Name                vg_01
      LV UUID                NgcCdz-efSY-vCrm-E35b-Dg6p-LNYq-xxxxxx
      LV Write Access        read/write
      LV Creation host, time iZbp13kehgn0kh64txxxxxx, 2025-09-15 16:57:21 +0800
      LV Status              available
      # open                 0
      LV Size                55.00 GiB
      Current LE             14080
      Segments               2
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           252:0

    In this example, the LV Path for lv01 is /dev/vg_01/lv01.

Step 4: Create and mount a file system

  1. Create a file system.

    ext4 handles small files better than xfs.

    ext4

    1. Create an ext4 file system.

      Replace <lv_path> with the LV Path from Step 3.

      sudo mkfs -t ext4 <lv_path>
      Example: LV Path /dev/vg_01/lv01 → run sudo mkfs -t ext4 /dev/vg_01/lv01.
    2. Verify the creation.

      Run sudo lsblk -f. If FSTYPE shows ext4, the file system was created.

    xfs

    1. Install the xfsprogs tool.

      • For Alibaba Cloud Linux and CentOS:

        sudo yum install -y xfsprogs
      • For Debian and Ubuntu:

        sudo apt-get install -y xfsprogs
    2. Create an xfs file system.

      Replace <lv_path> with the LV Path from Step 3.

      sudo mkfs -t xfs <lv_path>
      Example: LV Path /dev/vg_01/lv01 → run sudo mkfs -t xfs /dev/vg_01/lv01.
    3. Verify the creation.

      Run sudo lsblk -f. If FSTYPE shows xfs, the file system was created.

  2. Create a mount point and mount the file system.

    sudo mkdir <mount point> && sudo mount <lv_path> <mount point>

    Parameter

    Description

    <lv_path>

    The LV Path from Step 3.

    <mount point>

    A custom, empty directory path that starts with / . Mounting to a non-empty directory hides its original contents, which can disrupt services and make the original files inaccessible.

    Example: mount /dev/vg_01/lv01 to /mnt/lv01: sudo mkdir /mnt/lv01 && sudo mount /dev/vg_01/lv01 /mnt/lv01.

  3. Check if the file system is mounted successfully.

    Run sudo lsblk. If the target device shows a value in the MOUNTPOINT column, the mount succeeded.

    Important

    This mount is temporary and lost after a reboot. To persist the mount, configure automatic mounting at startup.

FAQ

  • How do I add a new PV to an existing VG?

    1. Log on to the ECS instance.

      1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

      2. On the instance details page, click Connect > Workbench.

    2. View PV and VG information.

      1. View PVs.

        Run sudo pvdisplay. Record the PV name from the PV Name field.

      2. View existing VGs.

        Run sudo vgs. Record the VG name from the VG field.

    3. Add other created PVs.

      Replace <vg_name> and <pv_name> with the values from the previous step.

      sudo vgextend <vg_name> <pv_name>...<pv_name>
  • Why do I get a "404 Not Found" error when installing tools?

    Cause : This error occurs because CentOS 6 and Debian 9/10/11 have reached their End-of-Life (EOL), and their default package repositories are no longer active.

    Solution : You must update your system's repository source to point to an official archive server. After updating the source, you can run the installation command again.

  • What does my LV mount information is missing after a reboot, and how do I fix it?

    Cause: The volume was mounted manually without an entry in /etc/fstab, which controls automatic mounts at boot.

    Solution:

    1. Mount the file system manually if not already mounted. See Step 4.

    2. Configure automatic mounting at startup by adding an entry to /etc/fstab.

  • When running lvcreate, why do I get the error "Volume group "vg01" has insufficient free space (23038 extents): 51200 required." when creating a LV?

    Cause: The specified LV size (-L <lv_size>) exceeds the free space in VG vg_01.

    Solution:

    1. Run sudo vgs and note the VFree value.

    2. Re-run lvcreate with a size within the available free space.

References

If your LV runs out of space, use lvextend to extend the LV.