How to Create and Manage LVM (Logical Volume Management) in Linux
Jul 25, 2025 am 02:08 AMLVM in Linux allows flexible storage management by abstracting physical disks into logical volumes. 2. The core components are Physical Volumes (PVs), Volume Groups (VGs), and Logical Volumes (LVs), forming a layered structure. 3. To set up LVM, first initialize disks as PVs using pvcreate, then combine them into a VG with vgcreate, create LVs from the VG using lvcreate, and finally format and mount the LVs like regular partitions. 4. LVM supports dynamic resizing: extend LVs by adding space with lvextend and resizing the filesystem, reduce LVs only after shrinking the filesystem to avoid data loss, and expand VGs by adding new PVs with vgextend. 5. To remove LVM components, unmount LVs, then remove LVs, VGs, and PVs in sequence using lvremove, vgremove, and pvremove. 6. Useful tips include using descriptive names, monitoring storage with vgs/lvs, creating snapshots for backups, and exploring thin provisioning for advanced use cases. 7. Always back up data before modifying volumes and follow correct operation order to prevent data loss. LVM simplifies storage management and provides greater flexibility than traditional partitioning when properly used.
Logical Volume Management (LVM) in Linux provides a flexible way to manage disk storage. Unlike traditional partitioning, LVM allows you to resize volumes on the fly, combine multiple physical disks into one large volume group, and create snapshots for backups. Here's how to create and manage LVM step by step.

1. Understanding LVM Components
Before diving into commands, it's important to know the core components of LVM:
-
Physical Volume (PV): A physical storage device (e.g.,
/dev/sdb
,/dev/sdc
) or partition (e.g.,/dev/sdb1
) that has been initialized for use by LVM. - Volume Group (VG): A pool of storage created by combining one or more physical volumes.
- Logical Volume (LV): A partition-like block device created from a volume group. You can format and mount LVs like regular partitions.
This layered structure gives LVM its flexibility.

2. Creating LVM: Step-by-Step Setup
Let’s assume you have two new disks: /dev/sdb
and /dev/sdc
. We’ll use them to create an LVM setup.
Step 1: Create Physical Volumes
Initialize the disks or partitions as physical volumes using pvcreate
:

sudo pvcreate /dev/sdb /dev/sdc
Verify with:
sudo pvs
or for detailed info:
sudo pvdisplay
Step 2: Create a Volume Group
Combine the physical volumes into a volume group (e.g., vg_data
):
sudo vgcreate vg_data /dev/sdb /dev/sdc
Check the result:
sudo vgs
or
sudo vgdisplay
Now you have a storage pool named vg_data
with combined capacity from both disks.
Step 3: Create Logical Volumes
From the volume group, create a logical volume. For example, create a 10GB LV named lv_home
:
sudo lvcreate -L 10G -n lv_home vg_data
You can also use percentages of free space:
sudo lvcreate -l 50%FREE -n lv_temp vg_data
(Note: -l
uses extents; -L
uses size like GB.)
Check with:
sudo lvs
or
sudo lvdisplay
Step 4: Format and Mount the Logical Volume
Format the LV with a filesystem (e.g., ext4):
sudo mkfs.ext4 /dev/vg_data/lv_home
Create a mount point and mount it:
sudo mkdir /mnt/data sudo mount /dev/vg_data/lv_home /mnt/data
To auto-mount at boot, add an entry to /etc/fstab
:
/dev/vg_data/lv_home /mnt/data ext4 defaults 0 0
3. Managing LVM: Resize, Extend, and Reduce
One of LVM’s biggest advantages is dynamic resizing.
Extend a Logical Volume
If you need more space, first ensure the volume group has free space.
To extend lv_home
by 5GB:
sudo lvextend -L 5G /dev/vg_data/lv_home
Then resize the filesystem:
- For ext2/ext3/ext4:
sudo resize2fs /dev/vg_data/lv_home
- For xfs:
sudo xfs_growfs /mnt/data
?? Always extend the LV before resizing the filesystem.
Reduce a Logical Volume (Careful!)
Reducing is riskier and requires unmounting the filesystem.
Unmount:
sudo umount /mnt/data
Check and shrink the filesystem first:
sudo e2fsck -f /dev/vg_data/lv_home sudo resize2fs /dev/vg_data/lv_home 8G
Then reduce the LV:
sudo lvreduce -L 8G /dev/vg_data/lv_home
Remount:
sudo mount /dev/vg_data/lv_home /mnt/data
?? Never shrink the LV before the filesystem — data loss will occur.
Extend a Volume Group
If your VG runs out of space, add another physical disk.
Example: Add /dev/sdd
sudo pvcreate /dev/sdd sudo vgextend vg_data /dev/sdd
Now you can extend LVs using the new space.
4. Removing LVM Components (Optional)
If you need to clean up:
Unmount the LV:
sudo umount /mnt/data
Remove the logical volume:
sudo lvremove /dev/vg_data/lv_home
Remove the volume group:
sudo vgremove vg_data
Remove physical volume metadata:
sudo pvremove /dev/sdb /dev/sdc
Bonus: Useful LVM Tips
- Use meaningful names: Name VGs and LVs descriptively (e.g.,
vg_db
,lv_www
). - Monitor usage: Use
sudo vgs
andsudo lvs
regularly. - Snapshots: Create point-in-time snapshots for backups:
sudo lvcreate -L 2G -s -n lv_home_snap /dev/vg_data/lv_home
-
Thin provisioning: For advanced use, explore thin pools with
lvcreate --thin
.
LVM gives you powerful control over storage. Once set up, managing disk space becomes much more flexible than traditional partitioning. Just remember to always back up critical data before resizing or removing volumes.
Basically, it’s not complex — just pay attention to the order of operations.
The above is the detailed content of How to Create and Manage LVM (Logical Volume Management) in Linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

Firefox browser is the default browser for most modern Linux distributions such as Ubuntu, Mint, and Fedora. Initially, its performance might be impressive, however, with the passage of time, you might notice that your browser is not as fast and resp

When encountering DNS problems, first check the /etc/resolv.conf file to see if the correct nameserver is configured; secondly, you can manually add public DNS such as 8.8.8.8 for testing; then use nslookup and dig commands to verify whether DNS resolution is normal. If these tools are not installed, you can first install the dnsutils or bind-utils package; then check the systemd-resolved service status and configuration file /etc/systemd/resolved.conf, and set DNS and FallbackDNS as needed and restart the service; finally check the network interface status and firewall rules, confirm that port 53 is not

If you find that the server is running slowly or the memory usage is too high, you should check the cause before operating. First, you need to check the system resource usage, use top, htop, free-h, iostat, ss-antp and other commands to check CPU, memory, disk I/O and network connections; secondly, analyze specific process problems, and track the behavior of high-occupancy processes through tools such as ps, jstack, strace; then check logs and monitoring data, view OOM records, exception requests, slow queries and other clues; finally, targeted processing is carried out based on common reasons such as memory leaks, connection pool exhaustion, cache failure storms, and timing task conflicts, optimize code logic, set up a timeout retry mechanism, add current limit fuses, and regularly pressure measurement and evaluation resources.

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

Frankly speaking, I cannot recall the last time I used a PC with a CD/DVD drive. This is thanks to the ever-evolving tech industry which has seen optical disks replaced by USB drives and other smaller and compact storage media that offer more storage

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.

Built on Chrome’s V8 engine, Node.JS is an open-source, event-driven JavaScript runtime environment crafted for building scalable applications and backend APIs. NodeJS is known for being lightweight and efficient due to its non-blocking I/O model and
