How to resize a disk with LVM in Linux

  1. Log in to the device console as root
  2. Check the devices of the virtual machine.
    lsblk
  3. Extend the partition

    cfdisk

  4. Resize the Physical Volume

    pvresize /dev/sda3

  5. Resize the Logical Volume
    For Debian
    lvextend -l +100%FREE /dev/mapper/hostname--vg-root
    For Almalinux

    lvextend -l +100%FREE /dev/mapper/almalinux-root

    For Ubuntu

    lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

  6. Verify the type of filesystem

    df -T

  7. Resize the filesystem
    For EXT4
    resize2fs /dev/ubuntu-vg/ubuntu-lv
    For XFS 

    xfs_growfs /dev/mapper/almalinux-rootxxxzx