LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes. LVM physical volumes can be placed on other block devices which might span two or more disks.
The physical volumes are combined into logical volumes, with the exception of the /boot/ partition. The /boot/ partition cannot be on a logical volume group because the boot loader cannot read it. If the root (/) partition is on a logical volume, create a separate /boot/ partition which is not a part of a volume group.
Since a physical volume cannot span over multiple drives, to span over more than one drive, create one or more physical volumes per drive.
You can then access the application by selecting from your menu panel System → Administration →Logical Volume Management. Alternatively you can start the Logical Volume Management utility by typing system -config-lvm from a terminal
Basic configuration Steps when installing OS
1. Create standard partition /boot
2. Create n physical volumes
3. Create volume group (add n physical volumes)
4. Create logical volume mounted on /
5. Create logical volume swap
6. Create logical volume mounted on /home
There are many commands and management utilities for working with LVM. Here is an overview of them
[root@redhat ~]# pvdisplay Displays detailed information on physical volumes
[root@redhat ~]# vgdisplay Displays detailed information on volume groups
Migrating Data
Suppose you have a drive that is old or dying and you’d like to remove it from the system. On a system with normal partitions, you would have to copy all the data from one disk to another while the disk is offline (because of file locks). Having LVM makes this easier because you can migrate your data from one disk to another, even while the disk is online! This capability is very useful when you need to replace a disk. If you want to replace /dev/hdb because it’s failing, you can use the pvmove command to migrate the physical extents (which is really your data) to another physical volume (/dev/hdc). Because you removed /dev/hdc from the volume group in the previous section, you need to add it back.
# pvmove /dev/hdb /dev/hdc
Creating LVM Logical Volumes
Creating Volumes
Steps
Create n Physical Volumes
Create Volume Group: add n Physical Volumes in a volume Group
Create m Logical Volumes
Make an Filesystem on Logical Volume
Mount Filesystem
Physical Volume
Create a new physical volume [root@redhat ~]# pvcreate special file
Example
Displays physical volumes [root@redhat ~]# pvs
Displays detailed information on physical volumes [root@redhat ~]# pvdisplay
Resizing LVM Logical Volumes
[root@rhel8 user1]# vgextend Extends an existing volume group
[root@rhel8 user1]# lvextend Extends a logical volume
[root@redhat ~]# pvresize /dev/sda1 Expand the PV on /dev/sda1 after enlarging the partition with fdisk
[root@rhel8 user1]# lvresize Resizes a logical volume
[root@rhel8 user1]# lvreduce Reduces a logical volume
[root@rhel8 user1]# lvrename Renames a logical volume
[root@rhel8 user1]# pvmove Moves/migrates data from one physical volume to another
[root@rhel8 user1]# vgreduce Reduces a volume group
[root@rhel8 user1]# pvremove Removes a physical volume
Configuring Stratis
Stratis
In RHEL 8, Red Hat has added two advanced storage types: Stratis and VDO.
Stratis is a so-called volume-managing file system, and it introduces advanced storage features that were not available in previous versions of RHEL:
• Thin provisioning: This feature enables a Stratis file to present itself to users as much bigger than it really is. This is useful in many environments, such as virtual desktops, where each user may see 20 GiB of available storage in total although a much lower amount is actually provisioned to each user.
• Snapshots: A Stratis snapshot allows users to take a “picture” of the current state of a file system. This snapshot makes it easy to revert to the previous state of a file system, rolling back any changes that have been made.
• Cache tier: Cache tier is a Ceph storage feature that ensures that data can be stored physically closer to the Ceph client, which makes data access faster.
• Programmatic API: The programmatic API ensures that storage can easily be configured and modified through API access. This is particularly interesting in cloud environments, where setting up storage directly from cloud-native applications is extremely useful.
• Monitoring and repair: Whereas old file systems need tools like fsck to verify the integrity of the file system, Stratis has built-in features to monitor the health of the file system and repair it if necessary.
Stratis Architecture
The lowest layer in the Stratis architecture is the pool. From a functional perspective, the Stratis pool is comparable to an LVM volume group. A pool represents all the available storage and consists of one or more storage devices, which in a Stratis environment are referred to as blockdev. These block devices may not be thin provisioned at the underlying hardware level. Stratis creates a /dev/stratis/poolname directory for each pool.
From the Stratis pool, XFS file systems are created. Note that Stratis only works with XFS, and the XFS file system it uses is integrated with the Stratis volume. When creating a file system, no size is specified, and each file system can grow up to the size of all the available storage space in the pool. Stratis file systems are always thin provisioned. The thin volume automatically grows as more data is added to the file system.