Extend LVM Partition Without Downtime by Adding a New Disk (PV)

Problem Overview

  • In production systems, disk space can run out unexpectedly. Restarting servers to increase disk space is often not an option, especially for critical applications.

  • Linux LVM (Logical Volume Manager) allows you to extend storage online, without stopping services or rebooting the server.

  • In this guide, you’ll learn how to safely extend an LVM partition step by step while the system remains up and running.

  • This approach is widely used in enterprise environments and is a must-know skill for Linux administrators and DevOps engineers.

⚠️ Important Note: Do Not Shrink the Root Filesystem

  • Shrinking the root (/) filesystem is not recommended and is unsafe in real-world environments. The root volume is designed to be extended, not reduced. Once you increase the root filesystem, do not attempt to shrink it.
  • Attempting to shrink / can lead to filesystem corruption, and in many cases the system may fail to boot after a restart. Recovering such a system is extremely difficult and may even be impossible without a full rebuild.

Prerequisites

Before starting, make sure the following conditions are met:

  • The system is using LVM

  • A new disk has been attached to the server

  • You have root or sudo access

  • Filesystem is ext4 or xfs

  • You have verified current disk usage using the command df -h and lsblk

Solution

  • Confirm that the OS detects the newly added disk. You should see the new disk (for example /dev/sdb) without any partitions.
    • [root@pythonlinuxhub ~]# lsblk
      NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
      sda                8:0    0   20G  0 disk
      ├─sda1             8:1    0    1G  0 part /boot
      └─sda2             8:2    0   19G  0 part
        ├─rhel_10-root 253:0    0   17G  0 lvm  /
        └─rhel_10-swap 253:1    0    2G  0 lvm  [SWAP]
      sdb                8:16   0    4G  0 disk
      sr0               11:0    1 1024M  0 rom
  • Initialize the new disk as an LVM physical volume.

    • root@pythonlinuxhub ~]# pvcreate /dev/sdb
        Physical volume "/dev/sdb" successfully created.
      [root@pythonlinuxhub ~]# pvs
        PV         VG      Fmt  Attr PSize   PFree
        /dev/sda2  rhel_10 lvm2 a--  <19.00g    0
        /dev/sdb           lvm2 ---    4.00g 4.00g
  • Add the new physical volume to the existing volume group.
    • [root@pythonlinuxhub ~]# vgextend rhel_10 /dev/sdb
        Volume group "rhel_10" successfully extended
      [root@pythonlinuxhub ~]# vgs
        VG      #PV #LV #SN Attr   VSize  VFree
        rhel_10   2   2   0 wz--n- 22.99g <4.00g
      [root@pythonlinuxhub ~]#
  • You should now see additional free space available in the volume group.

  • Extend the logical volume using all available free space.

    • [root@pythonlinuxhub ~]# lvs
        LV   VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
        root rhel_10 -wi-ao---- <17.00g
        swap rhel_10 -wi-ao----   2.00g
      [root@pythonlinuxhub ~]# lvextend -l +100%FREE /dev/rhel_10/root
        Size of logical volume rhel_10/root changed from <17.00 GiB (4351 extents) to 20.99 GiB (5374 extents).
        Logical volume rhel_10/root successfully resized.
      [root@pythonlinuxhub ~]# lvs
        LV   VG      Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
        root rhel_10 -wi-ao---- 20.99g
        swap rhel_10 -wi-ao----  2.00g
  • At this stage, the logical volume is extended, but the filesystem is not yet resized.

  • Resize the filesystem
    • For ext4 Filesystem
      • [root@pythonlinuxhub ~]# resize2fs /dev/rhel_10/root
    • For xfs Filesystem
      • [root@pythonlinuxhub ~]# xfs_growfs /
    • XFS requires the mount point, not the device path.
  • Verify the updated disk space. You should now see the increased space reflected on the mounted filesystem.
    • [root@pythonlinuxhub ~]# df -h
      Filesystem                Size  Used Avail Use% Mounted on
      devtmpfs                  4.0M     0  4.0M   0% /dev
      tmpfs                     1.8G     0  1.8G   0% /dev/shm
      tmpfs                     732M  9.3M  722M   2% /run
      /dev/mapper/rhel_10-root   21G  8.2G   13G  39% /
      /dev/sda1                 960M  372M  589M  39% /boot
      tmpfs                     366M   96K  366M   1% /run/user/1000
      [root@pythonlinuxhub ~]# lsblk
      NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
      sda                8:0    0   20G  0 disk
      ├─sda1             8:1    0    1G  0 part /boot
      └─sda2             8:2    0   19G  0 part
        ├─rhel_10-root 253:0    0   21G  0 lvm  /
        └─rhel_10-swap 253:1    0    2G  0 lvm  [SWAP]
      sdb                8:16   0    4G  0 disk
      └─rhel_10-root   253:0    0   21G  0 lvm  /
      sr0               11:0    1 1024M  0 rom

Note:

  • Always double-check device names before running LVM commands

  • Take a snapshot or backup before making storage changes

  • Avoid extending root volumes on production servers without proper validation

  • Monitor disk usage after extension to ensure stability

Shaik Mohammed Faruk

Software Engineer sharing practical tutorials and insights on Linux, Python, SQL, and modern technologies.

Read more About Me

0 0 votes
Article Rating
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
trackback

[…] Extend LVM Partition Without Downtime by Adding a New Disk (PV) […]

Thanks for your interest!

Content for this is getting ready and will be published soon.

1
0
Would love your thoughts, please comment.x
()
x