How to Extend Logical Volume in RHEL 8


Most of the Linux/Server administrators will have to deal with No space left errors regularly in their career.

This article explains the steps involved in extending the space in RHEL 8 server. The steps have been verified in RHEL 8.2, but will hold good in all versions of RHEL 8.

$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.2 (Ootpa)

Step 1 - View the Volume Groups

The vgs command is used to view the details of the volume groups in RHEL 8.  

$ vgs

  VG         #PV #LV #SN Attr   VSize   VFree
  VolGroup00   1   6   0 wz--n- <59.50g <7.50g

#PV stands for physical volume and #LV stands for logical volume. The output shows that there is 1 physical volume and 6 logical volumes. The VFree indicated the amount of unallocated space left in the device.

Alternatively, the vgdisaply command will give a much more detailed report about the volume groups.

$ vgdisaply
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               6
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <59.50 GiB
  PE Size               4.00 MiB
  Total PE              15231
  Alloc PE / Size       13312 / 52.00 GiB
  Free  PE / Size       1919 / <7.50 GiB
  VG UUID               1VwmhN-5cuu-R5nl-6EID-3VT6-a0Ml-eH3szS

Step 2 - Extend the Logical Volume

Once you make sure there is enough unallocated space, let us allocate it to the root logical volume group.

$ lvextend -L +5G /dev/mapper/VolGroup00-root_vol

Size of logical volume VolGroup00/root_vol changed from 44.00 GiB (11264 extents) to 49.00 GiB (12544 extents).
  Logical volume VolGroup00/root_vol successfully resized.
In case if you encounter Couldn't create temporary archive name error while trying to extend logical voume with lvextend, free up some space in the root logical volume.

One last step needs to be executed to grow the volume to the new extended space.

$ xfs_growfs /dev/mapper/VolGroup00-root_vol

meta-data=/dev/mapper/VolGroup00-root_vol isize=512    agcount=44, agsize=262144 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=11534336, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 11534336 to 12845056

Step 3 - Verify the Extended Volume Group

To verify the size of the extended volume group, issue the df -khT command.

$ df -khT

Filesystem                           Type      Size  Used Avail Use% Mounted on
devtmpfs                             devtmpfs  3.8G     0  3.8G   0% /dev
tmpfs                                tmpfs     3.9G     0  3.9G   0% /dev/shm
tmpfs                                tmpfs     3.9G   57M  3.8G   2% /run
tmpfs                                tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/VolGroup00-root_vol      xfs        49G   43G  6.3G  88% /
/dev/mapper/VolGroup00-var_vol       xfs       3.0G  1.6G  1.5G  53% /var
/dev/mapper/VolGroup00-tmp_vol       xfs      1014M   40M  975M   4% /tmp
/dev/sda1                            xfs       507M  169M  339M  34% /boot
/dev/mapper/VolGroup00-var_log_audit xfs      1014M   72M  943M   8% /var/log/audit
/dev/mapper/VolGroup00-home_vol      xfs      1014M   40M  975M   4% /home
tmpfs                                tmpfs     782M     0  782M   0% /run/user/54321
tmpfs                                tmpfs     782M     0  782M   0% /run/user/0

Nithya Binoy

Nithya Binoy