Skip to content

Logical Volumes

Logical volumes and logical volume management make it easier to manage disk space. Physical devices are the storage devices used to save data stored in a logical volume. Initialize a device as a physical volume before using it in an LVM system (PVs). Volume groups are storage pools made up of one or more physical volumes (VGs). Logical volumes (LVs) are created from free physical extents in a volume group and provide the "storage" device used by applications, users, and the operating system.

Use parted or fdisk to create a new partition for use with LVM.

fdsik /dev/vdc

fdisk process would be n, p, 1, 2048, +1G, t, 8e and w.

Usepvcreate to label the partition as a physical volume.

pvcreate /dev/vdc1

Use vgcreate to collect one or more physical volumes into a volume group.

vgcreate data /dev/vdc1

Use lvcreate to create a new logical volume from the available physical extents in a volume group.

lvcreate -n dv01 -L 500M data

Add an xfs file system on the new logical volume.

mkfs.xfs /dev/data/dv01

The device /dev/data/dv01 can now be mounted in the standard way.

The above process can be done using lvremove, vgremove and pvremove.

To display information use pvdisplay, vgdisplay and lvdisplay and for a summary use pvs, vgs and lvs.

You can add more disk space to a volume group by adding additional physical volumes, called extending the volume group. Then, you can assign the new physical extents from the additional physical volumes to logical volumes. You can remove unused physical volumes from a volume group called reducing the volume group.

Use vgextend to add the new physical volume to the volume group.

vgextend vg01 /dev/vdb3

To reduce a volume group first relocate physical extents from the physical volume to be removed.

Use pvmove /dev/vdb3 command to move PEs from /dev/vdb3. Always backup any data stored on all logical volumes in a volume group before reducing sizes.

Use vgreduce vg01 /dev/vdb3 to remove a physical volume from a volume group.

Use lvextend to extend the logical volume to a new size.

lvextend -L +300M /dev/vg01/lv01

Use the -r argument with lvextend to avoid a manual second step of xfs_growfs. For ext4 file systems use resize2fs.

Stratis

Stratis simplifies many aspects of local storage provisioning and configuration. Stratis uses the backstore subsystem to manage the block devices, and the thinpool subsystem to manage the pools. Stratis supports file-system snapshotting.

To manage the thin-provisioned file systems using the Stratis storage management solution, install the stratis-cli and stratisd packages.

dnf install stratis-cli stratisd -y
systemctl enable --now stratisd

Create pools of block devices using the stratis pool create command:

stratis pool create pool1/dev/vdb

Use the stratis pool list command to view the list of available pools. Use the stratis pool add-data command to add additional block devices to a pool:

stratis pool add-data pool1/dev/vdc

Use the stratis blockdev list command to view the block devices of a pool. Use the stratis filesystem create command to create a dynamic and flexible file system from a pool:

stratis filesystem create pool1filesystem1

Example entry in the /etc/fstab file to persistently mount a Stratis file system.

UUID=42b9...8c52 /data  xfs defaults,x-systemd.requires=stratisd.service 0 0

Create a volume snapshot:

stratis filesystem snapshot pool myfs myfs-snap

Virtual Data Optimizer

The Virtual Data Optimizer (VDO) driver optimizes the data footprint on block devices. VDO is a Linux device-mapper driver that reduces disk space usage on block devices, and minimizes the replication of data, saving disk space and even increasing data throughput.

Logical devices that you create using VDO are called VDO volumes. VDO volumes are similar to disk partitions.

Install the vdo and kmod-kvdo packages to enable VDO in the system:

dnf install vdo kmod-kvdo -y
Use the vdo create command to create a VDO volume:
vdo create --name=vdo1 --device=/dev/vdb --vdoLogicalSize=10G
Using vdo status displays a report on the VDO system and the status of the VDO volume.
vdo status --name=vdo1

This can be formatted and used like any other volume:

mkfs.xfs -K /dev/mapper/vdo1
mount /dev/mapper/vdo1 /data

View usage:

vdostats --human-readable

Mounting a vdo filesystem in /etc/fstab requires defaults,x-systemd.requires=vdo.service.

Summary

Physical volumes, volume groups, and logical volumes are managed by a variety of tools such as pvcreate, vgreduce, and lvextend and can be formatted with a file system or swap space. Additional storage can be added to volume groups, and logical volumes can be extended dynamically.

The Stratis volume-management solution implements flexible file systems that grow dynamically with data. Stratis volume-management solution supports thin provisioning, snapshotting, and monitoring.

The Virtual Data Optimizer (VDO) aims to reduce the cost of data storage. The Virtual Data Optimizer applies zero-block elimination, data deduplication, and data compression to optimize disk space efficiency.

Command References:

lvm, pvcreate, vgcreate, lvcreate, pvremove, vgremove, lvremove, lvextend, vgextend, pvdisplay, vgdisplay, lvdisplay, fdisk, stratis, vdo, xfs_growfs and resize2fs.