Thin Provisioning

Explore this Page

Overview

Thin Provisioning is a storage optimization strategy that enables the allocation of storage resources on-demand, rather than pre-allocating the entire storage upfront. This approach is particularly beneficial for maximizing storage utilization and delaying hardware expansion costs.

You can create virtual volumes that appear larger than the available physical capacity by using thin provisioning techniques. However, it is important to monitor and manage these volumes to avoid performance degradation or storage depletion.

Creating a Thin-Provisioned Volume for Replicated PV Mayastor

To enable thin provisioning, set thin: true under the parameters specification in the StorageClass definition. Refer to the StorageClass Parameters Documentation for more information.

Copy
StorageClass Definition for Thin-Provisioned Volume for Replicated PV Mayastor
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: mayastor-1
parameters:
  protocol: nvmf
  repl: "1"  
  thin: "true"
provisioner: io.openebs.csi-mayastor
allowVolumeExpansion: true

Creating a Thin-Provisioned Volume for Local PV LVM

To enable thin provisioning, set the thinProvision parameter to "yes" in the StorageClass definition. If this parameter is omitted, the volume is created as thick-provisioned by default.

Copy
StorageClass Definition for Thin-Provisioned Volume for Local PV LVM
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
 name: lvm-sc
allowVolumeExpansion: true
provisioner: local.csi.openebs.io
parameters:
  volgroup: "lvmvg"
  thinProvision: "yes"

Ensure the dm_thin_pool kernel module is loaded on all nodes before creating thin-provisioned volumes.

Verifying Kernel Module Availability

Run the following command on all nodes to verify that the required kernel module is loaded:

Copy
Check if dm_thin_pool Module is Loaded
lsmod | grep dm_thin_pool

If the module is not loaded, load it using:

Copy
Load the dm_thin_pool Kernel Module
modprobe dm_thin_pool

Extending the Thin Pool Size

Thin pools are implemented as logical volumes. You can extend their size using the lvextend command. Note that reducing the size of a thin pool is not supported.

Copy
Extend Thin Pool Size
lvextend -L +15G lvmvg/thin_pool
Copy
Sample Output
Extending logical volume thin_pool to 30.00 GiB
Logical volume mythinpool successfully resized

Configuring Auto-Extension for Thin Pools

By default, auto-extension of thin pools is not enabled. This allows you to retain control over pool growth, especially in environments where limits must be enforced manually.

To enable automatic extension monitoring, the thin pool must be explicitly monitored using lvchange.

  1. Check Monitoring Status.

    Copy
    Verify if Thin Pool Monitoring is Enabled
    lvs -o+seg_monitor
    Copy
    Sample Output
    LV             VG    Attr       LSize Pool           Origin Data%  Meta%  Move Log Cpy%Sync Convert Monitor
    lvmvg_thinpool lvmvg twi-aotz-- 2.07g                       0.00   11.52                            not monitored

    If the Monitor column indicates not monitored, proceed to enable monitoring.

  2. Enable Monitoring.

    Copy
    Enable Monitoring for Thin Pool
    lvchange --monitor y lvmvg/lvmvg_thinpool

    Verify that the monitoring is enabled:

    Copy
    Confirm Monitoring Status
    lvs -o+seg_monitor
    Copy
    Sample Output
    LV             VG    Attr       LSize Pool           Origin Data%  Meta%  Move Log Cpy%Sync Convert Monitor
    lvmvg_thinpool lvmvg twi-aotz-- 2.07g                       0.00   11.52                            monitored

Configure Threshold for Auto-Extension

To set a threshold for auto-extension of the thin pool, edit the /etc/lvm/lvm.conf file. By default, the threshold is 100%, meaning the pool will not grow automatically. For example, setting the threshold to 75% will trigger an auto-extension when the pool reaches 75% capacity.

Copy
View Auto-Extension Settings
grep -E '^\s*thin_pool_auto' /etc/lvm/lvm.conf
Copy
Sample Output
thin_pool_autoextend_threshold = 100
thin_pool_autoextend_percent = 20

You may modify these values as needed:

  • thin_pool_autoextend_threshold = 75
  • thin_pool_autoextend_percent = 20

This configuration means the thin pool will auto-extend by 20% when it reaches 75% of its capacity.

Creating a Thin-Provisioned Volume for Local PV ZFS

To enable thin provisioning, set the thinProvision parameter to yes in the StorageClass definition. Refer to the StorageClass Parameters Documentation for more information.

Copy
StorageClass Definition for Thin-Provisioned Volume for Local PV ZFS
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: puls8-zfspv
parameters:
  recordsize: "128k"
  compression: "off"
  dedup: "off"
  fstype: "zfs"
  poolname: "zfspv-pool"
  thinProvision: "yes"
provisioner: zfs.csi.openebs.io

Benefits of Thin Provisioning

  • Over-provisioning of physical storage to create larger virtual volumes.
  • Efficient use of available disk space.
  • Flexibility to scale capacity based on actual usage.
  • Cost-effective resource management.

Learn More