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.
Environment
- A Kubernetes cluster with Longhorn installed
- An existing workload using a Persistent Volume (PV) of the Longhorn StorageClass (SC)
Situation
Why does Longhorn report higher Actual Size
for a volume than the usage reported by the filesystem, even after deleting content?
Resolution
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
-
Remove the
4gbfile
from the mounted volume:rm 4gbfile
-
Check the usage reported by the filesystem, by running
du -sh
on the mounted volume, which will show 2GB. -
Navigate to the Longhorn UI and check the
Actual Size
, reported underVolume Details
in the Volume view, which will show 6GB of usage still.
Further Reading
Status
Disclaimer
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:22-Jul-2024
-
- SUSE Rancher
- SUSE Rancher Longhorn
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com