How to resize hard drive on Linux systems with LVM?

  1. Connect to the server using SSH.

  2. Make sure that the server uses LVM:

    • The similar output will be returned if LVM is present:

      lvs
      LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
      root centos -wi-ao---- <8.00g
      swap centos -wi-ao---- 1.00g

      Note: centos here is the name of the logical group. It will be used in the further steps

    • The similar output will be returned if LVM is not present:

      lvs
      -bash: lvs: command not found

      lvdisplay -v
      No volume groups found.

      Warning: In this case, solution from the article cannot be applied, as the server does not use LVM.

  3. Start cfdisk to get information about current partition schema:

    cfdisk

    Note: Unallocated disk space will have Free Space FS Type. This space can be used for creation of a partition and for further LVM extension

    2018-08-29_07_50_38-root_test__.png

  4. Select unallocated disk space using arrow buttons and create a new partition by clicking on the [ New ] button:

    2018-08-29_07_53_36-root_test__.png

  5. Follow the wizard to create a Primary partition and its size. Primary type is selected by default, and the default size corresponds to the free disk space size

  6. Click on [ Write ] and then [ Quit ] to confirm create and apply changes to the hard drive partition table:

    2018-08-29_08_00_49-root_test__.png

    Note: The name of the new partition may vary, in this case it is sda3. It will be used in the further steps

  7. Run partprobe to load partition changes in userspace:

    partprobe

  8. Once new partition table is loaded, it is possible to add a new volume to the logical group using its name:

    vgextend centos /dev/sda3
    Physical volume "/dev/sda3" successfully created
    Volume group "centos" successfully extended

    Note: Volume and logical group names may vary, in this case it is centos and sda3. Refer to step 6 and command cfdisk to get volume name and to step 2 and command vgdisplay to get volume group name

  9. Then it is possible to extend logical volume of root directory to add all unused space available in the volume group:

    lvdisplay | grep 'LV Path'
    LV Path /dev/centos/root
    LV Path /dev/centos/swap

    ls -la /dev/centos/root
    lrwxrwxrwx. 1 root root 7 Aug 28 21:14 /dev/centos/root -> ../dm-0

    lsblk /dev/dm-0
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    centos-root 253:0 0 23G 0 lvm /

    Note: Since /dev/centos/root is mounted on the /, as displayed above, it should be resized. Logical volume name may vary

    lvresize -l +100%FREE /dev/centos/root

  10. Extend the partition located on the logical volume:

    Note: To determine file system, run file -sL /dev/centos/root

    For XFS:
    1. Install required packages:

      • For .rpm-based OS (RHEL, CentOS, CloudLinux)

        yum install -y xfsprogs

      • For .deb-based OS (Debian, Ubuntu)

        apt install -y xfsprogs

    2. Grow partition:

      xfs_growfs -d /dev/centos/root

    For ext2/ext3/ext4
    1. Install required packages:

      • For .rpm-based OS (RHEL, CentOS, CloudLinux)

        yum install -y e2fsprogs

      • For .deb-based OS (Debian, Ubuntu)

        apt install -y e2fsprogs

    2. Grow partition:

      resize2fs /dev/centos/root

  11. Check that the disk space has been extended:

    df -h

  • LVM, Centos, plesk
  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

Connecting using PuTTY on Windows workstations

Configuring PuTTY In PuTTY, under Session, enter your Host Name Under Connection choose Data...

How to install the php-mcrypt module on a Plesk server

Question How to install the php-mcrypt module on a Plesk server? Answer Notes: The solution in...

What is Reverse DNS?

Reverse DNS (rDNS) is name resolution that looks up an IP addresses to obtain a domain name,...

How to disable directory browsing globally on whole WHM/cPanel server

o disable directory browsing/listing on whole server, follow these simple instructions: 1. Log...

How to change virtual hosts location in Plesk for Linux?

  In Plesk for Linux, transvhosts.pl utility can be used to change the location for all virtual...