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.
fdisk
process would be n
, p
, 1
, 2048
, +1G
, t
, 8e
and w
.
Usepvcreate
to label the partition as a physical volume.
Use vgcreate
to collect one or more physical volumes into a volume group.
Use lvcreate
to create a new logical volume from the available physical extents in a volume group.
Add an xfs
file system on the new logical volume.
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.
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.
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.
Create pools of block devices using the stratis pool create
command:
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:
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:
Example entry in the /etc/fstab
file to persistently mount a Stratis file system.
Create a volume snapshot:
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:
vdo create
command to create a VDO volume:
Using vdo status
displays a report on the VDO system and the status of the VDO volume.
This can be formatted and used like any other volume:
View usage:
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
.