In this lesson, we explore the Logical Volume Manager (LVM), a powerful tool that enables you to group multiple physical volumes (disks or partitions) into a single volume group (VG). From the volume group, you can then allocate one or more logical volumes (LVs). While our example uses three partitions, LVM is flexible enough to work with a single disk, multiple disks, or even an unlimited number of partitions grouped under a single VG.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
One of LVM’s most significant advantages is its ability to resize logical volumes dynamically, provided there is sufficient free space in the volume group. This feature is especially useful for systems with changing storage requirements.
Prerequisites
Before you begin, ensure that the LVM2 package is installed on your system. Use the command below to install LVM2:Step 1: Create a Physical Volume
The initial step in configuring LVM is to identify available disks or partitions and create physical volumes (PVs) from them. A physical volume represents the disk or partition in LVM. For example, to create a physical volume on the device path/dev/sdb, execute:
Step 2: Create a Volume Group
Once the physical volume is established, create a volume group (VG) that will host your logical volumes. In this example, the VG is namedcaleston_vg and includes /dev/sdb:
Step 3: Create a Logical Volume
After establishing the volume group, create a logical volume (LV). In this example, we create a 1GB LV namedvol1 within the caleston_vg volume group:
Step 4: Create and Mount a Filesystem
With your logical volume in place, the next step is to create a filesystem on it. In this example, we create an ext4 filesystem on/dev/caleston_vg/vol1:
/mnt/vol1) to make it accessible:
Step 5: Resize the Logical Volume and Filesystem
Sometimes you may need to expand the logical volume while it remains mounted. Begin by verifying that there is sufficient free space in the volume group:At this stage, even after resizing the logical volume, the filesystem will still report its original size (1GB) when using the
df command because only the LV has been extended. It is essential to also resize the filesystem with the resize2fs command.Access Paths for the Logical Volume
It’s important to note that the logical volume can be accessed through two different paths:- /dev/caleston_vg/vol1
- /dev/mapper/caleston_vg-vol1