Thin Provisioning
Explore this Page
- Overview
- Creating a Thin-Provisioned Volume for Replicated PV Mayastor
- Creating a Thin-Provisioned Volume for Local PV LVM
- Creating a Thin-Provisioned Volume for Local PV ZFS
- Benefits of Thin Provisioning
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.
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.
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:
If the module is not loaded, load it using:
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.
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
.
-
Check Monitoring Status.
CopySample OutputLV 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 monitoredIf the
Monitor
column indicatesnot monitored
, proceed to enable monitoring. -
Enable Monitoring.
Verify that the monitoring is enabled:
CopySample OutputLV 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.
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.
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