Thursday, July 2, 2026

How To Increase a Logical Volume (System Partition) on a Red Hat Enterprise Linux (RHEL) 9.x Virtual Server

Warning:  Do not attempt this procedure on a production system without making a reliable backup.  If done incorrectly there is the potential to destroy the virtual disk and require a complete re-install of the system. This article also assumes the underlying Linux file systems are the Red Hat Enterprise Linux default type XFS. 

Let's say you notice after you built a RHEL 9.x server that the /var/log partition isn't large enough and that it needs to be 2 Gig instead of 1 Gig. 

Take note of the existing partition table for the system's virtual disk.

# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sr0 11:0 1 1024M 0 rom
vda 252:0 0 85G 0 disk
├─vda1 252:1 0 1G 0 part /boot/efi
├─vda2 252:2 0 1G 0 part /boot
└─vda3 252:3 0 83G 0 part
├─rhel_rhel98-root 253:0 0 20G 0 lvm /
├─rhel_rhel98-swap 253:1 0 8G 0 lvm [SWAP]
├─rhel_rhel98-var_log 253:2 0 1G 0 lvm /var/log
├─rhel_rhel98-tmp 253:3 0 10G 0 lvm /tmp
├─rhel_rhel98-var 253:4 0 20G 0 lvm /var
├─rhel_rhel98-home 253:5 0 20G 0 lvm /home
├─rhel_rhel98-var_tmp 253:6 0 2G 0 lvm /var/tmp
└─rhel_rhel98-var_log_audit 253:7 0 2G 0 lvm /var/log/audit

Notice that the /dev/vda3 partition is the last partition on the disk and it has the partition type for containing Linux logical volumes.  

# fdisk -l /dev/vda
Disk /dev/vda: 85 GiB, 91268055040 bytes, 178257920 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F01214C1-2860-4C76-9C65-AF38B27671F5

Device       Start       End   Sectors Size Type
/dev/vda1     2048   2099199   2097152   1G EFI System
/dev/vda2  2099200   4196351   2097152   1G Linux filesystem
/dev/vda3  4196352 178255871 174059520  83G Linux LVM

Here is a brief overview of how we will accomplish adding additional disk space to the virtual machine and then to the /var/log logical volume.  

  • Shutdown the VM/virtual server
  • Extend the underlying virtual disk from the hypervisor
  • Boot the VM back up.  
  • Delete the /dev/vda3 partition from the partition table
  • Re-create the /dev/vda3 partition with the additional new sectors
  • Write the new partition table to the virtual disk
  • Update the logical volume manager's physical volume to see the added space
  • Allocate new space to the /var/log logical volume.

Our hypervisor for this example is running QEMU, KVM and Virt-Manager on Ubuntu.

 Setting Up Virtual Machines with QEMU, KVM, and Virt-Manager on Debian/Ubuntu

On this system we need to use the virsh command line utility on the host (hypervisor) to increase the underlying virtual disk.  On a VMware system we would use the VSphere web GUI to increase the underlying disk.  

Below we find the location for the hypervisor file that contains our virtual disk and then increase it's size. But before that we need to shutdown our RHEL 9.x server from within the VM.

# shutdown -h now
Broadcast message from root@RHEL98 on pts/1 (Fri 2026-06-26 15:57:35 EDT):

The system will power off now!

From command line on the hypervisor system.

$ virsh list --all
 Id   Name     State
------------------------
 -    RHEL98   shut off

$ virsh dominfo RHEL98
Id: -
Name: RHEL98
UUID: 5529e3e2-6610-4c69-bf4c-6da0dc34f945
OS Type: hvm
State: shut off
CPU(s): 4
CPU time: 339.9s
Max memory: 4194304 KiB
Used memory: 4194304 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: apparmor
Security DOI: 0

$ virsh domblklist RHEL98
Target Source
------------------------------------------------
vda /var/lib/libvirt/images/RHEL98.qcow2
sda -

$ sudo qemu-img resize /var/lib/libvirt/images/RHEL98.qcow2 +1G
Image resized.

Restart the VM with the command below or use the virt-manager GUI application.

$ virsh start RHEL98
Domain 'RHEL98' started

Secure shell back into the VM and inspect the partition table

