Introduction
This article provides a brief overview of resizing a logical volume.
Please note that cPanel support cannot assist you with resizing a logical volume. We recommend you seek assistance from a qualified system administrator to resize any disk.
Procedure
Incorrectly modifying a volume can destroy all data on the volume. It is strongly recommended that you back up your data to an off-server location before attempting to resize a volume.
Please note that, in the provided examples, "centos" is the volume group, "xvda" is the existing disk, and "xvdb" is the new disk. The volume group and disks on your server may be different.
- SSH into your server as the 'root' user.
- Review the size and mount point associated with the logical volume to alter.
[root@server ~]cPs# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 50G 23G 24G 49% /
tmpfs 3.8G 0 3.8G 0% /dev/shm
/dev/xvda1 477M 125M 327M 28% /boot
/dev/mapper/centos-home 860G 72M 816G 1% /home
/dev/loop0 1.6G 2.6M 1.5G 1% /tmp
[root@server ~]cPs# - Review the physical disk information.
[root@server ~]cPs# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 40G 0 disk
└─xvda1 202:1 0 40G 0 part /
└─xvda2 202:2 0 960G 0 part
└─centos-root 253:1 0 50G 0 lvm /
└─centos-home 253:2 0 860G 0 lvm /home
loop0 7:0 0 1.6G 0 loop /var/tmp
xvdb 232:16 0 50G 0 disk
[root@server ~]cPs# - If the volume will be extended using another disk:
- Initialize the new disk using the pvcreate command.
pvcreate /dev/xvdb
- Identify the volume group to add the new disk to with the vgs command.
[root@server ~]cPs# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 -wi-ao---- 960g 50g - Use the vgextend command to extend the volume group to the new disk.
vgextend centos /dev/xvdb
- Initialize the new disk using the pvcreate command.
- Use the lvextend command to expand the logical volume.
lvextend -l +100%FREE /dev/mapper/centos-root
Please note that for the file system to detect the new logical volume size, you will need to run xfs_growfs for xfs file systems or either resize2fs or resize4fs for ext2/ext3/ext4 file systems to expand and resize the file system.