This topic describes how to use the Logical Volume Manager (LVM) to resize a Logical Volume (LV) that consists of multiple cloud disks on a Linux ECS instance.
You have created an LV. For more information, see Create an LV.
The cloud disks have free space, or the cloud disks have been resized. For more information, see Overview.
- Remotely connect to an ECS instance as a root user. For more information about detailed steps, see ECS instance creation overview.
- Run the lvdisplay command to view information of the LV that has been created in the ECS instance.
You have created the /dev/lvm_01/lv01 LV, which have a physical capacity of 5 TiB.
root@lvs06:~# lvdisplay --- Logical volume --- LV Path /dev/lvm_01/lv01 LV Name lv01 VG Name lvm_01 LV UUID svB00x-l6Ke-ES6M-ctsE-9P6d-dVj2-o0h*** LV Write Access read/write LV Creation host, time lvs06, 2019-06-0615:27:19 +0800 LV Status available # open 0 LV Size 5.00 TiB Current LE 1310720 Segments 6 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
- Run the pvs command to view the Physical Volume (PV) usage.
The /dev/vdg data disk has a free space of 500 GiB.
root@lvs06:~# pvs PV VG Fmt Attr PSize PFree /dev/vdb lvm_01 lvm2 a-- <1024.00g 0 /dev/vdc lvm_01 lvm2 a-- <1024.00g 0 /dev/vdd lvm_01 lvm2 a-- <1024.00g 0 /dev/vde lvm_01 lvm2 a-- <1024.00g 0 /dev/vdf lvm_01 lvm2 a-- <1024.00g 0 /dev/vdg lvm_01 lvm2 a-- <1024.00g <523.98g
- Run the lvextend command to resize the LV.
lvextend [-L +/- <Capacity to be resized>] <LV name>Note
- Capacity to be resized: the LV can be resize only when the Volume Group (VG) has sufficient free space. In this example, you resize the LV from 5 TiB to 5.5 TiB.
- LV name: the name of the LV to be resized.
You resize the /dev/lvm_01/lv01 LV by a physical capacity of 500 GiB.
root@lvs06:~# lvextend -L +500GB /dev/lvm_01/lv01 Size of logical volume lvm_01/lv01 changed from5.00 TiB (1310720 extents) to <5.49 TiB (1438720 extents). Logical volume lvm_01/lv01 successfully resized.
- Run the resize2fs command to resize the file system of the LV.
root@lvs06:~# resize2fs /dev/lvm_01/lv01 resize2fs 1.44.1 (24-Mar-2018) Filesystem at /dev/lvm_01/lv01 is mounted on /media/lv01; on-line resizing required old_desc_blocks = 640, new_desc_blocks = 703 The filesystem on /dev/lvm_01/lv01 is now 1473249280 (4k) blocks long.
- Run the df command to check the file system result.
The total capacity of the LV is 5.5 TiB, indicating that the resize operation is successful.
root@lvs06:~# df -h Filesystem Size Used Avail Use% Mounted on udev 12G 012G 0% /dev tmpfs 2.4G 3.7M 2.4G 1% /run /dev/vda1 40G 3.6G 34G 10% / tmpfs 12G 0 12G 0% /dev/shm tmpfs 5.0M 05.0M 0% /run/lock tmpfs 12G 012G 0% /sys/fs/cgroup tmpfs 2.4G 02.4G 0% /run/user/0 /dev/mapper/lvm_01-lv01 5.5T 83M 5.2T 1% /media/lv01