$ sudo -i
[sudo] password for john: 

# fdisk -l /dev/vda
GPT PMBR size mismatch (178257919 != 180355071) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/vda: 86 GiB, 92341796864 bytes, 180355072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F01214C1-2860-4C76-9C65-AF38B27671F5

Device       Start       End   Sectors Size Type
/dev/vda1     2048   2099199   2097152   1G EFI System
/dev/vda2  2099200   4196351   2097152   1G Linux filesystem
/dev/vda3  4196352 178255871 174059520  83G Linux LVM

Now we will delete and recreate the partition table.
# fdisk /dev/vda

Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

GPT PMBR size mismatch (178257919 != 180355071) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.



Command (m for help): d (delete a partition)
Partition number (1-3, default 3): 3

Partition 3 has been deleted.

Command (m for help): n (add a new partition)
Partition number (3-128, default 3): 3
First sector (4196352-180355038, default 4196352): <Enter>
Last sector, +/-sectors or +/-size{K,M,G,T,P} (4196352-180355038, default 180355038): <Enter>

Created a new partition 3 of type 'Linux filesystem' and of size 84 GiB.
Partition #3 contains a LVM2_member signature.

Do you want to remove the signature? [Y]es/[N]o: N

Command (m for help): t (change partition type)
Partition number (1-3, default 3): 3
Partition type or alias (type L to list all): L
...
 19 Linux swap                     0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
20 Linux filesystem 0FC63DAF-8483-4772-8E79-3D69D8477DE4
21 Linux server data 3B8F8425-20E0-4F3B-907F-1A25A76F98E8
22 Linux root (x86) 44479540-F297-41B2-9AF7-D131D5F0458A
23 Linux root (x86-64) 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709
24 Linux root (ARM) 69DAD710-2CE4-4E3C-B16C-21A1D49ABED3
25 Linux root (ARM-64) B921B045-1DF0-41C3-AF44-4C6F280D3FAE
26 Linux root (IA-64) 993D8D3D-F80E-4225-855A-9DAF8ED7EA97
27 Linux reserved 8DA63339-0007-60C0-C436-083AC8230908
28 Linux home 933AC7E1-2EB4-4F13-B844-0E14E2AEF915
29 Linux RAID A19D880F-05FC-4D3B-A006-743F0F84911E
30 Linux LVM E6D6D379-F507-44C2-A23C-238F2A3DF928
31 Linux variable data 4D21B016-B534-45C2-A9FB-5C16E091FD2D
32 Linux temporary data 7EC6F557-3BC5-4ACA-B293-16EF5DF639D1
33 Linux /usr (x86) 75250D76-8CC6-458E-BD66-BD47CC81A812
34 Linux /usr (x86-64) 8484680C-9521-48C6-9C11-B0720656F69E
35 Linux /usr (ARM) 7D0359A3-02B3-4F0A-865C-654403E70625
36 Linux /usr (ARM-64) B0E01050-EE5F-4390-949A-9101B17104E9
37 Linux /usr (IA-64) 4301D2A6-4E3B-4B2A-BB94-9E0B2C4225EA
38 Linux root verity (x86) D13C5D3B-B5D1-422A-B29F-9454FDC89D76
39 Linux root verity (x86-64) 2C7357ED-EBD2-46D9-AEC1-23D437EC2BF5
40 Linux root verity (ARM) 7386CDF2-203C-47A9-A498-F2ECCE45A2D6
41 Linux root verity (ARM-64) DF3300CE-D69F-4C92-978C-9BFB0F38D820
42 Linux root verity (IA-64) 86ED10D5-B607-45BB-8957-D350F23D0571
43 Linux /usr verity (x86) 8F461B0D-14EE-4E81-9AA9-049B6FB97ABD
44 Linux /usr verity (x86-64) 77FF5F63-E7B6-4633-ACF4-1565B864C0E6
45 Linux /usr verity (ARM) C215D751-7BCD-4649-BE90-6627490A4C05
46 Linux /usr verity (ARM-64) 6E11A4E7-FBCA-4DED-B9E9-E1A512BB664E
47 Linux /usr verity (IA-64) 6A491E03-3BE7-4545-8E38-83320E0EA880
48 Linux extended boot BC13C2FF-59E6-4262-A352-B275FD6F7172
49 Linux user's home 773f91ef-66d4-49b5-bd83-d683bf40ad16
...
Partition type or alias (type L to list all): 30 (will not always be this number)

