How to Extend a Linux Disk with LVM Without Reboot
This guide walks through a real‑world case where a virtual machine shows only ~30 GB free while a hidden 160 GB disk is detected, and demonstrates step‑by‑step how to use LVM to add, partition, and resize the disk without restarting the system.
In a recent scenario a virtual machine displayed only about 30 GB of free space with df -h, while fdisk -l revealed an unused 160 GB disk that needed to be mounted without rebooting.
The solution relies on Logical Volume Manager (LVM), which provides flexible creation, resizing, and management of logical volumes on top of physical volumes without requiring a system restart.
LVM Overview
LVM uses a three‑layer hierarchy: physical disks are partitioned into Physical Volumes (PV), one or more PVs form a Volume Group (VG), and VGs can host multiple Logical Volumes (LV). Filesystems are created on LVs and can be mounted like regular partitions.
Step‑by‑step Disk Expansion
Check current free space
df -h
Identify the unmounted 160 GB disk
fdisk -l
Create a new partition of type 8e (LVM)
fdisk /dev/sdb
Initialize the partition as a Physical Volume
pvcreate /dev/sdb
Verify the PV creation
pvdisplay
Extend the existing Volume Group (centos) with the new PV
vgextend centos /dev/sdb
Display the VG status
vgdisplay
Resize the logical volume to use all free space
lvextend -l +100%FREE /dev/mapper/centos-root
Grow the XFS filesystem to occupy the enlarged LV
xfs_growfs /dev/mapper/centos-root
Confirm the new capacity
df -h
After these commands the root filesystem expands from about 35 GB to roughly 185 GB, all without rebooting the server.
Reference URLs: https://linux.cn/articles/3218-1.html https://www.cnblogs.com/kevingrace/p/5825963.html
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
