Why longhorn volume still shows more space than the actual size after deleting the content?
This document (000020027) is provided subject to the disclaimer at the end of this document.
Why does Longhorn report higher
Actual Size for a volume than the usage reported by the filesystem, even after deleting content?
- A Kubernetes cluster with Longhorn installed
- An existing workload using a Persistent Volume (PV) of the Longhorn StorageClass (SC)
Whilst Longhorn storage is thin-provisioned, a volume cannot shrink in size after content is removed.
Per the Longhorn Documentation: "This happens because Longhorn operates on the block level, not the filesystem level, so Longhorn doesn’t know if the content has been removed by a user or not. That information is mostly kept at the filesystem level."
You can demonstrate this behaviour, by attaching a 10GB Longhorn volume to a Pod, creating 6GB of files on the volume and then deleting 4GB, as follows:
Increase the disk usage of the volume:
dd if=/dev/zero of=4gbfile bs=4G count=1 dd if=/dev/zero of=2gbfile bs=2G count=1
4gbfilefrom the mounted volume:
Check the usage reported by the filesystem, by running
du -shon the mounted volume, which will show 2GB.
Navigate to the Longhorn UI and check the
Actual Size, reported under
Volume Detailsin the Volume view, which will show 6GB of usage still.
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000020027
- Creation Date: 06-May-2021
- Modified Date:06-May-2021
- SUSE Rancher
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com