Changed type of partition 'Linux filesystem' to 'Linux LVM'.

Command (m for help): p (print the partition table)

Disk /dev/vda: 86 GiB, 92341796864 bytes, 180355072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F01214C1-2860-4C76-9C65-AF38B27671F5

Device Start End Sectors Size Type
/dev/vda1 2048 2099199 2097152 1G EFI System
/dev/vda2 2099200 4196351 2097152 1G Linux filesystem
/dev/vda3 4196352 180355038 176158687 84G Linux LVM

Command (m for help): w (write table to disk and exit)
The partition table has been altered.
Syncing disks.
Now make sure the Red Hat OS sees the change.

# partprobe
# partx -u /dev/vda

Resize the physical volume Red Hat sees.

# pvs
  PV         VG          Fmt  Attr PSize   PFree
  /dev/vda3  rhel_rhel98 lvm2 a--  <83.00g    0 

# pvresize /dev/vda3
  Physical volume "/dev/vda3" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

# pvs
  PV         VG          Fmt  Attr PSize   PFree
  /dev/vda3  rhel_rhel98 lvm2 a--  <84.00g 1.00g

Extend the logical volume inside Red Hat.

# lvscan
  ACTIVE            '/dev/rhel_rhel98/var_log' [1.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/tmp' [10.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/var' [20.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/root' [20.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/home' [20.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/swap' [8.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/var_tmp' [2.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/var_log_audit' [<2.00 GiB] inherit

NOTE: There are two variations of the lvextend command, the 1st allocates specific amounts of space to the LV. For example: lvextend -r -L +1G /dev/rhel_rhel98/var_log just adds 1Gig to the LV from the free space available on the PV. The other variation that we will be using here, adds ALL the available free space on the PV to the LV.

# lvextend -r -l +100%FREE /dev/rhel_rhel98/var_log
  File system xfs found on rhel_rhel98/var_log mounted at /var/log.
  Size of logical volume rhel_rhel98/var_log changed from 1.00 GiB (256 extents) to 2.00 GiB (512 extents).
  Extending file system xfs to 2.00 GiB (2147483648 bytes) on rhel_rhel98/var_log...
xfs_growfs /dev/rhel_rhel98/var_log
meta-data=/dev/mapper/rhel_rhel98-var_log isize=512    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=1 inobtcount=1 nrext64=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=16384, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 262144 to 524288
xfs_growfs done
  Extended file system xfs on rhel_rhel98/var_log.
  Logical volume rhel_rhel98/var_log successfully resized.

# lvscan
  ACTIVE            '/dev/rhel_rhel98/var_log' [2.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/tmp' [10.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/var' [20.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/root' [20.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/home' [20.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/swap' [8.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/var_tmp' [2.00 GiB] inherit
  ACTIVE            '/dev/rhel_rhel98/var_log_audit' [<2.00 GiB] inherit

The /var/log logical volume is now 2 Gig in size.   

# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sr0 11:0 1 1024M 0 rom
vda 252:0 0 86G 0 disk
├─vda1 252:1 0 1G 0 part /boot/efi
├─vda2 252:2 0 1G 0 part /boot
└─vda3 252:3 0 84G 0 part
├─rhel_rhel98-root 253:0 0 20G 0 lvm /
├─rhel_rhel98-swap 253:1 0 8G 0 lvm [SWAP]
├─rhel_rhel98-var_log 253:2 0 2G 0 lvm /var/log
├─rhel_rhel98-tmp 253:3 0 10G 0 lvm /tmp
├─rhel_rhel98-var 253:4 0 20G 0 lvm /var
├─rhel_rhel98-home 253:5 0 20G 0 lvm /home
├─rhel_rhel98-var_tmp 253:6 0 2G 0 lvm /var/tmp
└─rhel_rhel98-var_log_audit 253:7 0 2G 0 lvm /var/log/audit

  
While this is definitely a non-trivial procedure, you can (if done correctly) reliably extend filesystems on virtualized Linux systems. 

 

No comments:

Post a Comment