LVM - lvm

LVM is a storage management framework rather than a file system. It is used to manage physical storage devices, allowing you to create a number of logical storage volumes that use and virtualize the underlying physical storage devices.

Note that it is possible to over-commit the physical storage in the process, to allow flexibility for scenarios where not all available storage is in use at the same time.

To use LVM, make sure you have lvm2 installed on your machine.

Terminology

LVM can combine several physical storage devices into a volume group. You can then allocate logical volumes of different types from this volume group.

One supported volume type is a thin pool, which allows over-committing the resources by creating thinly provisioned volumes whose total allowed maximum size (quota) is larger than the available physical storage. Another type is a volume snapshot, which captures a specific state of a logical volume.

lvm driver in LXD

The lvm driver in LXD uses logical volumes for images, and volume snapshots for instances and snapshots.

LXD assumes that it has full control over the volume group. Therefore, you should not maintain any file system entities that are not owned by LXD in an LVM volume group, because LXD might delete them. However, if you need to reuse an existing volume group (for example, because your setup has only one volume group), you can do so by setting the lvm.vg.force_reuse configuration.

By default, LVM storage pools use an LVM thin pool and create logical volumes for all LXD storage entities (images, instances and custom volumes) in there. This behavior can be changed by setting lvm.use_thinpool to false when you create the pool. In this case, LXD uses “normal” logical volumes for all storage entities that are not snapshots. Note that this entails serious performance and space reductions for the lvm driver (close to the dir driver both in speed and storage usage). The reason for this is that most storage operations must fall back to using rsync, because logical volumes that are not thin pools do not support snapshots of snapshots. In addition, non-thin snapshots take up much more storage space than thin snapshots, because they must reserve space for their maximum size (quota) at creation time. Therefore, this option should only be chosen if the use case requires it.

For environments with a high instance turnover (for example, continuous integration) you should tweak the backup retain_min and retain_days settings in /etc/lvm/lvm.conf to avoid slowdowns when interacting with LXD.

Configuration options

The following configuration options are available for storage pools that use the lvm driver and for storage volumes in these pools.

Storage pool configuration

lvm.thinpool_metadata_size

The size of the thin pool metadata volume

lvm.thinpool_name

Thin pool where volumes are created

lvm.use_thinpool

Whether the storage pool uses a thin pool for logical volumes

lvm.vg.force_reuse

Force using an existing non-empty volume group

lvm.vg_name

Name of the volume group to create

rsync.bwlimit

Upper limit on the socket I/O for rsync

rsync.compression

Whether to use compression while migrating storage pools

size

Size of the storage pool (for loop-based pools)

source

Path to an existing block device, loop file, or LVM volume group

source.wipe

Whether to wipe the block device before creating the pool

Tip

In addition to these configurations, you can also set default values for the storage volume configurations. See Configure default values for storage volumes.

Storage volume configuration

block.filesystem

File system of the storage volume

block.mount_options

Mount options for block-backed file system volumes

lvm.stripes

Number of stripes to use for new volumes (or thin pool volume)

lvm.stripes.size

Size of stripes to use

security.shared

Enable volume sharing

security.shifted

Enable ID shifting overlay

security.unmapped

Disable ID mapping for the volume

size

Size/quota of the storage volume

snapshots.expiry

When snapshots are to be deleted

snapshots.pattern

Template for the snapshot name

snapshots.schedule

Schedule for automatic volume snapshots

volatile.idmap.last

JSON-serialized UID/GID map that has been applied to the volume

volatile.idmap.next

JSON-serialized UID/GID map that has been applied to the volume

volatile.uuid

The volume’s UUID

Storage bucket configuration

To enable storage buckets for local storage pool drivers and allow applications to access the buckets via the S3 protocol, you must configure the core.storage_buckets_address server setting.

size

Size/quota of the storage bucket