Expanding the Capacity of a Logical Volume Using the Unallocated Capacity
Scenarios
When the capacity of a logical volume becomes insufficient, you can expand its capacity. This topic shows how to add 4 GB space for a 15 GB logical volume, which cannot meet requirements.
During the capacity expansion, ensure that the volume group where the to-be-expanded logical volume belongs has sufficient available space. If the volume group's available space is also insufficient, expand the capacity of the volume group according to Adding an EVS Disk to Expand the Capacity of a Volume Group.
Procedure
- Log in to the ECS as user root.
- Run the following command to expand the capacity of the logical volume:
lvextend -L +Additional capacity Logical volume path
Parameter descriptions:
- Additional capacity: Specify a value smaller than the volume group's available space, either in MB or GB.
- Logical volume path: Specify the path of the to-be-expanded logical volume.
For example, run the following command:
lvextend -L +4GB /dev/vgdata/lvdata1
Information similar to the following is displayed:
[root@ecs-lvmtest ~]# lvextend -L +4GB /dev/vgdata/lvdata1 Size of logical volume vgdata/lvdata1 changed from 15.00 GiB (3840 extents) to 19.00 GiB (4864 extents). Logical volume vgdata/lvdata1 successfully resized.
This step expands only the capacity of the logical volume. You also need to expand the size of the file system on this volume.
- Run the following command to expand the size of the file system:
resize2fs Logical volume path
For example, run the following command:
resize2fs /dev/vgdata/lvdata1
Information similar to the following is displayed:
[root@ecs-lvmtest ~]# resize2fs /dev/vgdata/lvdata1 resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/vgdata/lvdata1 is mounted on /Data1; on-line resizing required old_desc_blocks = 4, new_desc_blocks = 28 The filesystem on /dev/vgdata/lvdata1 is now 3657728 blocks long.
- Run the following command to check whether the file system size increases:
df -h
Information similar to the following is displayed:
[root@ecs-lvmtest ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda2 39G 1.5G 35G 5% / devtmpfs 487M 0 487M 0% /dev tmpfs 496M 0 496M 0% /dev/shm tmpfs 496M 6.7M 490M 2% /run tmpfs 496M 0 496M 0% /sys/fs/cgroup /dev/vda1 976M 131M 779M 15% /boot tmpfs 100M 0 100M 0% /run/user/0 /dev/mapper/vgdata-lvdata1 19G 44M 18G 1% /Data1
In the command output, the size of file system /dev/mapper/vgdata-lvdata1 increases by 4 GB.
Last Article: Creating and Mounting a File System
Next Article: Adding an EVS Disk to Expand the Capacity of a Volume Group
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.